Skip to content

feat: custom oauth providers - #43094

Merged
ivasilov merged 30 commits into
masterfrom
feat/custom-oauth-providers
Mar 16, 2026
Merged

ivasilov merged 30 commits into
masterfrom
feat/custom-oauth-providers

Conversation

@fsansalvadore

Copy link
Copy Markdown
Contributor

No description provided.

@vercel

vercel Bot commented Feb 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment Mar 16, 2026 2:30pm
studio-staging Ready Ready Preview, Comment Mar 16, 2026 2:30pm
7 Skipped Deployments
Project Deployment Actions Updated (UTC)
cms Ignored Ignored Mar 16, 2026 2:30pm
studio Ignored Ignored Mar 16, 2026 2:30pm
design-system Skipped Skipped Mar 16, 2026 2:30pm
docs Skipped Skipped Mar 16, 2026 2:30pm
learn Skipped Skipped Mar 16, 2026 2:30pm
ui-library Skipped Skipped Mar 16, 2026 2:30pm
zone-www-dot-com Skipped Skipped Mar 16, 2026 2:30pm

Request Review

@supabase

supabase Bot commented Feb 23, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Feb 23, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 80ab5039-12f2-4313-9ae6-78139c3cec51

📥 Commits

Reviewing files that changed from the base of the PR and between ec5578f and 2ba8786.

📒 Files selected for processing (1)
  • apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Full custom OAuth/OIDC provider management UI: create, edit, delete with OIDC auto-discovery or manual OAuth2.
    • Provider list with search, filters, sorting, limits, per-provider actions, and status badges.
    • Create/edit form shows read-only callback URL, discard-changes confirmation, success toasts, and loading/error states.
  • Chores

    • Enabled feature flag to display Custom Providers and added schema entry.

Walkthrough

Adds a custom OAuth providers feature: UI components to list, create, update, and delete providers (CustomAuthProviders, CustomAuthProvidersList, CreateOrUpdateCustomProviderSheet, DeleteCustomProviderModal); data layer hooks and functions for listing, creating, updating, and deleting providers; a query key helper; filtering and plan-logic utilities; and a new feature flag authentication:show_custom_providers. Components validate input, use React Query for caching/invalidation, and integrate project/client endpoint context.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as "Studio UI\n(Create/Update Sheet)"
  participant Hook as "useOAuthCustomProviderCreate/Update\n(mutation)"
  participant Admin as "Supabase Admin API\n(admin.customProviders)"
  participant Cache as "React Query Cache\n(oAuthCustomProvidersKeys)"

  User->>UI: open sheet, submit form
  UI->>Hook: call mutate(payload + projectRef + clientEndpoint)
  Hook->>Admin: admin.customProviders.createProvider/updateProvider(payload)
  Admin-->>Hook: 200 OK / provider data
  Hook->>Cache: invalidate ['projects', projectRef, 'oauth-custom-providers', clientEndpoint]
  Cache-->>UI: refetch list (useOAuthCustomProvidersQuery)
  UI-->>User: show success toast and close sheet
Loading

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Feb 23, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  157 passed
skipped  4 skipped

Details

stats  161 tests across 20 suites
duration  4 minutes, 59 seconds
commit  07a6128

Skipped tests

Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@blacksmith-sh

This comment has been minimized.

@ivasilov
ivasilov marked this pull request as ready for review March 5, 2026 16:57
@ivasilov
ivasilov requested a review from a team as a code owner March 5, 2026 16:57

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx`:
- Around line 195-207: The update payload built in
CreateOrUpdateCustomProviderSheet when calling updateCustomProvider omits
client_secret, so edits that change client_secret are ignored; include
client_secret in the object sent to updateCustomProvider by taking it from the
form values (e.g., values.client_secret) or from the existing payload when
present, ensuring you only include it when non-empty to avoid unintentionally
clearing secrets; update the call site that constructs the payload for
updateCustomProvider to merge client_secret alongside client_id, issuer, scopes,
etc., and ensure the same fix is applied to the other similar call site that
builds the update payload.
- Line 113: The component CreateOrUpdateCustomProviderSheet currently passes the
resolved endpointData from useProjectApiUrl into the create/update mutation
calls, but the provider list cache (useOAuthCustomProvidersQuery) is keyed by
hostEndpoint; replace usages of endpointData passed as the mutation's
clientEndpoint with the hostEndpoint value returned from useProjectApiUrl so the
mutation invalidates the correct cache key (ensure the mutation calls in
CreateOrUpdateCustomProviderSheet that currently use endpointData instead use
hostEndpoint), referencing useProjectApiUrl and useOAuthCustomProvidersQuery
(oauth-custom-providers-query.ts) to ensure consistency.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 92472976-b2e5-4dc9-9652-b76bae892cfc

📥 Commits

Reviewing files that changed from the base of the PR and between 4f7d4a3 and 33d1b4c.

📒 Files selected for processing (13)
  • apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx
  • apps/studio/components/interfaces/Auth/CustomAuthProviders/CustomAuthProvidersList.tsx
  • apps/studio/components/interfaces/Auth/CustomAuthProviders/DeleteCustomProviderModal.tsx
  • apps/studio/components/interfaces/Auth/CustomAuthProviders/customProviders.utils.ts
  • apps/studio/components/interfaces/Auth/CustomAuthProviders/index.tsx
  • apps/studio/data/oauth-custom-providers/keys.ts
  • apps/studio/data/oauth-custom-providers/oauth-custom-provider-create-mutation.ts
  • apps/studio/data/oauth-custom-providers/oauth-custom-provider-delete-mutation.ts
  • apps/studio/data/oauth-custom-providers/oauth-custom-provider-update-mutation.ts
  • apps/studio/data/oauth-custom-providers/oauth-custom-providers-query.ts
  • apps/studio/pages/project/[ref]/auth/providers.tsx
  • packages/common/enabled-features/enabled-features.json
  • packages/common/enabled-features/enabled-features.schema.json

}: CreateOrUpdateCustomProviderSheetProps) => {
const isEditMode = !!providerToEdit
const { ref: projectRef } = useParams()
const { data: endpointData } = useProjectApiUrl({ projectRef })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use hostEndpoint for mutation clientEndpoint to avoid stale list after create/update.

Line 113 reads data (resolved endpoint), but useOAuthCustomProvidersQuery keys the list by hostEndpoint (apps/studio/data/oauth-custom-providers/oauth-custom-providers-query.ts:53-56). Passing endpointData at Lines 198 and 212 can invalidate a different cache key on custom-domain projects, so the table may not refresh after save.

Proposed fix
-  const { data: endpointData } = useProjectApiUrl({ projectRef })
+  const { data: endpointData, hostEndpoint: clientEndpoint } = useProjectApiUrl({ projectRef })
...
-        clientEndpoint: endpointData,
+        clientEndpoint,
...
-        clientEndpoint: endpointData,
+        clientEndpoint,

Also applies to: 195-213

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx`
at line 113, The component CreateOrUpdateCustomProviderSheet currently passes
the resolved endpointData from useProjectApiUrl into the create/update mutation
calls, but the provider list cache (useOAuthCustomProvidersQuery) is keyed by
hostEndpoint; replace usages of endpointData passed as the mutation's
clientEndpoint with the hostEndpoint value returned from useProjectApiUrl so the
mutation invalidates the correct cache key (ensure the mutation calls in
CreateOrUpdateCustomProviderSheet that currently use endpointData instead use
hostEndpoint), referencing useProjectApiUrl and useOAuthCustomProvidersQuery
(oauth-custom-providers-query.ts) to ensure consistency.

Comment on lines +195 to +207
updateCustomProvider({
identifier,
projectRef,
clientEndpoint: endpointData,
name: values.name,
client_id: values.client_id,
scopes: values.scopes.split(',').map((s) => s.trim()),
issuer: values.issuer,
pkce_enabled: true,
enabled: true,
email_optional: values.email_optional,
...payload,
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Edit mode allows changing client secret, but update payload drops it.

Line 453 keeps client_secret editable during edit, but the update payload (Lines 195-207) never sends client_secret. That creates a silent no-op and misleading update behavior.

Proposed fix (minimum safe behavior)
-                      <Input_Shadcn_ {...field} type="password" placeholder="Client secret" />
+                      <Input_Shadcn_
+                        {...field}
+                        type="password"
+                        placeholder="Client secret"
+                        disabled={isEditMode}
+                      />

Also applies to: 447-454

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx`
around lines 195 - 207, The update payload built in
CreateOrUpdateCustomProviderSheet when calling updateCustomProvider omits
client_secret, so edits that change client_secret are ignored; include
client_secret in the object sent to updateCustomProvider by taking it from the
form values (e.g., values.client_secret) or from the existing payload when
present, ensuring you only include it when non-empty to avoid unintentionally
clearing secrets; update the call site that constructs the payload for
updateCustomProvider to merge client_secret alongside client_id, issuer, scopes,
etc., and ensure the same fix is applied to the other similar call site that
builds the update payload.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx (2)

195-208: ⚠️ Potential issue | 🟠 Major

Edit mode still ignores client_secret.

The form keeps client_secret editable, but the update payload never sends it. Any change to that field is a silent no-op. Either include a non-empty secret in updateCustomProvider(...) or disable the field in edit mode.

Also applies to: 455-462

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx`
around lines 195 - 208, The edit flow currently ignores changes to the
client_secret because updateCustomProvider is called without passing
client_secret; update the payload in the isEditMode branch to include
client_secret when values.client_secret is non-empty (e.g., add client_secret:
values.client_secret) or alternatively disable the client_secret input in edit
mode so users cannot edit a secret that won't be sent; locate the isEditMode
conditional and the updateCustomProvider(...) call in
CreateOrUpdateCustomProviderSheet (and the equivalent block at the other
occurrence) and either add client_secret to the object or make the form field
readOnly/disabled when isEditMode is true.

114-115: ⚠️ Potential issue | 🟠 Major

Use hostEndpoint for the mutation client.

endpointData is the resolved/custom-domain URL, but the providers list is keyed by hostEndpoint. On custom-domain projects, create/update can invalidate a different cache key and leave the list stale after save.

Also applies to: 196-213

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx`
around lines 114 - 115, The mutation is using endpointData (custom/resolved
domain) but the providers cache is keyed by hostEndpoint, so updates on
custom-domain projects invalidate the wrong key and leave the list stale; in
CreateOrUpdateCustomProviderSheet replace uses of endpointData when building the
mutation client with the hostEndpoint value (e.g., read hostEndpoint from
useProjectApiUrl's response or project context) so the mutation targets the same
key as the providers list and invalidates the correct cache; update both the
create/update mutation setup around where endpointData is used and the
save/response handlers referenced later (lines ~196-213) to ensure the cache
invalidation uses hostEndpoint.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx`:
- Around line 114-115: The endpoint query (useProjectApiUrl -> endpointData) can
be undefined while loading, causing mutations and the callback preview to throw
or render invalid URLs; update the CreateOrUpdateCustomProviderSheet to gate
rendering and submission on a loaded endpoint by checking that endpointData (or
endpointData.value) is truthy before: (1) enabling the submit action/primary
button, (2) invoking mutation helpers that require clientEndpoint, and (3)
rendering the callback preview string; add a loading/disabled state and a safe
fallback UI until endpointData exists so mutations only run when a valid
clientEndpoint is available (apply same guard around the other occurrences
noted: the blocks around lines 172-225 and 507-513).

---

Duplicate comments:
In
`@apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx`:
- Around line 195-208: The edit flow currently ignores changes to the
client_secret because updateCustomProvider is called without passing
client_secret; update the payload in the isEditMode branch to include
client_secret when values.client_secret is non-empty (e.g., add client_secret:
values.client_secret) or alternatively disable the client_secret input in edit
mode so users cannot edit a secret that won't be sent; locate the isEditMode
conditional and the updateCustomProvider(...) call in
CreateOrUpdateCustomProviderSheet (and the equivalent block at the other
occurrence) and either add client_secret to the object or make the form field
readOnly/disabled when isEditMode is true.
- Around line 114-115: The mutation is using endpointData (custom/resolved
domain) but the providers cache is keyed by hostEndpoint, so updates on
custom-domain projects invalidate the wrong key and leave the list stale; in
CreateOrUpdateCustomProviderSheet replace uses of endpointData when building the
mutation client with the hostEndpoint value (e.g., read hostEndpoint from
useProjectApiUrl's response or project context) so the mutation targets the same
key as the providers list and invalidates the correct cache; update both the
create/update mutation setup around where endpointData is used and the
save/response handlers referenced later (lines ~196-213) to ensure the cache
invalidation uses hostEndpoint.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 766e894e-2998-49a5-a39e-1af3e9856e4f

📥 Commits

Reviewing files that changed from the base of the PR and between 33d1b4c and ec5578f.

📒 Files selected for processing (1)
  • apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx

Comment on lines +114 to +115
const { data: endpointData } = useProjectApiUrl({ projectRef })
const form = useForm<z.infer<typeof FormSchema>>({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Block submit until the project endpoint has loaded.

useProjectApiUrl().data is undefined while the endpoint query is pending. Both mutation helpers throw when clientEndpoint is missing, and the callback preview renders undefined/auth/v1/callback meanwhile. Gate submit/render on a loaded endpoint.

Also applies to: 172-225, 507-513

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx`
around lines 114 - 115, The endpoint query (useProjectApiUrl -> endpointData)
can be undefined while loading, causing mutations and the callback preview to
throw or render invalid URLs; update the CreateOrUpdateCustomProviderSheet to
gate rendering and submission on a loaded endpoint by checking that endpointData
(or endpointData.value) is truthy before: (1) enabling the submit action/primary
button, (2) invoking mutation helpers that require clientEndpoint, and (3)
rendering the callback preview string; add a loading/disabled state and a safe
fallback UI until endpointData exists so mutations only run when a valid
clientEndpoint is available (apply same guard around the other occurrences
noted: the blocks around lines 172-225 and 507-513).

@blacksmith-sh

This comment has been minimized.

@ivasilov
ivasilov merged commit b69a145 into master Mar 16, 2026
25 checks passed
@ivasilov
ivasilov deleted the feat/custom-oauth-providers branch March 16, 2026 16:13
stylessh pushed a commit that referenced this pull request Mar 23, 2026
Co-authored-by: Ivan Vasilov <[email protected]>
Co-authored-by: Ali Waseem <[email protected]>
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.

3 participants