Skip to content

Commit 53021f6

Browse files
authored
feat: support custom oauth & oidc providers (#2357)
## Summary Add configurable custom OAuth/OIDC providers (phase 1) so projects can integrate self‑hosted/regional identity providers without requiring code changes. ## Problem Current OAuth/OIDC providers are hardcoded, require provider-specific code and env vars, and block customers who need self‑hosted or custom IdPs (e.g. GitHub Enterprise, LINE, internal OIDC servers). ## Solution Introduce database‑backed `oauth_providers` with custom:{identifier} IDs, OIDC discovery + OAuth2 manual configuration, admin CRUD APIs, and tier‑gated quotas, reusing existing /authorize and /callback flows with JWT state + PKCE.
1 parent a6076bc commit 53021f6

22 files changed

Lines changed: 4315 additions & 7 deletions

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ require (
6060
github.com/lestrrat-go/httprc v1.0.5 // indirect
6161
github.com/lestrrat-go/iter v1.0.2 // indirect
6262
github.com/lestrrat-go/option v1.0.1 // indirect
63+
github.com/lib/pq v1.10.7 // indirect
6364
github.com/mailru/easyjson v0.7.7 // indirect
6465
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
6566
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect

internal/api/api.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,21 @@ func NewAPIWithVersion(globalConfig *conf.GlobalConfiguration, db *storage.Conne
375375
})
376376
})
377377
}
378+
379+
// Custom OAuth/OIDC provider management endpoints
380+
if globalConfig.CustomOAuth.Enabled {
381+
r.Route("/custom-providers", func(r *router) {
382+
// supports both OAuth2 and OIDC via provider_type)
383+
r.Get("/", api.adminCustomOAuthProvidersList) // Optional ?type=oauth2 or ?type=oidc filter
384+
r.Post("/", api.adminCustomOAuthProviderCreate) // provider_type in request body
385+
386+
r.Route("/{identifier}", func(r *router) {
387+
r.Get("/", api.adminCustomOAuthProviderGet)
388+
r.Put("/", api.adminCustomOAuthProviderUpdate)
389+
r.Delete("/", api.adminCustomOAuthProviderDelete)
390+
})
391+
})
392+
}
378393
})
379394

380395
// OAuth Dynamic Client Registration endpoint (public, rate limited)

internal/api/apierrors/errorcode.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,12 @@ const (
102102
ErrorCodeWeb3UnsupportedChain ErrorCode = "web3_unsupported_chain"
103103
ErrorCodeOAuthDynamicClientRegistrationDisabled ErrorCode = "oauth_dynamic_client_registration_disabled"
104104
ErrorCodeEmailAddressNotProvided ErrorCode = "email_address_not_provided"
105+
ErrorCodeFeatureDisabled ErrorCode = "feature_disabled"
105106

106107
ErrorCodeOAuthClientNotFound ErrorCode = "oauth_client_not_found"
107108
ErrorCodeOAuthAuthorizationNotFound ErrorCode = "oauth_authorization_not_found"
108109
ErrorCodeOAuthConsentNotFound ErrorCode = "oauth_consent_not_found"
110+
111+
ErrorCodeCustomProviderNotFound ErrorCode = "custom_provider_not_found"
112+
ErrorCodeOverCustomProviderQuota ErrorCode = "over_custom_provider_quota"
109113
)

0 commit comments

Comments
 (0)