cas-curl to support assume
This commit is contained in:
parent
d89b4b4992
commit
fa06062dcd
21
bin/cas-curl
21
bin/cas-curl
@ -11,13 +11,23 @@ EOF
|
|||||||
exit
|
exit
|
||||||
fi
|
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 [ "$1" == "--trace" ]; then
|
if [ "$1" == "--trace" ]; then
|
||||||
function trace() {
|
function trace() {
|
||||||
echo "$*" >&2
|
echo "$*" >&2
|
||||||
}
|
}
|
||||||
function doCurl() {
|
function doCurl() {
|
||||||
set -x
|
set -x
|
||||||
curl --fail-with-body --header "Authorization: $HSADMINNG_CAS_TICKET" "$@"
|
curl --fail-with-body \
|
||||||
|
--header "Authorization: $HSADMINNG_CAS_TICKET" \
|
||||||
|
--header "assumed-roles: $HSADMINNG_CAS_ASSUME" \
|
||||||
|
"$@"
|
||||||
set +x
|
set +x
|
||||||
}
|
}
|
||||||
shift
|
shift
|
||||||
@ -76,6 +86,7 @@ function casLogin() {
|
|||||||
if [ -z "$HSADMINNG_CAS_TGT" ]; then
|
if [ -z "$HSADMINNG_CAS_TGT" ]; then
|
||||||
echo "ERROR: could not get ticket granting ticket" >&2
|
echo "ERROR: could not get ticket granting ticket" >&2
|
||||||
cat ~/.cas-login-tgt.response >&2
|
cat ~/.cas-login-tgt.response >&2
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "$HSADMINNG_CAS_TGT" >~/.cas-login-tgt
|
echo "$HSADMINNG_CAS_TGT" >~/.cas-login-tgt
|
||||||
trace "$HSADMINNG_CAS_TGT"
|
trace "$HSADMINNG_CAS_TGT"
|
||||||
@ -121,6 +132,14 @@ case "${1,,}" in
|
|||||||
export HSADMINNG_CAS_PASSWORD=
|
export HSADMINNG_CAS_PASSWORD=
|
||||||
casLogin
|
casLogin
|
||||||
;;
|
;;
|
||||||
|
"assume") # assumes the given comma-separated roles
|
||||||
|
shift
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
rm ~/.cas-curl-assume
|
||||||
|
else
|
||||||
|
echo "$1" >~/.cas-curl-assume
|
||||||
|
fi
|
||||||
|
;;
|
||||||
"logout") # logout, deleting ticket granting ticket
|
"logout") # logout, deleting ticket granting ticket
|
||||||
casLogout
|
casLogout
|
||||||
;;
|
;;
|
||||||
|
Loading…
Reference in New Issue
Block a user