This repository was archived by the owner on Jul 18, 2019. It is now read-only.
Add a scriptable check for valid credentials#182
Merged
djmitche merged 1 commit intotaskcluster:masterfrom Nov 28, 2017
Merged
Conversation
This allows users to `taskcluster signin --check` and get
an exit code of 1 if their credentials are either not found,
or expired.
I've successfully used it with this bash wrapper:
tc() {
if ! TC=$(which taskcluster)
then
echo "Unable to find taskcluster command"
return
fi
CLIENTVARS=${TASKCLUSTER_CLIENT_STORE:-"/dev/shm/tcclient.creds"}
if [ -f "$CLIENTVARS" ] ; then
# shellcheck source=/dev/null
source "$CLIENTVARS"
fi
if ! ${TC} signin --check; then
${TC} signin > "$CLIENTVARS"
# shellcheck source=/dev/null
source "$CLIENTVARS"
fi
${TC} "$@"
}
Contributor
Author
|
A potential option for #181 (which I forgot to mention in the initial comment) |
djmitche
approved these changes
Nov 28, 2017
| return fmt.Errorf("failed to check credentials: %s", err) | ||
| } | ||
| if len(result.Scopes) == 0 { | ||
| fmt.Println("No valid credentials were found") |
Contributor
There was a problem hiding this comment.
More accurate to say "No valid credentials were found, or credentials have no scopes".
I think this is a good way to check for access all the same, but if someone found themselves in the weird case of having a clientId with no scopes, the message might help them figure out what's going on.
Contributor
|
BTW, in the shell wrapper it'd probably be good to have the creds in a subdirectory where that subdirectory is chmod 700. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows users to
taskcluster signin --checkand getan exit code of 1 if their credentials are either not found,
or expired.
I've successfully used it with this bash wrapper: