Skip to content

Commit

Permalink
Add no-shortname feature
Browse files Browse the repository at this point in the history
  • Loading branch information
marcvs committed Apr 23, 2024
1 parent 1fd84f2 commit dd31a69
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/oidc-tokensh/oidc-tokensh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ usage()
echo " --oidc <name>|<OP-url> name or url of the oidc-agent "
echo " configuration to use"
echo " --minsecs <seconds> minimum lifetime the token should have"
echo " -o, --outfile file in which the token will be stored"
echo " -o|--outfile <file> specify alternative file for storing"
echo " the Access Token"
echo " -v|--verbose show debug output"
Expand Down Expand Up @@ -174,7 +173,6 @@ start_token_renewer() {
${CMND_ARGS}

}
#########################################################################

cleanup()
{
Expand All @@ -188,6 +186,22 @@ cleanup()
fi
}
}
#########################################################################

[ -z ${OIDC_ID} ] && { # the --oidc option was not defined. We try to find
# if there is only one configured. If so, we use
# that one.
echo "Trying to auto-detect oidc-agent configuration"
NUM_OIDC_ACCOUNTS=$(oidc-add -l | grep -v "The following" | wc -l)
[ $NUM_OIDC_ACCOUNTS -eq 1 ] && {
OIDC_ID=$(oidc-add -l | grep -v "The following")
echo "Defaulting to $OIDC_ID"
}
[ $NUM_OIDC_ACCOUNTS -eq 1 ] || {
echo "Please specify the oidc-agent shortname that you wish to use"
exit 3
}
}

OIDC_TOKEN_ARGS="${OIDC_ID} -t ${MINSECS}"
[ "${GOTVERBOSE}" == "true" ] && [ "${START_RENEWER}" == "false" ] && {
Expand Down

0 comments on commit dd31a69

Please sign in to comment.