feat(middleware): forward product on M2M auth (flag-gated)#123
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughChangesThe auth middleware now reads M2M Product Forwarding
Sequence Diagram(s)sequenceDiagram
participant GRPCInterceptor
participant AuthClient
participant AuthService
GRPCInterceptor->>AuthClient: resolve product and authorize
AuthClient->>AuthService: send request with conditional product
AuthService-->>AuthClient: return authorization result
AuthClient-->>GRPCInterceptor: return result
GRPCInterceptor->>AuthClient: build telemetry payload
AuthClient-->>GRPCInterceptor: include product only when forwarded
Possibly related PRs
✨ Finishing Touches✨ Simplify code
Comment |
M2M (application-token) authorization calls sent no product, so once Custom permission resources are prefixed with "{product}/" (Item 17 F2), a bare M2M request stops matching the stored resource and the auth service denies it (403).
Forward the route product for application tokens too, gated by AUTH_M2M_PRODUCT_FORWARD_ENABLED (default off) so deploy != release: prefix isolation activates by flipping the flag, with no consumer code change. Normal-user behavior is unchanged. A shared shouldForwardProduct helper keeps the request body and telemetry payload in lockstep.
X-Lerian-Ref: 0x1
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e6227e8 to
93c44db
Compare
|
🎉 This PR is included in version 3.0.0-beta.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 3.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
What
Adds
AuthClient.ForwardM2MProduct(read once fromAUTH_M2M_PRODUCT_FORWARD_ENABLED, default off). When enabled, M2M (application-token) authorization calls forward the routeproduct— the same field already forwarded for normal-user flows.Why
This is the last piece of Item 17 Fase 2 (resource-prefix). Once Custom permission
resourcesare prefixed with{product}/(seed + migration 43, already ondevelopofplugin-access-manager), the enforce side dual-matches a bare request only whenproductis present so it can strip the prefix. The M2M path forwarded no product, so a bare M2M request (e.g.plugin-fees → midaz) stops matching the now-prefixed stored resource and the auth service denies it (403). Forwardingproductfor application tokens closes that gap.Isolation is preserved: on the M2M path
productis not the authorization gate (the governing m2m-permission is) — it only scopes the resource-prefix strip, which the access-manager already gates viapermissionBelongsToProduct.Design
AUTH_M2M_PRODUCT_FORWARD_ENABLED=trueper environment (staging first). Rollback = flip the flag, not a code revert.productat the call site; lib-auth was dropping it forapplication. A dependency bump + env flag is all that's needed.shouldForwardProducthelper keeps the request body (checkAuthorization) and the telemetry payload (authPayload) in lockstep.Rollout order
AUTH_M2M_PRODUCT_FORWARD_ENABLED=trueper env, staging first.Tests
checkAuthorization(M2M flag on forwards / flag on + empty product omits),authPayloadgating (flag on/off/empty), gRPC unary interceptor end-to-end with flag on, andNewAuthClientenv parsing.gofmtclean ·go build ./...·go test ./...green ·golangci-lint0 issues.🤖 Generated with Claude Code