-
Notifications
You must be signed in to change notification settings - Fork 874
Investigate coder as an auth method for vault #13127
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
Comments
We can also investigate this by creating a vault plugin. |
We have published a vault module that allows using the OIDC access tokenn from the shared IdP provider for Coder and Vault and automatically logs the user into Vault. This works by configuring Vault with JWT auth and reusing the Coder's OIDC access token to exchange for a Vault token. |
from a security point of view, it would make sense to do what gitlab CI does for authentication to vault / other systems, in the CI config file, you ask gitlab to issue a token for how this translates to coder: the agent (not user) can request a token using it's authentication the key thing though, (if you want to treat the token generated by coder as being the the user themselves, then you would configure vault's jwt config with e.g. you would be able to use this to give user X different permissions depending on which coder workspace they use to access vault from additionally, this token can be refreshed for the entire lifetime of the workspace once you pass a short lived OIDC token that you have no way to renew without user intervention, how i see this looking from a technical point of view: the next part, issuing the tokens is up for debate then, there would be a command for coder cli to call that endpoint from inside a workspace from the looks of it, the agents currently authenticate with a session token issued to the user + their agent uuid. |
it might make sense to handle this similar to the external auth providers, |
this template sort of emulates what i'm talking about, though i dont want to be storing a private key in the template, would much prefer it be generated by coder and given to the template https://gist.github.com/moo-im-a-cow/002e18137f5956893e610f85096e04e9#file-main-tf-L394-L422 this generates a jwt token like this: {
"agent": "a36714d7-7be9-4f87-ba04-fab7afcb5114",
"aud": "https://vault.birb.au",
"iat": 1745244035,
"iss": "https://code.birb.au",
"owner": "b94eeac0-5cb4-43bf-93a1-6b1756ccd3ae",
"owner_email": "birdie@birb.au",
"owner_groups": [
"Everyone"
],
"owner_login_type": "password",
"owner_name": "birdie",
"provisioner": "ffc654cc-b3e8-45f0-abae-173ca0d9e031",
"provisioner_arch": "amd64",
"provisioner_os": "linux",
"sub": "f29b73bf-d0d0-42fd-a327-be19d1ffe7f8",
"template": "5956ace7-2442-4827-a9e4-44e4e7173bc5",
"template_name": "test",
"template_version": "friendly_maxwell4",
"workspace": "f29b73bf-d0d0-42fd-a327-be19d1ffe7f8",
"workspace_name": "brown-chipmunk-42",
"workspace_port": 443,
"workspace_url": "https://code.birb.au"
} then, configure 2 vault roles like this (one with user_claim=sub and one with user_claim=owner_email):
The reason this is so useful, is that vault can use every field in that token for policies. all the data, sent and cryptographically secured by coder can be seen as trustworthy by vault, and can be used to inform decisions e.g. a very simple example, the vault admin wants to allow me to access a secret only from one specific workspace:
they place the secret at path now, I can only access it from the vault CLI in that one specific workspace in coder, context in oidc token = "user just typed their password in, completed mfa and wanted to access application coder (not vault)" |
Extracted from #11084 (comment) Probably depends on #11084
For vault we may look into as becoming one of the supported auth methods
More details: https://developer.hashicorp.com/vault/docs/concepts/auth
I think our flow can work best similar to GitHub auth method. Where we pre-configure vault with a Coder OAuth app and then can login simply
With
vault login -method=coder token=$CODER_SESSION_TOKEN
Reference: https://developer.hashicorp.com/vault/docs/auth/github
Use case(s)
The text was updated successfully, but these errors were encountered: