Repository navigation
Fix Jetty security headers handler chain #2676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a2713c7
c24d5f9
de4976b
09d9001
5d9769f
20db61c
63283a8
8017b48
27eda0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,8 +21,9 @@ | |
| <Configure class="org.eclipse.jetty.server.handler.ContextHandlerCollection" id="Contexts"> | ||
|
|
||
| <!-- Rewrite Handler for Security Headers --> | ||
| <Call name="addHandler"> | ||
| <Arg> | ||
| <Ref refid="Server"> | ||
| <Call name="insertHandler"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving the But it means the CSP (line 68) is now actually sent, which has a side effect. That policy sets The console still has three of them:
When the Could you move these three handlers to external JS, the same way |
||
| <Arg> | ||
| <New class="org.eclipse.jetty.rewrite.handler.RewriteHandler"> | ||
| <Call name="addRule"> | ||
| <Arg> | ||
|
|
@@ -128,8 +129,9 @@ | |
| </Call> | ||
| --> | ||
| </New> | ||
| </Arg> | ||
| </Call> | ||
| </Arg> | ||
| </Call> | ||
| </Ref> | ||
|
|
||
| <!-- Admin Web Application --> | ||
| <Call name="addHandler"> | ||
|
|
@@ -201,4 +203,4 @@ | |
| </Arg> | ||
| </Call> | ||
|
|
||
| </Configure> | ||
| </Configure> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This request never actually authenticates. The test resource have no JAAS configuration: there's no
login.config, and neitherjava.security.auth.login.confignoractivemq.confis set.JAASLoginServicecan't load theactivemqlogin module, so this request gets a 401, just like the one above.The assertion still passes because the
RewriteHandlernow runs before theSecurityHandler, which putsX-Frame-Optionson the 401 too. So the authenticated path is not covered. The test would stay green even if headers were dropped from 200 responses.I suggest the following changes:
login.configwith aactivemqentry that usesPropertiesLoginModule, plususers.propertiesandgroups.propertiesthat putadmininadmins(the role/admin/*requires). Pointjava.security.auth.login.configat it, either through surefiresystemPropertyVariablesor from the test itself.index.html, so a 200 is expected):try { ... } finally { context.close(); }. If this assertion fails,context.stop()is skipped and Jetty stays running into the next test. Even when it isn't skipped,stop()does't callJettyServerBean.destroy(). Onlyclose()does.Nit:
java.util.Base64is written out in full inline, whileStandardCharsetsgets an import.