diff --git a/internal/api/custom_oauth_admin.go b/internal/api/custom_oauth_admin.go index b8da661d49..e1b8331c92 100644 --- a/internal/api/custom_oauth_admin.go +++ b/internal/api/custom_oauth_admin.go @@ -10,6 +10,7 @@ import ( popslices "github.com/gobuffalo/pop/v6/slices" "github.com/gofrs/uuid" "github.com/supabase/auth/internal/api/apierrors" + "github.com/supabase/auth/internal/conf" "github.com/supabase/auth/internal/models" "github.com/supabase/auth/internal/observability" "github.com/supabase/auth/internal/storage" @@ -59,6 +60,15 @@ type AdminCustomOAuthProviderParams struct { Enabled *bool `json:"enabled,omitempty"` EmailOptional *bool `json:"email_optional,omitempty"` + // ClientAuthMethod is how the server authenticates to the token endpoint: + // "client_secret" or "private_key_jwt". It defaults to "client_secret" on + // create; on update, omitting it keeps the current method. + ClientAuthMethod string `json:"client_auth_method,omitempty"` + // ClientAssertionAudience sets the aud claim of client assertions, which + // otherwise is the provider's issuer. On update, omitting it keeps the + // current value and an empty string removes the override. + ClientAssertionAudience *string `json:"client_assertion_audience,omitempty"` + // OIDC-specific fields Issuer string `json:"issuer,omitempty"` DiscoveryURL *string `json:"discovery_url,omitempty"` @@ -162,6 +172,11 @@ func (a *API) adminCustomOAuthProviderCreate(w http.ResponseWriter, r *http.Requ return err } + clientAuthMethod, err := validateClientAuthParams(params, providerType, nil, &config.Experimental.ClientAssertion) + if err != nil { + return err + } + // Validate authorization params (no reserved OAuth parameters) if err := validateAuthorizationParams(params.AuthorizationParams); err != nil { return err @@ -210,21 +225,24 @@ func (a *API) adminCustomOAuthProviderCreate(w http.ResponseWriter, r *http.Requ // Create provider model provider := buildProviderFromParams(params, providerType) + applyClientAuthParams(provider, params, clientAuthMethod) // For OIDC providers, fetch and validate the discovery document before persisting. // This catches misconfigurations (bad issuer URL, missing endpoints) at admin time // rather than failing silently at user login time. if providerType == models.ProviderTypeOIDC { - discovery, err := fetchAndValidateDiscovery(ctx, provider.GetDiscoveryURL(), params.Issuer) + discovery, err := fetchOIDCDiscovery(ctx, provider.GetDiscoveryURL(), params.Issuer) if err != nil { return err } provider.SetDiscoveryCache(discovery) } - // Encrypt and store client secret - if err := provider.SetClientSecret(params.ClientSecret, config.Security.DBEncryption); err != nil { - return apierrors.NewInternalServerError("Error encrypting custom OAuth provider client secret").WithInternalError(err) + // Encrypt and store client secret. private_key_jwt providers have none. + if clientAuthMethod == models.ClientAuthMethodClientSecret { + if err := provider.SetClientSecret(params.ClientSecret, config.Security.DBEncryption); err != nil { + return apierrors.NewInternalServerError("Error encrypting custom OAuth provider client secret").WithInternalError(err) + } } // Create in database @@ -309,15 +327,21 @@ func (a *API) adminCustomOAuthProviderUpdate(w http.ResponseWriter, r *http.Requ oldIssuer = *provider.Issuer } + clientAuthMethod, err := validateClientAuthParams(params, provider.ProviderType, provider, &config.Experimental.ClientAssertion) + if err != nil { + return err + } + // Update provider with new non-secret values if err := updateProviderFromParams(provider, params); err != nil { return err } + applyClientAuthParams(provider, params, clientAuthMethod) // For OIDC providers, re-validate discovery when the issuer or discovery URL changes. // This network call happens outside the transaction to avoid holding it open. if provider.IsOIDC() && (params.Issuer != "" || params.DiscoveryURL != nil) { - discovery, err := fetchAndValidateDiscovery(ctx, provider.GetDiscoveryURL(), *provider.Issuer) + discovery, err := fetchOIDCDiscovery(ctx, provider.GetDiscoveryURL(), *provider.Issuer) if err != nil { return err } @@ -431,10 +455,6 @@ func validateProviderParams(params *AdminCustomOAuthProviderParams, providerType if params.ClientID == "" { return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "client_id is required") } - if params.ClientSecret == "" { - return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "client_secret is required") - } - // Type-specific validations switch providerType { case models.ProviderTypeOIDC: @@ -456,6 +476,97 @@ func validateProviderParams(params *AdminCustomOAuthProviderParams, providerType return nil } +// validateClientAuthParams validates the client authentication params of a +// create (existing is nil) or update request and returns the method the +// provider will use. private_key_jwt is only allowed while client assertions +// are enabled and a signing key is configured. +func validateClientAuthParams( + params *AdminCustomOAuthProviderParams, + providerType models.ProviderType, + existing *models.CustomOAuthProvider, + assertionConfig *conf.ClientAssertionConfiguration, +) (models.ClientAuthMethod, error) { + method := models.ClientAuthMethod(params.ClientAuthMethod) + switch { + case method == "" && existing != nil: + method = existing.ClientAuthMethod + case method == "": + method = models.ClientAuthMethodClientSecret + case method != models.ClientAuthMethodClientSecret && method != models.ClientAuthMethodPrivateKeyJWT: + return "", apierrors.NewBadRequestError( + apierrors.ErrorCodeValidationFailed, + "client_auth_method must be either 'client_secret' or 'private_key_jwt'", + ) + } + + assertionsAvailable := assertionConfig.Enabled && assertionConfig.SigningKey != nil + if !assertionsAvailable && + (params.ClientAuthMethod == string(models.ClientAuthMethodPrivateKeyJWT) || params.ClientAssertionAudience != nil) { + return "", apierrors.NewBadRequestError( + apierrors.ErrorCodeValidationFailed, + "private_key_jwt client authentication is not enabled", + ) + } + + switch method { + case models.ClientAuthMethodClientSecret: + if params.ClientAssertionAudience != nil && *params.ClientAssertionAudience != "" { + return "", apierrors.NewBadRequestError( + apierrors.ErrorCodeValidationFailed, + "client_assertion_audience is only supported with client_auth_method 'private_key_jwt'", + ) + } + // required on create and when switching from private_key_jwt + hasSecret := existing != nil && existing.ClientAuthMethod == models.ClientAuthMethodClientSecret + if !hasSecret && params.ClientSecret == "" { + return "", apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "client_secret is required") + } + + case models.ClientAuthMethodPrivateKeyJWT: + if params.ClientSecret != "" { + return "", apierrors.NewBadRequestError( + apierrors.ErrorCodeValidationFailed, + "client_secret must not be set when client_auth_method is 'private_key_jwt'", + ) + } + if providerType != models.ProviderTypeOIDC { + return "", apierrors.NewBadRequestError( + apierrors.ErrorCodeValidationFailed, + "client_auth_method 'private_key_jwt' is only supported for OIDC providers", + ) + } + if params.ClientAssertionAudience != nil && len(*params.ClientAssertionAudience) > 2048 { + return "", apierrors.NewBadRequestError( + apierrors.ErrorCodeValidationFailed, + "client_assertion_audience must be at most 2048 characters", + ) + } + } + + return method, nil +} + +// applyClientAuthParams sets the client auth method on provider and clears the +// fields of the other method. The client secret itself is set by the caller. +func applyClientAuthParams(provider *models.CustomOAuthProvider, params *AdminCustomOAuthProviderParams, method models.ClientAuthMethod) { + provider.ClientAuthMethod = method + + switch method { + case models.ClientAuthMethodClientSecret: + provider.ClientAssertionAudience = nil + + case models.ClientAuthMethodPrivateKeyJWT: + provider.ClientSecret = "" + if params.ClientAssertionAudience != nil { + if audience := *params.ClientAssertionAudience; audience != "" { + provider.ClientAssertionAudience = &audience + } else { + provider.ClientAssertionAudience = nil + } + } + } +} + // validateProviderURLs validates URLs with SSRF protection func validateProviderURLs(params *AdminCustomOAuthProviderParams, providerType models.ProviderType) error { var urls []string @@ -687,6 +798,10 @@ func validateAuthorizationParams(params map[string]interface{}) error { return nil } +// fetchOIDCDiscovery is a variable so tests can create OIDC providers without +// network access. +var fetchOIDCDiscovery = fetchAndValidateDiscovery + // fetchAndValidateDiscovery fetches the OIDC discovery document via the shared // utility, then applies admin-only validation: required fields per the OpenID // Connect Discovery 1.0 spec must be present before we persist the document. diff --git a/internal/api/custom_oauth_admin_client_auth_test.go b/internal/api/custom_oauth_admin_client_auth_test.go new file mode 100644 index 0000000000..37f6e64b17 --- /dev/null +++ b/internal/api/custom_oauth_admin_client_auth_test.go @@ -0,0 +1,292 @@ +package api + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "strings" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/supabase/auth/internal/api/apierrors" + "github.com/supabase/auth/internal/models" +) + +// enableClientAssertions turns the experimental flag on with a signing key +// configured. The key itself is never used by the admin API. +func (ts *CustomOAuthAdminTestSuite) enableClientAssertions() { + ts.Config.Experimental.ClientAssertion.Enabled = true + ts.Config.Experimental.ClientAssertion.SigningKey = func(context.Context) (any, error) { + return nil, nil + } +} + +// stubOIDCDiscovery lets OIDC providers be created without network access. +func (ts *CustomOAuthAdminTestSuite) stubOIDCDiscovery() { + original := fetchOIDCDiscovery + fetchOIDCDiscovery = func(_ context.Context, _ string, issuer string) (*models.OIDCDiscovery, error) { + return &models.OIDCDiscovery{ + Issuer: issuer, + AuthorizationEndpoint: issuer + "/authorize", + TokenEndpoint: issuer + "/token", + JwksURI: issuer + "/jwks", + }, nil + } + ts.T().Cleanup(func() { fetchOIDCDiscovery = original }) +} + +func (ts *CustomOAuthAdminTestSuite) adminRequest(method, path string, payload any) *httptest.ResponseRecorder { + var body bytes.Buffer + if payload != nil { + require.NoError(ts.T(), json.NewEncoder(&body).Encode(payload)) + } + req := httptest.NewRequest(method, path, &body) + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", ts.token)) + w := httptest.NewRecorder() + ts.API.handler.ServeHTTP(w, req) + return w +} + +func (ts *CustomOAuthAdminTestSuite) requireBadRequest(w *httptest.ResponseRecorder, msg string) { + require.Equal(ts.T(), http.StatusBadRequest, w.Code, w.Body.String()) + var apiErr apierrors.HTTPError + require.NoError(ts.T(), json.NewDecoder(w.Body).Decode(&apiErr)) + assert.Equal(ts.T(), apierrors.ErrorCodeValidationFailed, apiErr.ErrorCode) + assert.Contains(ts.T(), apiErr.Message, msg) +} + +func privateKeyJWTPayload(identifier string) map[string]any { + return map[string]any{ + "provider_type": "oidc", + "identifier": identifier, + "name": "Private Key JWT Provider", + "client_id": "test-client-id", + "issuer": "https://example.com", + "client_auth_method": "private_key_jwt", + } +} + +func (ts *CustomOAuthAdminTestSuite) findProvider(identifier string) *models.CustomOAuthProvider { + provider, err := models.FindCustomOAuthProviderByIdentifier(ts.API.db, identifier) + require.NoError(ts.T(), err) + return provider +} + +// decodeRaw decodes a JSON response into a map so the test can check which +// keys are present. +func decodeRaw(ts *CustomOAuthAdminTestSuite, w *httptest.ResponseRecorder) map[string]any { + var raw map[string]any + require.NoError(ts.T(), json.NewDecoder(w.Body).Decode(&raw)) + return raw +} + +func (ts *CustomOAuthAdminTestSuite) TestClientAuthFlagOff() { + ts.stubOIDCDiscovery() + + ts.Run("create with private_key_jwt", func() { + w := ts.adminRequest(http.MethodPost, "/admin/custom-providers", privateKeyJWTPayload("custom:pkjwt-flag-off")) + ts.requireBadRequest(w, "private_key_jwt client authentication is not enabled") + }) + + ts.Run("create with client_assertion_audience", func() { + payload := ts.createTestOAuth2Payload("custom:audience-flag-off") + payload["client_assertion_audience"] = "https://example.com" + w := ts.adminRequest(http.MethodPost, "/admin/custom-providers", payload) + ts.requireBadRequest(w, "private_key_jwt client authentication is not enabled") + }) + + ts.Run("switch an existing provider to private_key_jwt", func() { + provider := ts.createOIDCProviderInDB("switch-flag-off", "https://switch-flag-off.example.com") + w := ts.adminRequest(http.MethodPut, "/admin/custom-providers/"+provider.Identifier, map[string]any{ + "client_auth_method": "private_key_jwt", + }) + ts.requireBadRequest(w, "private_key_jwt client authentication is not enabled") + assert.Equal(ts.T(), models.ClientAuthMethodClientSecret, ts.findProvider(provider.Identifier).ClientAuthMethod) + }) + + ts.Run("flag on without a signing key", func() { + ts.Config.Experimental.ClientAssertion.Enabled = true + defer func() { ts.Config.Experimental.ClientAssertion.Enabled = false }() + + w := ts.adminRequest(http.MethodPost, "/admin/custom-providers", privateKeyJWTPayload("custom:pkjwt-no-key")) + ts.requireBadRequest(w, "private_key_jwt client authentication is not enabled") + }) + + ts.Run("client_secret providers still work", func() { + w := ts.adminRequest(http.MethodPost, "/admin/custom-providers", ts.createTestOAuth2Payload("custom:secret-flag-off")) + require.Equal(ts.T(), http.StatusCreated, w.Code, w.Body.String()) + assert.Equal(ts.T(), "client_secret", decodeRaw(ts, w)["client_auth_method"]) + }) +} + +func (ts *CustomOAuthAdminTestSuite) TestClientAuthCreateValidation() { + ts.enableClientAssertions() + ts.stubOIDCDiscovery() + + withSecret := privateKeyJWTPayload("custom:pkjwt-with-secret") + withSecret["client_secret"] = "test-client-secret" + + oauth2 := ts.createTestOAuth2Payload("custom:pkjwt-oauth2") + delete(oauth2, "client_secret") + oauth2["client_auth_method"] = "private_key_jwt" + + unknownMethod := ts.createTestOAuth2Payload("custom:unknown-method") + unknownMethod["client_auth_method"] = "client_secret_jwt" + + missingSecret := ts.createTestOAuth2Payload("custom:missing-secret") + delete(missingSecret, "client_secret") + + secretWithAudience := ts.createTestOAuth2Payload("custom:secret-with-audience") + secretWithAudience["client_assertion_audience"] = "https://example.com" + + longAudience := privateKeyJWTPayload("custom:long-audience") + longAudience["client_assertion_audience"] = "https://issuer.example.com/" + strings.Repeat("a", 2048) + + cases := []struct { + name string + payload map[string]any + msg string + }{ + {"private_key_jwt with a client secret", withSecret, "client_secret must not be set"}, + {"private_key_jwt on an OAuth2 provider", oauth2, "only supported for OIDC providers"}, + {"unknown client_auth_method", unknownMethod, "client_auth_method must be either"}, + {"client_secret without a secret", missingSecret, "client_secret is required"}, + {"client_secret with an audience", secretWithAudience, "client_assertion_audience is only supported"}, + {"audience over 2048 characters", longAudience, "at most 2048 characters"}, + } + for _, tc := range cases { + ts.Run(tc.name, func() { + w := ts.adminRequest(http.MethodPost, "/admin/custom-providers", tc.payload) + ts.requireBadRequest(w, tc.msg) + }) + } + + count, err := models.CountCustomOAuthProviders(ts.API.db) + require.NoError(ts.T(), err) + assert.Equal(ts.T(), 0, count) +} + +func (ts *CustomOAuthAdminTestSuite) TestClientAuthCreatePrivateKeyJWT() { + ts.enableClientAssertions() + ts.stubOIDCDiscovery() + + payload := privateKeyJWTPayload("custom:pkjwt") + payload["client_assertion_audience"] = "https://example.com/token" + w := ts.adminRequest(http.MethodPost, "/admin/custom-providers", payload) + require.Equal(ts.T(), http.StatusCreated, w.Code, w.Body.String()) + + raw := decodeRaw(ts, w) + assert.Equal(ts.T(), "private_key_jwt", raw["client_auth_method"]) + assert.Equal(ts.T(), "https://example.com/token", raw["client_assertion_audience"]) + assert.NotContains(ts.T(), raw, "client_secret") + + // no secret is stored, not even an encrypted empty string + stored := ts.findProvider("custom:pkjwt") + assert.Equal(ts.T(), models.ClientAuthMethodPrivateKeyJWT, stored.ClientAuthMethod) + assert.Empty(ts.T(), stored.ClientSecret) + + // get and list return the method and audience, never the secret + for _, path := range []string{"/admin/custom-providers/custom:pkjwt", "/admin/custom-providers"} { + w := ts.adminRequest(http.MethodGet, path, nil) + require.Equal(ts.T(), http.StatusOK, w.Code) + assert.Contains(ts.T(), w.Body.String(), `"client_auth_method":"private_key_jwt"`) + assert.Contains(ts.T(), w.Body.String(), `"client_assertion_audience":"https://example.com/token"`) + assert.NotContains(ts.T(), w.Body.String(), "client_secret") + } +} + +func (ts *CustomOAuthAdminTestSuite) TestClientAuthSwitchMethod() { + ts.enableClientAssertions() + provider := ts.createOIDCProviderInDB("switch-method", "https://switch-method.example.com") + path := "/admin/custom-providers/" + provider.Identifier + + // client_secret -> private_key_jwt clears the secret + w := ts.adminRequest(http.MethodPut, path, map[string]any{ + "client_auth_method": "private_key_jwt", + "client_assertion_audience": "https://switch-method.example.com/token", + }) + require.Equal(ts.T(), http.StatusOK, w.Code, w.Body.String()) + stored := ts.findProvider(provider.Identifier) + assert.Equal(ts.T(), models.ClientAuthMethodPrivateKeyJWT, stored.ClientAuthMethod) + assert.Empty(ts.T(), stored.ClientSecret) + require.NotNil(ts.T(), stored.ClientAssertionAudience) + assert.Equal(ts.T(), "https://switch-method.example.com/token", *stored.ClientAssertionAudience) + + // a secret can't be added while the method stays private_key_jwt + w = ts.adminRequest(http.MethodPut, path, map[string]any{"client_secret": "new-secret"}) + ts.requireBadRequest(w, "client_secret must not be set") + + // an empty audience clears the override + w = ts.adminRequest(http.MethodPut, path, map[string]any{"client_assertion_audience": ""}) + require.Equal(ts.T(), http.StatusOK, w.Code, w.Body.String()) + assert.Nil(ts.T(), ts.findProvider(provider.Identifier).ClientAssertionAudience) + + // private_key_jwt -> client_secret requires a secret + w = ts.adminRequest(http.MethodPut, path, map[string]any{"client_auth_method": "client_secret"}) + ts.requireBadRequest(w, "client_secret is required") + + w = ts.adminRequest(http.MethodPut, path, map[string]any{ + "client_auth_method": "private_key_jwt", + "client_assertion_audience": "https://switch-method.example.com/token", + }) + require.Equal(ts.T(), http.StatusOK, w.Code, w.Body.String()) + + w = ts.adminRequest(http.MethodPut, path, map[string]any{ + "client_auth_method": "client_secret", + "client_secret": "new-secret", + }) + require.Equal(ts.T(), http.StatusOK, w.Code, w.Body.String()) + + stored = ts.findProvider(provider.Identifier) + assert.Equal(ts.T(), models.ClientAuthMethodClientSecret, stored.ClientAuthMethod) + assert.Nil(ts.T(), stored.ClientAssertionAudience, "switching to client_secret clears the audience") + secret, err := stored.GetClientSecret(ts.Config.Security.DBEncryption) + require.NoError(ts.T(), err) + assert.Equal(ts.T(), "new-secret", secret) + + // updating a client_secret provider without a secret keeps the old one + w = ts.adminRequest(http.MethodPut, path, map[string]any{"name": "Renamed"}) + require.Equal(ts.T(), http.StatusOK, w.Code, w.Body.String()) + secret, err = ts.findProvider(provider.Identifier).GetClientSecret(ts.Config.Security.DBEncryption) + require.NoError(ts.T(), err) + assert.Equal(ts.T(), "new-secret", secret) +} + +func (ts *CustomOAuthAdminTestSuite) TestClientAuthSwitchOAuth2ToPrivateKeyJWT() { + ts.enableClientAssertions() + w := ts.adminRequest(http.MethodPost, "/admin/custom-providers", ts.createTestOAuth2Payload("custom:oauth2-switch")) + require.Equal(ts.T(), http.StatusCreated, w.Code, w.Body.String()) + + w = ts.adminRequest(http.MethodPut, "/admin/custom-providers/custom:oauth2-switch", map[string]any{ + "client_auth_method": "private_key_jwt", + }) + ts.requireBadRequest(w, "only supported for OIDC providers") +} + +func (ts *CustomOAuthAdminTestSuite) TestClientAuthExistingPrivateKeyJWTProviderWithFlagOff() { + ts.enableClientAssertions() + provider := ts.createOIDCProviderInDB("pkjwt-later-flag-off", "https://pkjwt-later-flag-off.example.com") + path := "/admin/custom-providers/" + provider.Identifier + w := ts.adminRequest(http.MethodPut, path, map[string]any{"client_auth_method": "private_key_jwt"}) + require.Equal(ts.T(), http.StatusOK, w.Code, w.Body.String()) + + ts.Config.Experimental.ClientAssertion.Enabled = false + + // unrelated updates still work + w = ts.adminRequest(http.MethodPut, path, map[string]any{"name": "Renamed"}) + require.Equal(ts.T(), http.StatusOK, w.Code, w.Body.String()) + + // but nothing can (re)set private_key_jwt fields + w = ts.adminRequest(http.MethodPut, path, map[string]any{"client_assertion_audience": "https://other.example.com"}) + ts.requireBadRequest(w, "private_key_jwt client authentication is not enabled") + + // switching back to client_secret is allowed + w = ts.adminRequest(http.MethodPut, path, map[string]any{ + "client_auth_method": "client_secret", + "client_secret": "new-secret", + }) + require.Equal(ts.T(), http.StatusOK, w.Code, w.Body.String()) +} diff --git a/internal/api/custom_oauth_admin_test.go b/internal/api/custom_oauth_admin_test.go index b4219d4947..c5486c6744 100644 --- a/internal/api/custom_oauth_admin_test.go +++ b/internal/api/custom_oauth_admin_test.go @@ -58,6 +58,7 @@ func (ts *CustomOAuthAdminTestSuite) SetupTest() { ts.Config.CustomOAuth.Enabled = true ts.Config.CustomOAuth.MaxProviders = 10 ts.Config.Security.DBEncryption.Encrypt = true + ts.Config.Experimental.ClientAssertion = conf.ClientAssertionConfiguration{} // Generate admin token claims := &AccessTokenClaims{ diff --git a/openapi.yaml b/openapi.yaml index 5851d4bc25..210300b30d 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -2642,7 +2642,6 @@ paths: - identifier - name - client_id - - client_secret properties: provider_type: type: string @@ -2664,7 +2663,21 @@ paths: description: OAuth client ID from the provider client_secret: type: string - description: OAuth client secret (will be encrypted at rest) + description: OAuth client secret (will be encrypted at rest). Required when client_auth_method is 'client_secret', and must not be set when it is 'private_key_jwt'. + client_auth_method: + type: string + enum: + - client_secret + - private_key_jwt + default: client_secret + description: > + How the server authenticates to the provider's token endpoint. 'private_key_jwt' sends a signed + client assertion (RFC 7523) instead of a client secret. It is currently only available for OIDC providers, + and only when client assertions are enabled on the server; otherwise the request is rejected with 400. + client_assertion_audience: + type: string + maxLength: 2048 + description: Overrides the aud claim of client assertions, which defaults to the provider's issuer. Only allowed with client_auth_method 'private_key_jwt'. acceptable_client_ids: type: array items: @@ -2901,7 +2914,20 @@ paths: description: OAuth client ID client_secret: type: string - description: OAuth client secret (only provide if changing, will be encrypted) + description: OAuth client secret (only provide if changing, will be encrypted). Required when switching client_auth_method to 'client_secret', and must not be set for 'private_key_jwt' providers. + client_auth_method: + type: string + enum: + - client_secret + - private_key_jwt + description: > + How the server authenticates to the provider's token endpoint. Switching to 'private_key_jwt' clears + the stored client secret, and switching to 'client_secret' clears client_assertion_audience. + 'private_key_jwt' is currently only available for OIDC providers, and only when client assertions are enabled on the server. + client_assertion_audience: + type: string + maxLength: 2048 + description: Overrides the aud claim of client assertions. An empty string clears the override. Only allowed for 'private_key_jwt' providers. acceptable_client_ids: type: array items: @@ -4165,6 +4191,15 @@ components: client_id: type: string description: OAuth client ID + client_auth_method: + type: string + enum: + - client_secret + - private_key_jwt + description: How the server authenticates to the provider's token endpoint. The client secret itself is never returned. + client_assertion_audience: + type: string + description: Override for the aud claim of client assertions. Omitted when not set. acceptable_client_ids: type: array items: