From 1e4f72d93c1a411f72fc59bca4d799cbbae3e138 Mon Sep 17 00:00:00 2001 From: Simon Kowallik Date: Mon, 3 Jan 2022 22:17:58 +0100 Subject: [PATCH] fixes issue \#12 + doc updates --- README.md | 12 ++++++------ ihac-auth | 13 +++++++------ ihac-commandlist | 2 +- ihac-commandrun | 2 +- ihac-diagnostics | 2 +- ihac-fileget | 2 +- ihac-filelist | 2 +- ihac-qkviewadd | 2 +- ihac-qkviewdelete | 2 +- ihac-qkviewget | 2 +- ihac-qkviewlist | 2 +- 11 files changed, 22 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 5b0690d..c721bc9 100644 --- a/README.md +++ b/README.md @@ -104,18 +104,18 @@ Password: OK ``` -Urlencoded credentials as an argument +JSON formatted credentials as an argument ```sh -simon@bigip ~ $ ihac-auth 'userid=simon%40example.com&passwd=MyP%40ssw0rd' +simon@bigip ~ $ ihac-auth '{"user_id": "simon@example.com", "user_secret": "MyP@ssw0rd"}' OK ``` -Urlencoded credentials via STDIN +JSON formatted credentials via STDIN ```sh -simon@bigip ~ $ cat $HOME/credentials.txt | ihac-auth +simon@bigip ~ $ cat $HOME/credentials.json | ihac-auth -simon@bigip ~ $ cat $HOME/credentials.txt -userid=simon%40example.com&passwd=MyP%40ssw0rd +simon@bigip ~ $ cat $HOME/credentials.json +{"user_id": "simon@example.com", "user_secret": "MyP@ssw0rd"} ``` De-authenticate / delete session cookies diff --git a/ihac-auth b/ihac-auth index 7bc43ca..bfeae14 100755 --- a/ihac-auth +++ b/ihac-auth @@ -2,7 +2,7 @@ #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC -VERSION="3.1" +VERSION="3.2" # IHACAUTH="$HOME/.ihac/auth.jar" if [[ ! -d "$HOME/.ihac" ]]; then mkdir "$HOME/.ihac"; fi @@ -36,7 +36,7 @@ then echo -n "Password: " read -s password && echo if [[ -z "$password" ]]; then echoerr "Error: need password to authenticate."; exit 1; fi - USRPW="userid=$(urlencode $username)&passwd=$(urlencode $password)" + USRPW="{\"user_id\": \"$username\", \"user_secret\": \"$password\"}" else if [[ "$1" == "delete" ]] || [[ "$1" == "--delete" ]] || [[ "$1" == "-d" ]] || [[ "$1" == "--logout" ]] then @@ -60,12 +60,13 @@ else fi result=`curl -si$IHACPROXY --user-agent "iHAC/$VERSION" --cookie-jar "$IHACAUTH" \ - --data $USRPW \ - -o - https://login.f5.com/resource/loginAction.jsp \ + -H "Content-type: application/json" \ + --data-ascii "$USRPW" \ + -o - https://api.f5.com/auth/pub/sso/login/ihealth-api \ | sort -r \ | perl -ne 's/\r\n//g; - if(m/ssosession/gi) {print "OK";exit 0} - if(m/login.jsp/gi) {print "auth_failed";exit 0}'` + if(m/ssosession/gi) {print "OK";exit 0} + if(m/login.jsp/gi) {print "auth_failed";exit 0}'` if [[ "$result" == "OK" ]]; then echo "OK"; exit 0; fi if [[ "$result" == "auth_failed" ]]; then echoerr "Error: authentication failed."; exit 1; fi diff --git a/ihac-commandlist b/ihac-commandlist index bf9c732..4d97ff1 100755 --- a/ihac-commandlist +++ b/ihac-commandlist @@ -2,7 +2,7 @@ #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC -VERSION="3.1" +VERSION="3.2" # IHACAUTH="$HOME/.ihac/auth.jar" IHACPROXYFILE="$HOME/.ihac/IHACPROXY" diff --git a/ihac-commandrun b/ihac-commandrun index 5a6b4a6..c5da7fa 100755 --- a/ihac-commandrun +++ b/ihac-commandrun @@ -2,7 +2,7 @@ #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC -VERSION="3.1" +VERSION="3.2" # IHACAUTH="$HOME/.ihac/auth.jar" IHACPROXYFILE="$HOME/.ihac/IHACPROXY" diff --git a/ihac-diagnostics b/ihac-diagnostics index 6b79a96..2e369cb 100755 --- a/ihac-diagnostics +++ b/ihac-diagnostics @@ -2,7 +2,7 @@ #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC -VERSION="3.1" +VERSION="3.2" # IHACAUTH="$HOME/.ihac/auth.jar" IHACPROXYFILE="$HOME/.ihac/IHACPROXY" diff --git a/ihac-fileget b/ihac-fileget index ba70826..6b0440a 100755 --- a/ihac-fileget +++ b/ihac-fileget @@ -2,7 +2,7 @@ #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC -VERSION="3.1" +VERSION="3.2" # IHACAUTH="$HOME/.ihac/auth.jar" IHACPROXYFILE="$HOME/.ihac/IHACPROXY" diff --git a/ihac-filelist b/ihac-filelist index 4d0dbc6..27bfdb8 100755 --- a/ihac-filelist +++ b/ihac-filelist @@ -2,7 +2,7 @@ #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC -VERSION="3.1" +VERSION="3.2" # IHACAUTH="$HOME/.ihac/auth.jar" IHACPROXYFILE="$HOME/.ihac/IHACPROXY" diff --git a/ihac-qkviewadd b/ihac-qkviewadd index cd01e72..54be182 100755 --- a/ihac-qkviewadd +++ b/ihac-qkviewadd @@ -2,7 +2,7 @@ #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC -VERSION="3.1" +VERSION="3.2" # IHACAUTH="$HOME/.ihac/auth.jar" IHACPROXYFILE="$HOME/.ihac/IHACPROXY" diff --git a/ihac-qkviewdelete b/ihac-qkviewdelete index 9956b0b..020035b 100755 --- a/ihac-qkviewdelete +++ b/ihac-qkviewdelete @@ -2,7 +2,7 @@ #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC -VERSION="3.1" +VERSION="3.2" # IHACAUTH="$HOME/.ihac/auth.jar" IHACPROXYFILE="$HOME/.ihac/IHACPROXY" diff --git a/ihac-qkviewget b/ihac-qkviewget index 6f755d0..e259132 100755 --- a/ihac-qkviewget +++ b/ihac-qkviewget @@ -2,7 +2,7 @@ #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC -VERSION="3.1" +VERSION="3.2" # IHACAUTH="$HOME/.ihac/auth.jar" IHACPROXYFILE="$HOME/.ihac/IHACPROXY" diff --git a/ihac-qkviewlist b/ihac-qkviewlist index e1c663f..66c3246 100755 --- a/ihac-qkviewlist +++ b/ihac-qkviewlist @@ -2,7 +2,7 @@ #license: MIT #author: Simon Kowallik #source: https://github.com/simonkowallik/iHAC -VERSION="3.1" +VERSION="3.2" # IHACAUTH="$HOME/.ihac/auth.jar" IHACPROXYFILE="$HOME/.ihac/IHACPROXY"