-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(system): ENTESB-19674 set Referrer-Policy to no-referrer by default
Now by default Hawtio sets the following HTTP header: Referrer-Policy: no-referrer Optionally, you can customise the header by setting the following system property: hawtio.http.referrerPolicy=...
- Loading branch information
Showing
6 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
37 changes: 37 additions & 0 deletions
37
hawtio-system/src/main/java/io/hawt/web/filters/ReferrerPolicyFilter.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.hawt.web.filters; | ||
|
||
import javax.servlet.FilterConfig; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy | ||
*/ | ||
public class ReferrerPolicyFilter extends HttpHeaderFilter { | ||
|
||
private static final transient Logger LOG = LoggerFactory.getLogger(ReferrerPolicyFilter.class); | ||
|
||
public static final String REFERRER_POLICY = "http.referrerPolicy"; | ||
public static final String HAWTIO_REFERRER_POLICY = "hawtio." + REFERRER_POLICY; | ||
|
||
private String headerValue = "no-referrer"; | ||
|
||
@Override | ||
public void init(FilterConfig filterConfig) throws ServletException { | ||
super.init(filterConfig); | ||
String policy = getConfigParameter(REFERRER_POLICY); | ||
if (policy != null) { | ||
headerValue = policy; | ||
} | ||
LOG.debug("Referrer-Policy is configured: {}", headerValue); | ||
} | ||
|
||
@Override | ||
protected void addHeaders(HttpServletRequest request, HttpServletResponse response) { | ||
response.addHeader("Referrer-Policy", headerValue); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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