Skip to content
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
srfraser:signin_exitcode
Nov 28, 2017
Merged

Add a scriptable check for valid credentials#182
djmitche merged 1 commit intotaskcluster:masterfrom
srfraser:signin_exitcode

Conversation

@srfraser
Copy link
Copy Markdown
Contributor

@srfraser srfraser commented Nov 28, 2017

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} "$@"
}

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} "$@"
}
@srfraser
Copy link
Copy Markdown
Contributor Author

A potential option for #181 (which I forgot to mention in the initial comment)

@djmitche djmitche self-requested a review November 28, 2017 21:44
Comment thread cmds/signin/signin.go
return fmt.Errorf("failed to check credentials: %s", err)
}
if len(result.Scopes) == 0 {
fmt.Println("No valid credentials were found")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@djmitche
Copy link
Copy Markdown
Contributor

BTW, in the shell wrapper it'd probably be good to have the creds in a subdirectory where that subdirectory is chmod 700.

@djmitche djmitche merged commit 28a1328 into taskcluster:master Nov 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants