-
Notifications
You must be signed in to change notification settings - Fork 328
feat: handle oauth-protected-resource for edge functions #4604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Rodriguespn
wants to merge
4
commits into
develop
Choose a base branch
from
feat/supabase-public-url
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+25
−1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pull Request Test Coverage Report for Build 20369862521Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
sweatybridge
previously approved these changes
Dec 19, 2025
Add SUPABASE_PUBLIC_URL environment variable that contains the external-facing URL (e.g., http://127.0.0.1:54321) for use in client-facing responses. This is needed for OAuth-protected Edge Functions (like MCP servers) that need to return public URLs in OAuth metadata and WWW-Authenticate headers, while still using the internal Docker URL (SUPABASE_URL) for server-to-server calls. In production, SUPABASE_PUBLIC_URL won't exist, so Edge Functions should fall back to SUPABASE_URL which is already the public URL. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
…rect The previous implementation appended /.well-known/oauth-protected-resource to the entire remaining path, causing requests like /.well-known/oauth-protected-resource/functions/v1/func-name/mcp to fail. Now correctly extracts just the function name and ignores sub-paths. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
The OAuth protected resource redirect feature doesn't require SUPABASE_PUBLIC_URL. Edge Functions can handle URL resolution themselves using custom env vars like PUBLIC_URL if needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
ddae315 to
74ef3f6
Compare
decided to go with www-authenticate header instead
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Feature - Enables local development and testing of OAuth-protected Edge Functions (like MCP servers).
What is the current behavior?
When building OAuth-protected Edge Functions locally, there's no way for OAuth clients to discover the authorization server for a protected Edge Function resource via the standard
/.well-known/oauth-protected-resourcepath.Per RFC 9728, OAuth clients should be able to discover the authorization server by fetching:
This wasn't possible for Edge Functions running locally.
What is the new behavior?
OAuth Protected Resource Metadata Endpoint
Added a Kong route that redirects OAuth protected resource discovery requests to the appropriate Edge Function:
This enables OAuth clients to discover the authorization server for any Edge Function per RFC 9728.
Example Edge Function implementation:
Edge Functions can use custom environment variables (
PUBLIC_URL,AUTH_SERVER_URL) passed viasupabase functions serve --env-fileto override URLs for local development.Testing
Related issue: https://linear.app/supabase/issue/AI-311/add-oauth-authentication-section-to-byom-one-pager-docs
Should close #4322 @cemalkilic