feat(auth): add --redirect-uri + --token-endpoint-auth-method to register-client#894
Open
panda850819 wants to merge 1 commit into
Open
Conversation
…o register-client
`gbrain auth register-client` previously hard-coded `redirect_uris = []` and
`token_endpoint_auth_method = NULL` when persisting the client. That made the
CLI unusable for the most common case it's recommended for: pre-registering
Claude.ai / ChatGPT custom connectors so SECURITY.md's "don't enable open DCR"
guidance can actually be followed.
The failure mode:
1. Operator follows SECURITY.md "If you must use a custom HTTP wrapper",
drops --enable-dcr, runs `gbrain auth register-client claude-ai ...`.
2. Pastes client_id/secret into Claude.ai → /authorize returns
`invalid_request: Unregistered redirect_uri`.
3. ChatGPT additionally needs token_endpoint_auth_method=none for its
PKCE-only flow.
4. Operator has to `UPDATE oauth_clients SET redirect_uris=ARRAY[...],
token_endpoint_auth_method=...` by hand against the live DB.
New flags:
--redirect-uri <uri> (repeatable)
--token-endpoint-auth-method <method> (client_secret_post | none)
Auth-method values are validated against ALLOWED_TOKEN_ENDPOINT_AUTH_METHODS,
which mirrors what `mcpAuthRouter` advertises in
token_endpoint_auth_methods_supported. Unknown values fail loud at registration
instead of silently producing an unauthorizable client.
Tests cover: redirect_uris persistence, auth-method persistence (`none`),
default fallback to client_secret_post, and rejection of unsupported methods.
Worked example (now possible without UPDATE):
gbrain auth register-client claude-ai \
--grant-types authorization_code,refresh_token \
--scopes "read write" \
--redirect-uri https://claude.ai/api/mcp/auth_callback \
--redirect-uri https://claude.com/api/mcp/auth_callback
gbrain auth register-client chatgpt \
--grant-types authorization_code,refresh_token \
--scopes "read write" \
--redirect-uri https://chatgpt.com/connector/oauth/<HASH> \
--token-endpoint-auth-method none
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
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
gbrain auth register-clientpreviously hard-codedredirect_uris = []andtoken_endpoint_auth_method = NULL, which made the CLI unusable for the caseSECURITY.mditself recommends it for — pre-registering Claude.ai / ChatGPT custom connectors so operators can run with--enable-dcroff.New flags:
--redirect-uri <uri>(repeatable; required forauthorization_codeclients)--token-endpoint-auth-method <method>(client_secret_post|none; ChatGPT custom connectors usenone)Auth-method values are validated against a new
ALLOWED_TOKEN_ENDPOINT_AUTH_METHODSset that mirrors what the MCP SDK'smcpAuthRouteradvertises intoken_endpoint_auth_methods_supported. Unknown values fail loud at registration.The failure mode this fixes
Before this PR, the SECURITY.md-recommended hardening path falls apart at step 2:
--enable-dcr, runsgbrain auth register-client claude-ai --grant-types authorization_code,refresh_token --scopes "read write"./authorizereturns{\"error\":\"invalid_request\",\"error_description\":\"Unregistered redirect_uri\"}.oauth_clientsby hand to add the callback URLs, and again fortoken_endpoint_auth_method = 'none'to make ChatGPT's PKCE-only flow work.Worked example after this PR
```bash
gbrain auth register-client claude-ai \
--grant-types authorization_code,refresh_token \
--scopes "read write" \
--redirect-uri https://claude.ai/api/mcp/auth_callback \
--redirect-uri https://claude.com/api/mcp/auth_callback
gbrain auth register-client chatgpt \
--grant-types authorization_code,refresh_token \
--scopes "read write" \
--redirect-uri https://chatgpt.com/connector/oauth/ \
--token-endpoint-auth-method none
```
Test plan
Notes
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmithwith what you need.