probo
probo copied to clipboard
Add OAuth 2 scopes
Add explicit read/write scope pairs for each product API resource so OAuth clients can request granular access. Validation and implied-scope helpers live next to the existing standard OAuth2 scopes.
Summary by cubic
Add granular OAuth2 API scopes with read/write pairs and enforce them for bearer‑token requests using a static scope-to-action map. Discovery lists all scopes on both the authorization server and the protected resource, and consent shows API scopes.
Coredata +88 -107
- Aliased scope types/constants to
pkg/oauth2; addedImpliedScopesand getters that delegate topkg/oauth2. - Removed legacy validation/codec; now accepts API scopes via the new package.
Service +478 -10
- Introduced
pkg/oauth2with standard + v1 API scope constants, helpers (IsStandardScope,IsAPIScope,IsReadScope,BaseScope,ImpliedScopes), and token-scope context helpers. - Authorizer enforces token scopes before IAM policy via an injected gate; returns
ErrInsufficientOAuth2Scopeon denial. - AS metadata now uses
AllOAuth2ScopesSupported()and includesprotected_resources; added RFC 9728 protected-resource metadata builder.
GraphQL API +576 -6
- Injected
OAuth2ScopeGrantsActioninto the Authorizer; middleware attaches token scopes to request context. - Added static scope→IAM action map in
authzfor enforcement; unmapped actions deny OAuth requests. - Mapped
ErrInsufficientOAuth2Scopeto forbidden in GraphQL and files API. - Exposed
/.well-known/oauth-protected-resource.
MCP +8 -0
- Return “insufficient scope” on
ErrInsufficientOAuth2Scope.
App: console +15 -5
- Consent shows a key icon and raw names for API scopes; keeps translations for OIDC scopes.
Agents +24 -0
- Documented scope format, discovery endpoints, consent behavior, and enforcement flow; noted discovery-only write scopes until actions exist.
Tests +535 -36
- E2E: protected-resource metadata, scoped client registration, and GraphQL enforcement with bearer tokens.
- Added factory and testutil helpers for scoped auth code flow and bearer GraphQL.
- Unit tests for Authorizer scope gate, metadata, protected resource, and scope→action mapping.
Written for commit 5ae487857850f1adce01f269818b996650c34a40. Summary will update on new commits.