Skip to content

feat: support client_auth_method on gotrue_custom_oauth_provider - #9

Merged
cemalkilic merged 2 commits into
mainfrom
feat/custom-provider-client-auth-method
Nov 18, 2026
Merged

cemalkilic merged 2 commits into
mainfrom
feat/custom-provider-client-auth-method

Conversation

@cemalkilic

Copy link
Copy Markdown
Collaborator

What

Adds support for the new custom provider admin API params from supabase/auth#2935:

  • client_auth_method: client_secret (default) or private_key_jwt
  • client_assertion_audience: overrides the aud claim of client assertions (max 2048 chars)

client_secret is now optional.

Behaviour

  • Plan-time validation (CustomizeDiff) mirrors the server rules, so mistakes fail at plan instead of as a 400 at apply:

    • client_secret is required for client_secret and must not be set for private_key_jwt
    • private_key_jwt is only allowed for oidc providers
    • client_assertion_audience is only allowed with private_key_jwt

    Values unknown until apply are left for the server to check.

  • Older auth servers keep working: the default method is not sent on create, and a response without client_auth_method is read as client_secret.

  • Audience is only sent for private_key_jwt providers. The server clears it on a switch to client_secret, and rejects any audience (even "") while client assertions are disabled. Sending it would break switching back after the flag is turned off. Removing the audience on a private_key_jwt provider sends "", which clears it.

Tests

gotrue/custom_oauth_provider_test.go covers each validation rule, the request bodies for create and update (switching methods both ways, changing and removing the audience), and reading from a server that doesn't return the method.

Follow-up

supabase-community/pulumi-gotrue will be bumped to the tag cut from this PR.

Add client_auth_method ("client_secret" or "private_key_jwt") and
client_assertion_audience to the custom OAuth provider resource, matching
the custom provider admin API (supabase/auth#2935).

- client_secret is now optional. A CustomizeDiff check enforces the
  server's rules at plan time: a secret is required for client_secret and
  forbidden for private_key_jwt, private_key_jwt is OIDC-only, and an
  audience is only allowed with private_key_jwt.
- The default method is not sent on create, and a missing method in
  responses is read as client_secret, so older auth servers keep working.
- The audience is only sent for private_key_jwt providers. The server
  clears it when switching to client_secret and rejects any audience
  while client assertions are disabled.
@fadymak

fadymak commented Nov 18, 2026

Copy link
Copy Markdown

@claude review

- When client_auth_method changes to client_secret, always send
  client_secret. The server never returns the secret, so state can still
  hold the configured value and show no change after the method was
  switched outside Terraform, which made the server reject the update.
- Don't send client_auth_method when the old state has no value and the
  new one is the default. State from earlier provider versions has no
  method, and older servers may not know the field.
@cemalkilic
cemalkilic merged commit ad8b0ec into main Nov 18, 2026
1 check passed
@cemalkilic
cemalkilic deleted the feat/custom-provider-client-auth-method branch November 18, 2026 11:11
cemalkilic added a commit to supabase-community/pulumi-gotrue that referenced this pull request Nov 18, 2026
## What

Picks up the new custom provider admin API params from
supabase/auth#2935, via supabase-community/terraform-provider-gotrue#9:

- `clientAuthMethod`: `client_secret` (default) or `private_key_jwt`
- `clientAssertionAudience`: overrides the `aud` claim of client
assertions

`clientSecret` is now optional.

Schema and Go, Node.js, Python and .NET SDKs are regenerated. Only the
`CustomOauthProvider` files changed.

Bumps `terraform-provider-gotrue` to `v1.1.4`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants