diff --git a/bin/cas-curl b/bin/cas-curl index 6bf351e0..9f6edb87 100755 --- a/bin/cas-curl +++ b/bin/cas-curl @@ -3,19 +3,21 @@ if [ "$#" -eq 0 ] || [ "$1" == "help" ] || [ "$1" == "--help" ] || [ "$1" == "-h" ]; then cat <> [parameters] + usage: $0 [--trace] [--show-password] <> [parameters] commands: EOF - grep '") ''# ' $0 + # filters out help texts (marked with ## and following lines with #) from the commands itself + # (the '' makes sure that this line is not found, just the lines with actual help texts) + sed -n '/#''#/ {s/#''#//; p; :a; n; /^[[:space:]]*#/!b; s/^[[:space:]]*#//; p; ba}' $0 exit fi -export HSADMINNG_CAS_ASSUME_HEADER -if [ -f ~/.cas-curl-assume ]; then - HSADMINNG_CAS_ASSUME="$(cat ~/.cas-curl-assume)" +if [ "$2" == "--show-password" ]; then + HSADMINNG_CAS_SHOW_PASSWORD=yes + shift else - HSADMINNG_CAS_ASSUME= + HSADMINNG_CAS_SHOW_PASSWORD= fi if [ "$1" == "--trace" ]; then @@ -40,6 +42,13 @@ else } fi +export HSADMINNG_CAS_ASSUME_HEADER +if [ -f ~/.cas-curl-assume ]; then + HSADMINNG_CAS_ASSUME="$(cat ~/.cas-curl-assume)" +else + HSADMINNG_CAS_ASSUME= +fi + if [ -z "$HSADMINNG_CAS_LOGIN" ] || [ -z "$HSADMINNG_CAS_VALIDATE" ] || \ [ -z "$HSADMINNG_CAS_SERVICE_ID" ]; then cat >&2 <>\" \ + -d \"username=$HSADMINNG_CAS_USERNAME&password=$HSADMINNG_CAS_PASSWORD_DISPLAY\" \ $HSADMINNG_CAS_LOGIN -o ~/.cas-login-tgt.response -D -" HSADMINNG_CAS_TGT=`curl --fail-with-body -s -i -X POST \ -H 'Content-Type: application/x-www-form-urlencoded' \ @@ -126,45 +141,85 @@ function casValidate() { } case "${1,,}" in - "login") # reads username+password and fetches ticket granting ticket (bypasses HSADMINNG_CAS_USERNAME+HSADMINNG_CAS_PASSWORD) + + # -- generic commands -------------------------------------------------------------------------- + + "env") ## prints all related HSADMINNG_CAS_... environment variables; use '--show-password' to show the password as well + # example: cas-curl env --show-password + echo "HSADMINNG_CAS_LOGIN: $HSADMINNG_CAS_LOGIN" + echo "HSADMINNG_CAS_VALIDATE: $HSADMINNG_CAS_VALIDATE" + echo "HSADMINNG_CAS_USERNAME: $HSADMINNG_CAS_USERNAME" + if [ "$2" == "--show-password" ]; then + echo "HSADMINNG_CAS_PASSWORD: $HSADMINNG_CAS_PASSWORD" + elif [ -z "$HSADMINNG_CAS_PASSWORD" ]; then + echo "HSADMINNG_CAS_PASSWORD: <>" + else + echo "HSADMINNG_CAS_PASSWORD: <