Skip to content

Commit 1555154

Browse files
authored
feat: add OAuth2 provider functionality as an experiment (#18692)
# Add OAuth2 Provider Functionality as an Experiment This PR adds a new experiment flag `oauth2` that enables OAuth2 provider functionality in Coder. When enabled, this experiment allows Coder to act as an OAuth2 provider. The changes include: - Added the new `ExperimentOAuth2` constant with appropriate documentation - Updated the OAuth2 provider middleware to check for the experiment flag - Modified the error message to indicate that the OAuth2 provider requires enabling the experiment - Added the new experiment to the known experiments list in the SDK Previously, OAuth2 provider functionality was only available in development mode. With this change, it can be enabled in production environments by activating the experiment.
1 parent 2c95a1d commit 1555154

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

coderd/apidoc/docs.go

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/oauth2.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ const (
3737
displaySecretLength = 6 // Length of visible part in UI (last 6 characters)
3838
)
3939

40-
func (*API) oAuth2ProviderMiddleware(next http.Handler) http.Handler {
40+
func (api *API) oAuth2ProviderMiddleware(next http.Handler) http.Handler {
4141
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
42-
if !buildinfo.IsDev() {
42+
if !api.Experiments.Enabled(codersdk.ExperimentOAuth2) && !buildinfo.IsDev() {
4343
httpapi.Write(r.Context(), rw, http.StatusForbidden, codersdk.Response{
44-
Message: "OAuth2 provider is under development.",
44+
Message: "OAuth2 provider functionality requires enabling the 'oauth2' experiment.",
4545
})
4646
return
4747
}

codersdk/deployment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3341,6 +3341,7 @@ const (
33413341
ExperimentNotifications Experiment = "notifications" // Sends notifications via SMTP and webhooks following certain events.
33423342
ExperimentWorkspaceUsage Experiment = "workspace-usage" // Enables the new workspace usage tracking.
33433343
ExperimentWebPush Experiment = "web-push" // Enables web push notifications through the browser.
3344+
ExperimentOAuth2 Experiment = "oauth2" // Enables OAuth2 provider functionality.
33443345
)
33453346

33463347
// ExperimentsKnown should include all experiments defined above.
@@ -3350,6 +3351,7 @@ var ExperimentsKnown = Experiments{
33503351
ExperimentNotifications,
33513352
ExperimentWorkspaceUsage,
33523353
ExperimentWebPush,
3354+
ExperimentOAuth2,
33533355
}
33543356

33553357
// ExperimentsSafe should include all experiments that are safe for

docs/reference/api/schemas.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/api/typesGenerated.ts

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)