feat(auth): protect HttpApi endpoints with OAuth scope requirements #271
All Vouch review confidence checks passed
Residual risk 0.52 = Change Risk (0.71) × (1 − Review Confidence (0.27)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.71 · 496 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 48% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.371
Shallow Review Depth
shallow_review_depth
0.344
Sensitive Paths
sensitive_paths
0.071
Real PR Conversation Timeline
1 comments
"Review active on #271"
general
weight: 0.35
github-actions[bot]
oauth.middleware(scopes)protects HttpRouter routes such as MCP, but anHttpApishared with browser clients cannot declare the scopes its groups and endpoints need. Its generated clients see untyped 401 and 403 responses, and consent or scope pages cannot read scope descriptions from the API.OAuthScopegains browser-safe declarations, and the authorization server gainssecurityLayer(api):OAuthScope.Requiredannotates a group or endpoint with{ allOf },{ anyOf }, or both. Entries are branded scopes or{ name, description }. An endpoint's requirement replaces its group's, and{ allOf: [] }accepts any valid access.OAuthScope.RequireAccessis bearer security middleware. Generated clients need no implementation and decode failures asHttpApiError.Unauthorized,Forbidden, andServiceUnavailable.OAuthScope.catalog(api)lists described scopes in declaration order.oauth.securityLayer(api)implementsRequireAccesswith the verification deadline, failure reporting,WWW-Authenticatechallenges, andCurrentAccessofoauth.middleware. It fails withConfigurationErrorwhen a protected endpoint has no valid requirement, an annotated endpoint lacks the middleware (for example.middlewarebefore a later.add), a requirement names an undeclared scope, or theHttpApiitself is annotated.oauth.middlewareresponses are unchanged; both paths now share the verification classification and challenge builder. 503 stays a raw no-store response because its cause is already reported, and failing withHttpApiError.ServiceUnavailablewould report it again through the HttpApi builder. Challenges advertise theallOfscopes and the firstanyOfscope.Out of scope: a Layer for resource servers that verify tokens with
makeAccessTokenVerifier.<!-- codesmith:footer -->
---
<a href="https://app.blacksmith.sh/yielded-dev/codesmith/auth/pr/271?autoLogin=true&ref=codesmith_pr_footer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v3.svg"><img alt="View with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png" width="162" height="28"></picture></a> <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1795525378&installation_model_id=440452&pr_number=271&ref=codesmith_pr_footer&repository=yielded-dev%2Fauth&return_to=https%3A%2F%2Fgithub.com%2Fyielded-dev%2Fauth%2Fpull%2F271&signature=605a128bbb57c367f45c35953a0ddee4f2dc9058e7d5286a49a054380c306a3a"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png" width="190" height="28"></picture></a>
<sup>Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup>
<!-- codesmith:autofix:disabled -->
<!-- /codesmith:footer -->