Repository navigation
feat: custom oauth providers - #43094
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
7 Skipped Deployments
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Repository UI (inherited), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds 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 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
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. Comment |
🎭 Playwright Test ResultsDetails
Skipped testsFeatures › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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
📒 Files selected for processing (13)
apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsxapps/studio/components/interfaces/Auth/CustomAuthProviders/CustomAuthProvidersList.tsxapps/studio/components/interfaces/Auth/CustomAuthProviders/DeleteCustomProviderModal.tsxapps/studio/components/interfaces/Auth/CustomAuthProviders/customProviders.utils.tsapps/studio/components/interfaces/Auth/CustomAuthProviders/index.tsxapps/studio/data/oauth-custom-providers/keys.tsapps/studio/data/oauth-custom-providers/oauth-custom-provider-create-mutation.tsapps/studio/data/oauth-custom-providers/oauth-custom-provider-delete-mutation.tsapps/studio/data/oauth-custom-providers/oauth-custom-provider-update-mutation.tsapps/studio/data/oauth-custom-providers/oauth-custom-providers-query.tsapps/studio/pages/project/[ref]/auth/providers.tsxpackages/common/enabled-features/enabled-features.jsonpackages/common/enabled-features/enabled-features.schema.json
| }: CreateOrUpdateCustomProviderSheetProps) => { | ||
| const isEditMode = !!providerToEdit | ||
| const { ref: projectRef } = useParams() | ||
| const { data: endpointData } = useProjectApiUrl({ projectRef }) |
There was a problem hiding this comment.
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.
| 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, | ||
| }) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (2)
apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx (2)
195-208:⚠️ Potential issue | 🟠 MajorEdit mode still ignores
client_secret.The form keeps
client_secreteditable, but the update payload never sends it. Any change to that field is a silent no-op. Either include a non-empty secret inupdateCustomProvider(...)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 | 🟠 MajorUse
hostEndpointfor the mutation client.
endpointDatais the resolved/custom-domain URL, but the providers list is keyed byhostEndpoint. 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
📒 Files selected for processing (1)
apps/studio/components/interfaces/Auth/CustomAuthProviders/CreateOrUpdateCustomProviderSheet.tsx
| const { data: endpointData } = useProjectApiUrl({ projectRef }) | ||
| const form = useForm<z.infer<typeof FormSchema>>({ |
There was a problem hiding this comment.
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).
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Ivan Vasilov <[email protected]> Co-authored-by: Ali Waseem <[email protected]>
No description provided.