Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse tokens for up to 15 minutes - Wrapper script for client #99

Closed
roffe opened this issue Jun 15, 2018 · 8 comments
Closed

Reuse tokens for up to 15 minutes - Wrapper script for client #99

roffe opened this issue Jun 15, 2018 · 8 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@roffe
Copy link

roffe commented Jun 15, 2018

Hi gang and thanks for the hard work!

Got the authenticator running today and everything seems really nice!

However i noticed that all my kubectl commands now takes a little longer to complete. Not much but enough for me to hack together this little proof of concept "wrapper/cache" for the authenticator that stores the last response and would cat it directly from disk if the file is <800 seconds old.

#!/usr/bin/env bash
# Only tested on OS X
CACHE_FILE=${HOME}/.kube/heptio-authenticator-${AWS_PROFILE}.cache
MAXTIME=800
if [ -f $CACHE_FILE ]; then
    TS_DB=$(stat -t "%s" ${CACHE_FILE} | cut -d' ' -f10 | tr -d '"')
    AGE=$(( `date +%s` - $TS_DB ))
    if [[ $AGE -le $MAXTIME ]]; then
        cat ${CACHE_FILE}
    else
        heptio-authenticator-aws "$@" | tee $CACHE_FILE
    fi
else
    heptio-authenticator-aws "$@" | tee $CACHE_FILE
fi

Would something similar be doable directly in the client and let a user pass for example --cache as a runtime opt to use the disk cache for a slighter faster response

@christopherhein
Copy link
Member

Totally feasible, it'd still need the file to recall for the cache but we could probably add a function to check for this file and its age after https://github.com/heptio/authenticator/blob/master/cmd/heptio-authenticator-aws/token.go#L45 and if it passed add a func to token{} interface to GetFromCache()

@christopherhein
Copy link
Member

@roffe would you like to give this a go and work on a PR?

@roffe
Copy link
Author

roffe commented Jun 19, 2018

Sure, i'll take a crack at it and see what i can come up with

@jrnt30
Copy link
Contributor

jrnt30 commented Jul 12, 2018

I think we would also need to adjust the pre-signed TTL that the token creation generates as well for it to work on the server side as well, wouldn't we?

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 18, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 18, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

5 participants