common-fate / granted

The easiest way to access your cloud.
https://granted.dev
MIT License
957 stars 90 forks source link

Add `granted cache clear all` command #581

Open shwethaumashanker opened 6 months ago

shwethaumashanker commented 6 months ago

Request from slack: Is there a command or way to clear all the cached credentials in one go, in batch and headless. Like run granted cache clear for everything, specifically session-credentials.

I did this workaround, but it is just a hack:

while granted cache list 2>&1 | grep -q session-credentials ; do (echo -e 'session-credentials\n'; sleep 0.1; echo) | granted cache clear >/dev/null 2>&1 ; done
manuelfedele commented 6 months ago

I use to fetch credentials with a custom flow and put those creds in .aws/credentials file. The point is that I put short lived credentials there, and granted caches those credential (with which TTL? It's not clear to me).

It would be great to have this "granted cache clear all" command, or a customizable TTL so that granted session-credentials can expire accordingly to the .aws/credentials session tokens.

keymon commented 5 months ago

Other workaround in macosx: Open KeyChain Access app, search for "granted" and delete the credentials there:

image

Or from the command line run this. This is quicker than the example above

while security delete-generic-password -l "granted-aws-session-credentials"; do true; done

or more quiet

    while security find-generic-password -l "granted-aws-session-credentials" >/dev/null 2>&1 ; do
        security delete-generic-password -l "granted-aws-session-credentials" > /dev/null;
        echo -n .
    done