Repository navigation
fix(authz): decode the request body once in the resource middleware - #13014
Merged
Merged
Conversation
gjson and encoding/json disagree on duplicate and case-variant keys, so extractors and handlers could act on different values. The middleware now decodes into the route's declared request type and both read that value.
Routes whose extractors read path params or the response keep their body untouched, so handlers that accept more than the declared shape still work.
…options Rendering the decode error in the resource middleware skipped the audit middleware, so malformed requests were never logged. The error now rides on the resolved resources and authz renders it inside audit. Routes can declare bind options once, and the single decode honours them.
|
vikrantgupta25
marked this pull request as ready for review
September 29, 2026 19:04
therealpandey
approved these changes
Sep 29, 2026
pull Bot
pushed a commit
to TheTechOddBug/signoz
that referenced
this pull request
Sep 30, 2026
…est (SigNoz#13015) #### Description - Follows SigNoz#13014. Moves the remaining body-derived resource ids (gateway limits, zeus hosts, cloud integration check-ins, auth domains, query range) off gjson and onto the decoded request, with the handlers reading the same value. Part of SigNoz/keystone-pod#37. - Removes `BodyJSONPath`, `BodyJSONArray`, and `ExtractorContext.RequestBody`. #### Issues closed by this PR - Closes: SigNoz/keystone-pod#37
pull Bot
pushed a commit
to itsrbpandit/signoz
that referenced
this pull request
Sep 30, 2026
…ware (SigNoz#13024) #### Description - Reverts SigNoz#13014 and SigNoz#13015. The resource middleware goes back to reading body-derived resource ids with `BodyJSONPath` / `BodyJSONArray` over the raw body, and handlers decode their own request bodies again. - Authz should not own request decoding; that ownership stays with the handlers. #### Additional Information - Contributes to: SigNoz/keystone-pod#37
ahrefabhi
pushed a commit
that referenced
this pull request
Oct 13, 2026
…13014) #### Description - The resource middleware now decodes the body once into the route's declared `OpenAPIDef.Request` type, rejects a malformed body before any check, and carries the decoded value on `ExtractorContext.Body`. `BodyField` / `BodyFields` read ids off that value, and handlers read the same value via `coretypes.BodyFromContext`. - `handler.Handler` exposes `Request()`, and `handler.New` panics when a route with resource defs declares a non-pointer request, since the middleware instantiates it. - Only `POST /api/v1/service_account_roles` is wired to the new extractors in this PR to keep the review small. The remaining body routes still use the gjson extractors and decode again in their handlers. #### Issues closed by this PR - Contributes to: SigNoz/keystone-pod#37
ahrefabhi
pushed a commit
that referenced
this pull request
Oct 13, 2026
…est (#13015) #### Description - Follows #13014. Moves the remaining body-derived resource ids (gateway limits, zeus hosts, cloud integration check-ins, auth domains, query range) off gjson and onto the decoded request, with the handlers reading the same value. Part of SigNoz/keystone-pod#37. - Removes `BodyJSONPath`, `BodyJSONArray`, and `ExtractorContext.RequestBody`. #### Issues closed by this PR - Closes: SigNoz/keystone-pod#37
ahrefabhi
pushed a commit
that referenced
this pull request
Oct 13, 2026
…ware (#13024) #### Description - Reverts #13014 and #13015. The resource middleware goes back to reading body-derived resource ids with `BodyJSONPath` / `BodyJSONArray` over the raw body, and handlers decode their own request bodies again. - Authz should not own request decoding; that ownership stays with the handlers. #### Additional Information - Contributes to: SigNoz/keystone-pod#37
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.
Description
OpenAPIDef.Requesttype, rejects a malformed body before any check, and carries the decoded value onExtractorContext.Body.BodyField/BodyFieldsread ids off that value, and handlers read the same value viacoretypes.BodyFromContext.handler.HandlerexposesRequest(), andhandler.Newpanics when a route with resource defs declares a non-pointer request, since the middleware instantiates it.POST /api/v1/service_account_rolesis wired to the new extractors in this PR to keep the review small. The remaining body routes still use the gjson extractors and decode again in their handlers.Issues closed by this PR