[type:fix] forward configured sign app parameter - #7199
Open
dengliming wants to merge 1 commit into
Open
dengliming wants to merge 1 commit into
dengliming wants to merge 1 commit into
Conversation
Aias00
approved these changes
Sep 24, 2026
Aias00
left a comment
Contributor
There was a problem hiding this comment.
Good fix — the original line was a no-op by construction.
exchange.getRequest().mutate().headers(...).build() builds a new request and discards it; the result was never assigned back to the exchange, so the appParam header never reached downstream plugins. Moving the value into exchange.getAttributes() and materialising the header on a properly mutated exchange in SignPlugin actually forwards it.
What I checked:
- Both execution paths in
SignPlugin#doExecuteare covered: the no-body path viachain.execute(addAppParamHeader(exchange)), and the body-rewrite path via.map(this::addAppParamHeader)beforeflatMap(chain::execute). Easy to miss one; both are there. ObjectUtilsis already imported inSignPlugin(Spring's, already used for the rule-handler null check), soObjectUtils.isEmpty(appParam)compiles and handles the blank-string case.Constants.APP_PARAMis used consistently as both the attribute key and the header name, andaddAppParamHeaderreturns the exchange unchanged when the attribute is absent — so plugins that never set it see no behaviour change.- Tests cover both sides: the service stores the attribute, and the plugin converts it into a request header on the exchange handed to the chain.
Non-blocking: storing an app parameter in a request header means it will be propagated to the upstream service. That looks intentional here (it's the point of the feature), but it's worth confirming this is desired for all deployments, since header injection is visible to backends.
This branch has not been deployed
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.
Fixes #6634.\n\nStore the verified app parameter on the exchange and have SignPlugin build the request carrying the APP_PARAM header before invoking the downstream chain. This covers both regular and request-body signing paths.\n\nTests:
./mvnw -q -pl shenyu-plugin/shenyu-plugin-security/shenyu-plugin-sign -am -DskipTests=false -Dcheckstyle.skip=false -Dtest=SignPluginTest,SignServiceVersionTwoTest -DfailIfNoTests=false test