From 93e49c59a548895e2db2940e70f37f0aa30ad82c Mon Sep 17 00:00:00 2001 From: Chris Hallberg Date: Thu, 9 Feb 2023 16:38:19 -0500 Subject: [PATCH] Update auth to prompt for missing data Adds some sophistication to make getting started easier and keep less credentials stored in plain text. - Tries to get OKAPI url and tenant from the appropriate files. - Prompts for the OKAPI url and tenant if those files are missing. - Also saves those to the right place (`okapi.url`, `tenant`) - Finally, it prompts for username and password so they don't need to be stored on system. --- auth | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/auth b/auth index 3579453a..7f2bf070 100644 --- a/auth +++ b/auth @@ -4,10 +4,28 @@ # First generate an authentication token. You can use it for # as many calls as you like -okapi_url=your_okapi_url -tenant=your_tenant_id -username=your_username -pwd=your_password +okapi_url=$(cat okapi.url) +tenant=$(cat tenant) + +if [ -z $okapi_url ] +then + echo -n "OKAPI URL: " + read -r okapi_url + echo "$okapi_url" > okapi.url +fi + +if [ -z $tenant ] +then + echo -n "Tenant ID: " + read -r tenant + echo "$tenant" > tenant +fi + +echo -n "OKAPI username: " +read -r username + +echo -n "OKAPI password: " +read -r -s pwd IFS='' read -r -d '' okapi_login << EndOfAuth {