Skip to content

feat: allow external services to be authable #9996

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

Merged
merged 21 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow any ID
  • Loading branch information
kylecarbs committed Oct 2, 2023
commit 02718dde935a7aab1e00854a9b7bef37e28a807f
16 changes: 8 additions & 8 deletions coderd/externalauth/externalauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,6 @@ func ConvertConfig(entries []codersdk.ExternalAuthConfig, accessURL *url.URL) ([

var typ codersdk.ExternalAuthProvider
switch codersdk.ExternalAuthProvider(entry.Type) {
case codersdk.ExternalAuthProviderOpenIDConnect:
typ = codersdk.ExternalAuthProviderOpenIDConnect
case codersdk.ExternalAuthProviderAzureDevops:
typ = codersdk.ExternalAuthProviderAzureDevops
case codersdk.ExternalAuthProviderBitBucket:
Expand All @@ -381,7 +379,7 @@ func ConvertConfig(entries []codersdk.ExternalAuthConfig, accessURL *url.URL) ([
case codersdk.ExternalAuthProviderGitLab:
typ = codersdk.ExternalAuthProviderGitLab
default:
return nil, xerrors.Errorf("unknown external auth provider type: %q", entry.Type)
typ = codersdk.ExternalAuthProvider(entry.Type)
}

// Applies defaults to the config entry.
Expand Down Expand Up @@ -507,6 +505,13 @@ func applyDefaultsToConfig(typ codersdk.ExternalAuthProvider, config *codersdk.E
if config.ID == "" {
config.ID = string(typ)
}
if config.DisplayName == "" {
config.DisplayName = string(typ)
}
if config.DisplayIcon == "" {
// This is a key emoji.
config.DisplayIcon = "/emojis/1f511.png"
}
}

var defaults = map[codersdk.ExternalAuthProvider]codersdk.ExternalAuthConfig{
Expand Down Expand Up @@ -548,11 +553,6 @@ var defaults = map[codersdk.ExternalAuthProvider]codersdk.ExternalAuthConfig{
DeviceCodeURL: "https://github.com/login/device/code",
AppInstallationsURL: "https://api.github.com/user/installations",
},
codersdk.ExternalAuthProviderOpenIDConnect: {
DisplayName: "OpenID Connect",
// This is a key emoji.
DisplayIcon: "/emojis/1f511.png",
},
}

// jwtConfig is a new OAuth2 config that uses a custom
Expand Down
9 changes: 4 additions & 5 deletions codersdk/workspaceagents.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,11 +749,10 @@ func (c *Client) WorkspaceAgentLogsAfter(ctx context.Context, agentID uuid.UUID,
type ExternalAuthProvider string

const (
ExternalAuthProviderAzureDevops ExternalAuthProvider = "azure-devops"
ExternalAuthProviderGitHub ExternalAuthProvider = "github"
ExternalAuthProviderGitLab ExternalAuthProvider = "gitlab"
ExternalAuthProviderBitBucket ExternalAuthProvider = "bitbucket"
ExternalAuthProviderOpenIDConnect ExternalAuthProvider = "oidc"
ExternalAuthProviderAzureDevops ExternalAuthProvider = "azure-devops"
ExternalAuthProviderGitHub ExternalAuthProvider = "github"
ExternalAuthProviderGitLab ExternalAuthProvider = "gitlab"
ExternalAuthProviderBitBucket ExternalAuthProvider = "bitbucket"
)

type WorkspaceAgentLog struct {
Expand Down
2 changes: 1 addition & 1 deletion docs/admin/external-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Set the following environment variables to

```env
CODER_EXTERNAL_AUTH_0_ID="primary-github"
CODER_EXTERNAL_AUTH_0_TYPE=github|gitlab|azure-devops|bitbucket|oidc
CODER_EXTERNAL_AUTH_0_TYPE=github|gitlab|azure-devops|bitbucket|<name of service e.g. jfrog>
CODER_EXTERNAL_AUTH_0_CLIENT_ID=xxxxxx
CODER_EXTERNAL_AUTH_0_CLIENT_SECRET=xxxxxxx

Expand Down