feat(oauth)!: default STRICT_REDIRECT_URIS to true#198
Merged
Conversation
- Enforce loopback-or-HTTPS redirect URIs by default per OAuth 2.1 and MCP - Update configuration and MCP docs to reflect the new default and opt-out BREAKING CHANGE: STRICT_REDIRECT_URIS now defaults to true. Clients with plain-http redirect URIs to non-loopback hosts are rejected on next create or update (including Dynamic Client Registration). Set STRICT_REDIRECT_URIS=false to restore the previous permissive behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens AuthGate’s default OAuth client registration behavior by enabling strict redirect URI validation by default, aligning out-of-the-box settings with OAuth 2.1 §1.5 / MCP guidance (loopback or HTTPS redirect URIs only).
Changes:
- Flip
STRICT_REDIRECT_URISdefault fromfalsetotrueininternal/config/config.go. - Update MCP deployment guidance to reflect the new default and document the opt-out (
STRICT_REDIRECT_URIS=false). - Update the configuration reference example to show the new default and clarify behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/config/config.go | Changes the default for StrictRedirectURIs to true when loading config from env. |
| docs/MCP.md | Updates MCP-ready checklist text to reflect strict redirect enforcement now being default-on and documents opt-out. |
| docs/CONFIGURATION.md | Updates the sample env var value/comment to reflect the new default and clarify opt-out. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
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.
Summary
Flips
STRICT_REDIRECT_URISto defaulttrue, so AuthGate enforces OAuth 2.1 §1.5 / MCP redirect-URI rules (loopback or HTTPS only) out of the box. Plain-http://redirect URIs to non-loopback hosts are now rejected on client create/update unless an operator explicitly opts out.AI Authorship
internal/config/config.go,docs/CONFIGURATION.md,docs/MCP.mdChange classification
The code change itself is a one-line default flip, but it alters a security-relevant default that affects every client registration path (admin UI + Dynamic Client Registration).
Plan reference
No formal plan. Goal: close the gap noted while auditing AuthGate against the MCP authorization spec (2025-11-25) — OAuth 2.1 §1.5 requires redirect URIs to be loopback or HTTPS, but AuthGate previously defaulted this enforcement off.
Verification
go test ./internal/config/✓)TestCreateClient_StrictRedirectURIsalready covers the rejection path (sets the flag explicitly via builder).STRICT_REDIRECT_URISis on and that creating a client withhttp://example.com/cb(non-loopback) is rejected, whilehttp://127.0.0.1/cbandhttps://...are accepted.Risk & rollback
http://non-loopback redirect URIs will be rejected the next time they are created or updated (including via DCR). Pre-existing clients keep working until next edited.STRICT_REDIRECT_URIS=false, or revert this commit.Security check
Reviewer guide
internal/config/config.go(the two default flips at lines ~335 and ~594) — confirm the intent is to ship a stricter default.docs/CONFIGURATION.md,docs/MCP.md(wording only).🤖 Generated with Claude Code