Repository navigation
WW-3717 feat(core): restrict an action to HTTP methods with an http-method attribute - #2038
Merged
Merged
Conversation
…ethod attribute Adds an optional http-method attribute to <action> in the 7.5 DTD, enforced by HttpMethodInterceptor together with the existing @HttpGet/@HttpPost/@AllowedHttpMethod annotations; when both apply the request must satisfy both. Wildcard and regex actions keep the restriction, and an invalid method name fails configuration loading. A rejected request still gets the bad-request result when the action maps one; otherwise the interceptor now answers 405 with an Allow header instead of failing with "No result defined". A warning is logged for an action that declares http-method but whose interceptors do not include httpMethod. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ocation does
Before answering 405 the interceptor now also accepts a catch-all "*"
result and a result supplied by an unknown handler (e.g. the Convention
plugin's {action}-bad-request page), so existing annotation users keep
their page. Adds a test where the annotation narrows the configured
methods.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
lukaszlenart
marked this pull request as ready for review
October 16, 2026 14:47
… is rejected Injecting UnknownHandlerManager into HttpMethodInterceptor built the unknown handlers while the interceptor was created during configuration loading, before ConventionUnknownHandler could find its parent package, which broke every Convention plugin application at startup. Resolve the manager from the request's container only on the reject path instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Makes ActionConfig.httpMethods private, narrows rejectRequest to throw IOException, simplifies the end of equals, and tidies two tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
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 WW-3717
Summary
http-methodattribute on<action>instruts-7.5.dtd, e.g.http-method="post"orhttp-method="get,post"(case-insensitive). An unknown method name fails configuration loading.HttpMethodInterceptor, which now reads the action config as well as the existing@HttpGet/@HttpPost/@AllowedHttpMethod… annotations. When both apply, the request must satisfy both.ActionConfigMatcher).bad-requestresult when one can be resolved — exact name, a catch-all*result, or an unknown handler such as the Convention plugin. Otherwise the interceptor answers 405 with anAllowheader and returnsNONE, instead of failing with "No result defined".http-methodwhile its interceptors do not includehttpMethod.One action name still maps to one config; routing the same name to different configs per method is WW-5785 (8.0.0). Convention-plugin coverage via the annotations is verified in WW-5786.
Behaviour changes worth a migration note
bad-requestresult now get 405 +Allowinstead of a 500. Request methods outsideHttpMethod(e.g.PROPFIND) on restricted actions now get 405 instead of anIllegalArgumentException.HttpMethodInterceptorthroughMockActionProxymust give it anActionConfig, since the config is read on every request (and the rejection path needs a container on theActionContext, which the test base classes already set). This is deliberately not null-guarded.testWildcardResolvedExecuteRejectsGetThroughRealProxynow asserts 405 +Allow: POST: its fixture maps nobad-requestresult.Test plan
XmlConfigurationProviderHttpMethodTest(parsing, list/case handling, wildcard carry-over, invalid value, startup warning) and newHttpMethodInterceptorTestcases (config only, annotation only, both, mapped / global / catch-all / unknown-handler results, 405 +Allow, unknown request method) — each watched failing before the implementation./mvnw test -DskipAssembly -pl core— 3510 tests, 0 failures./mvnw install -DskipAssembly -DskipITs(full reactor, final commit) — 4850 tests, 0 failures, including the Convention plugin tests that caught an eagerUnknownHandlerManagerinjection on the first push (fixed in ced991c: the manager is now looked up from the request's container only when a request is rejected)Docs: struts-site PR follows (new "HTTP Methods" section in Action Configuration).
🤖 Generated with Claude Code