# chainctl token helper This little helper just wraps calls to `chainctl auth` and reads token ttls. On my workstation, I call it from ~/.profile like this: ```bash is_interactive() { [ -t 0 ] && [ -t 1 ] } if is_interactive; then # this is painful. I'd like to say "until 6:00 PM US/Eastern". # but I can't figure a way to do that. h=$(date --utc +%H) if [ $h -le 18 ]; then login-images --keepalive --until="18:00" else echo "not login-images, its after 6:00 PM local time" fi fi ``` ## Usage ``` Usage: login-images [ options ] [audience1 [...]] Use chainctl to get a token for audience. options: -u | --until TIME ensure you have a token until DATE -f | --for MINUTES ensure you have access for MINUTES minutes Examples: * Make sure you have tokens for default audiences until quitting time. login-images --until="6:00 PM" # note that if you have busybox date, the above wont work. # you can use "22:00" # * logout login-images --logout * check/print the existing token for cgr.dev login-images --check cgr.dev ``` ## Example * login-images --check $ login-images -c https://console-api.enforce.dev - 55m refresh=1187m my.email@chainguard.dev apk.cgr.dev - 55m refresh=1189m my.email@chainguard.dev cgr.dev - 55m refresh=1189m my.email@chainguard.dev * login-images without args will login to the audience provided or the builtin list Below, the was good for 58 minutes so it did not force a new login. The other two sites needed login. $ login-images console-api.enforce.dev had 0m wanted 30m Authenticating... Enter the verification code MZDD-XVMP in your browser at: https://auth.chainguard.dev/activate Code will be valid for 900 seconds Token received! Successfully exchanged token. Valid! Id: aa4458f1e77704575053c079c9b3b6db8bb47642 console-api.enforce.dev - good for 59m apk.cgr.dev had 0m wanted 30m Authenticating... Enter the verification code QCDR-XFWJ in your browser at: https://auth.chainguard.dev/activate Code will be valid for 900 seconds Token received! Successfully exchanged token. Valid! Id: aa4458f1e77704575053c079c9b3b6db8bb47642 apk.cgr.dev - good for 60m cgr.dev - good for 58m