feat: use *SecretVar for OAuth2Config credentials to preserve env./vault. - #4859
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughOAuth client credentials now use ChangesOAuth SecretVar propagation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant OAuthHandler
participant OAuthConfig
participant DynamicRegistration
participant AuthorizationURL
OAuthHandler->>OAuthConfig: pass ClientID and ClientSecret as SecretVar
OAuthConfig->>DynamicRegistration: retain credential wrappers
DynamicRegistration->>AuthorizationURL: resolve ClientID with GetValue()
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
|
8f4139b to
e152314
Compare
8f6a141 to
7e47d10
Compare
7e47d10 to
d464c76
Compare
e152314 to
23cf80b
Compare
23cf80b to
6b43b40
Compare
d464c76 to
3c02b32
Compare
oauth_configs to new mcp_oauth_flows table
#5709
d0b3779 to
d035f30
Compare
f04d622 to
a5c418f
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
d035f30 to
ed3cfbc
Compare
Merge activity
|
The base branch was changed.
…Auth2Config.ClientID's SecretVar migration
ed3cfbc to
00abc37
Compare

Summary
OAuth2Config.ClientIDandClientSecretwere plainstringfields, which meant env-variable and vault references (e.g.env.MY_VAR) were silently flattened to literal strings before being stored or compared. This PR changes both fields to*SecretVar, so reference metadata is preserved end-to-end: from config parsing through storage, change detection, OAuth flow initiation, and redaction.Changes
OAuth2Config.ClientIDandClientSecretchanged fromstringto*SecretVar, enabling env./vault. references to be carried intact rather than resolved prematurely.InitiateOAuthFlowno longer wraps credentials in a newSecretVarat the point of use; the*SecretVarfrom the config is passed through directly, and dynamically registered credentials are wrapped once at registration time.pendingOAuthConfigToRequestno longer manually unpacksSecretVarvalues into plain strings and re-wraps them — credentials now pass through as-is.mcpOauthBlockChangedcompares credentials by resolved value (GetValue()), so an env. reference that resolves to the same credential as the stored value is not treated as a config drift.RedactMCPClientConfignow callsRedacted()directly on the*SecretVarfields instead of routing through an intermediateSecretVarconstruction, and no longer mutates the live stash.TestOAuth2ConfigSecretVarCredentialscovering bare-string JSON backward compatibility, marshal round-trip reference preservation, and redaction isolation.Type of change
Affected areas
How to test
go test ./core/schemas/... ./framework/oauth2/... ./transports/bifrost-http/...Verify that:
OAuth2Configwithclient_id: "env.MY_VAR"resolves to the environment variable value at use time, not at parse time.MCPClientConfigwith aPendingOAuthConfigdoes not modify the original struct's credential values.Breaking changes
OAuth2Config.ClientIDandClientSecretare now*SecretVarinstead ofstring. Any code that directly reads or assigns these fields as plain strings must be updated to useGetValue()for reading andNewSecretVar(...)ornilfor assignment. Existing JSON blobs with bare string credentials remain backward-compatible viaSecretVar's JSON unmarshalling.Security considerations
Credentials stored as env./vault. references are no longer resolved to their plaintext values before being persisted or compared. Resolved values are only materialized at the point of use (e.g. when building the authorize URL), reducing the surface area where plaintext secrets appear in memory or logs. Redaction now operates directly on
SecretVar, ensuring the live config stash is never mutated by a redaction call.Checklist
docs/contributing/README.mdand followed the guidelines