Skip to content

feat(auth): delete a custom OAuth/OIDC provider as an admin - #581

Merged
Tr00d merged 1 commit into
masterfrom
feat/auth.admin.delete_provider
Oct 29, 2026
Merged

Tr00d merged 1 commit into
masterfrom
feat/auth.admin.delete_provider

Conversation

@Tr00d

@Tr00d Tr00d commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Admins can delete a custom OAuth/OIDC provider by its identifier.

Capability: auth.admin.delete_provider — Admin Delete Provider.

Public API

// IGotrueAdminClient<TUser>
Task DeleteCustomProviderAsync(string identifier, CancellationToken cancellationToken = default);

// FailureHint.Reason
CustomProviderNotFound
var admin = new AdminClient(serviceRoleKey, new ClientOptions { Url = authUrl });
await admin.DeleteCustomProviderAsync("custom:mycompany");

IGotrueApi<TUser, TSession> gains the matching DeleteCustomProviderAsync(string jwt, string identifier, CancellationToken).

Behavior

Operation DELETE /admin/custom-providers/{identifier} with the service-role key
Input identifier, required, starting with custom:
Output 204, no content; the method returns nothing
Checks before the request ArgumentNullException for null; ArgumentException when the identifier lacks the case-sensitive custom: prefix (pre-empts 400 validation_failed) or contains /, \, ?, # or %
Failures GotrueException: Reason = CustomProviderNotFound on 404 custom_provider_not_found; Reason = AdminTokenRequired on 403 not_admin; ErrorCode = feature_disabled on 404 when custom providers are disabled

The identifier is a path segment, and System.Uri resolves dot segments: without the character check, custom:x/../../users/<id> becomes DELETE /admin/users/<id>. Encoding does not help, because the auth server matches the raw path and rejects custom%3A…. The check rejects only route-changing characters, not the stricter OpenAPI pattern ^custom:[a-zA-Z0-9_-]+$: the server only enforces the prefix, so a stricter check could block deleting a provider it accepted.

Deviations from supabase-js

supabase-js interpolates the identifier into the URL without encoding or validation. This SDK rejects identifiers that would change the route before sending anything.

Tests

Tier Class Pins
E2E AdminCustomProviderTests Deleting a seeded provider removes it; unknown identifier → CustomProviderNotFound; non-admin key → AdminTokenRequired
Contract AdminCustomProviderContractTests Route and service-role credentials; a cancelled token sends nothing
Contract FailureHintTests custom_provider_not_found → CustomProviderNotFound
Unit AdminCustomProviderIdentifierTests Null, missing prefix and route-changing identifiers rejected before the request

Changed-line coverage: 100% (13 lines). Mutation: 11/11 killed on changed lines, 0 survivors.

No wire-shape approval snapshot: the request has no body.

Notes

  • Custom providers are enabled by default on the auth server (GOTRUE_CUSTOM_OAUTH_ENABLED defaults to true), so the local stack needs no configuration. The E2E tests seed providers with example.com URLs because the server resolves provider hostnames on create.
  • The OpenAPI spec does not list 404 feature_disabled, and its identifier pattern is stricter than the server's prefix-only check.

@Tr00d
Tr00d marked this pull request as ready for review October 29, 2026 09:35
@Tr00d
Tr00d merged commit 37f7322 into master Oct 29, 2026
3 checks passed
@Tr00d
Tr00d deleted the feat/auth.admin.delete_provider branch October 29, 2026 09:35
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.

1 participant