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

Automatic Token Handling in nomad login #20478

Open
thetoothpick opened this issue Apr 22, 2024 · 1 comment
Open

Automatic Token Handling in nomad login #20478

thetoothpick opened this issue Apr 22, 2024 · 1 comment
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/cli type/enhancement

Comments

@thetoothpick
Copy link

Proposal

The current functionality of the nomad login command in HashiCorp Nomad only outputs the secret token to standard output. This feature request proposes enhancing the nomad login command to persist the secret token and automatically use it in subsequent commands without manual intervention. It would also be useful to handle token expiration, either by displaying a warning to the user or automatically requesting a new token after expiration.

Use-cases

Automatically handling secret tokens generated by nomad login would increase usability and make handling tokens easier.

Attempted Solutions

I have a shell script to export the NOMAD_TOKEN variable based on the output of `nomad login -t "{{.SecretID}}".

nomad-login () {
  export NOMAD_TOKEN=$(nomad login -t "{{.SecretID}}")
  if [[ "-v" == "$1" ]]; then
    nomad acl token self
  fi
}

However, using this on a team requires adding it to everyone's shell setup, and it's not always clear that there is a separate shell function.

@jrasell jrasell added this to Needs Triage in Nomad - Community Issues Triage via automation Apr 23, 2024
@tgross
Copy link
Member

tgross commented Apr 26, 2024

Hi @thetoothpick! The tricky thing with setting the env var is that we can't do that in the parent shell, so the login can't persist outside that session without writing to disk somewhere. One approach we've talked about for this is described in #11043, where having some kind of persistent "context" would let you switch between logins while handling all the tokens as you'd like to do here.

Ideally we'd also be able to put tokens in the session keyring rather than having them sit around on disk, but then we get into cross-platform desktop details so that might be in a v2 of any such feature. In any case, thanks for opening the issue and I'll mark this for roadmapping.

@tgross tgross added theme/cli stage/accepted Confirmed, and intend to work on. No timeline committment though. labels Apr 26, 2024
@tgross tgross moved this from Needs Triage to Needs Roadmapping in Nomad - Community Issues Triage Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/cli type/enhancement
Projects
Development

No branches or pull requests

2 participants