-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed dismiss cookie to localstorage and added headers roda 5 (#3272)
Signed-off-by: carlosjepard <[email protected]> Signed-off-by: Miguel Guimarães <[email protected]>
- Loading branch information
1 parent
45fa6a7
commit 680ce5f
Showing
6 changed files
with
103 additions
and
27 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
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
38 changes: 38 additions & 0 deletions
38
roda-ui/roda-wui/src/main/java/org/roda/wui/filter/SecurityHeadersFilter.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,38 @@ | ||
package org.roda.wui.filter; | ||
|
||
import jakarta.servlet.*; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
|
||
public class SecurityHeadersFilter implements Filter { | ||
|
||
@Override | ||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) | ||
throws IOException, ServletException { | ||
HttpServletResponse httpServletResponse = (HttpServletResponse) response; | ||
|
||
httpServletResponse.setHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains"); | ||
httpServletResponse.setHeader("Content-Security-Policy", | ||
"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com " + | ||
"https://www.google-analytics.com https://www.gstatic.com; style-src 'self' 'unsafe-inline'; " + | ||
"img-src 'self'; font-src 'self';"); | ||
httpServletResponse.setHeader("X-XSS-Protection", "1; mode=block"); | ||
httpServletResponse.setHeader("X-Permitted-Cross-Domain-Policies", "none"); | ||
httpServletResponse.setHeader("Feature-Policy", "camera 'none'; fullscreen 'self'; geolocation *; " + | ||
"microphone 'self'"); | ||
httpServletResponse.setHeader("X-Frame-Options", "SAMEORIGIN"); | ||
httpServletResponse.setHeader("X-Content-Type-Options", "nosniff"); | ||
httpServletResponse.setHeader("Referrer-Policy", "no-referrer"); | ||
httpServletResponse.setHeader("Permissions-Policy", "geolocation=(self)"); | ||
|
||
chain.doFilter(request, response); | ||
} | ||
|
||
@Override | ||
public void init(FilterConfig filterConfig) { | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Context> | ||
|
||
<!-- Add SameSite to the cookies --> | ||
<CookieProcessor | ||
sameSiteCookies="strict" /> | ||
|
||
</Context> |
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