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

Support linking OIDC accounts, not just git provider accounts #9116

Closed
bpmct opened this issue Aug 15, 2023 · 3 comments
Closed

Support linking OIDC accounts, not just git provider accounts #9116

bpmct opened this issue Aug 15, 2023 · 3 comments
Assignees
Labels
feature Something we don't have yet

Comments

@bpmct
Copy link
Member

bpmct commented Aug 15, 2023

Background

Coder allows developers to link their git accounts to simplify git authentication in their workspace. When they git clone, Coder helps them authenticate with their provider or a template can even require that they authenticate in advance of creating their workspace:

image

On the server side, the admin configures this by providing OIDC credentials to the Coder server. The Coder server will store and rotate users' tokens on their behalf. You can read about this feature in our documentation

Vision

There are other cases where a workspace can benefit to being pre-authenticated to other providers. Both for runtime (e.g. artifactory token is injected into the workspace) and build-time (user authenticates with a Terraform provider with their OIDC token).

Create workspace page

Instead of Coder having to support native integrations with each platform, Coder supports generic OIDC (just like for log in and git auth) and then the template can use the token for whatever it wants (provisioning resources, pre-authenticating a CLI, etc).

To avoid code duplication, we can extend our git auth code to support non-git providers. Coder templates will still magically authenticate git for git providers with GIT_ASKPASS.

Mock server config:

CODER_INTEGRATION_0_ID=primary-github
CODER_INTEGRATION_0_TYPE=github
CODER_INTEGRATION_0_CLIENT_ID=xxxxxx
CODER_INTEGRATION_0_CLIENT_SECRET=xxxxxxx
CODER_INTEGRATION_0_GIT_REGEX=github.com/orgname

CODER_INTEGRATION_1_ID=azure-key-vault
CODER_INTEGRATION_1_TYPE=oidc
CODER_INTEGRATION_1_DISPLAY_NAME="Azure Key Vault"
CODER_INTEGRATION_1_ICON="https://wiki.example.org/akv.svg"
CODER_INTEGRATION_1_REQUIRED=true
CODER_INTEGRATION_1_CLIENT_ID=xxxxxx
CODER_INTEGRATION_1_CLIENT_SECRET=xxxxxxx
CODER_INTEGRATION_1_SCOPES="https://vault.azure.net/user_impersonation"

Within the template:

data "coder_integration" "azure-key-vault" {
  id="azure-key-vault"
}

resource "coder_agent" {
   # 
  env {
    name = "AZ_TOKEN"
    value = data.coder_git_auth.token
  }
}

Why not request all of these scopes when the user authenticates to Coder?

Identify providers are typically managed via a different organization than developer tools so it's typically difficult or impossible for organizations to create a central token that Coder can use directly against a large amount of APIs. Some advanced organizations allow token exchanges, but that is still not common.

For example, Azure Active Directory (a common identity provider) can only request scopes from Microsoft's Graph API. There is no way current Coder wants to also request a token that works for authentication and Azure Key Vault, for example.

@bpmct bpmct changed the title Switch to generic support for linking OIDC accounts, not just git provider accounts Support for linking OIDC accounts, not just git provider accounts Aug 15, 2023
@bpmct bpmct changed the title Support for linking OIDC accounts, not just git provider accounts Support linking OIDC accounts, not just git provider accounts Aug 15, 2023
@cdr-bot cdr-bot bot added the feature Something we don't have yet label Aug 15, 2023
@matifali
Copy link
Collaborator

matifali commented Sep 18, 2023

we could also create a new resource coder_variable which would be populated by these auth providers and can be consumed by coder_agent to set in the workspace as an environment variable.

This could allow us to modularize the auth methods as separate modules.

@kylecarbs
Copy link
Member

This is almost done!

@matifali
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Something we don't have yet
Projects
None yet
Development

No branches or pull requests

3 participants