-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use csp headers for swagger resources
- Loading branch information
1 parent
45e051e
commit 9649314
Showing
2 changed files
with
30 additions
and
3 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
20 changes: 20 additions & 0 deletions
20
backend/src/main/java/com/wire/bots/roman/filters/CspResponseFilter.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,20 @@ | ||
package com.wire.bots.roman.filters; | ||
|
||
import javax.ws.rs.container.ContainerRequestContext; | ||
import javax.ws.rs.container.ContainerResponseContext; | ||
import javax.ws.rs.container.ContainerResponseFilter; | ||
|
||
public class CspResponseFilter implements ContainerResponseFilter { | ||
|
||
@Override | ||
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) { | ||
// this is going to be | ||
// swagger.json, swagger-static, swagger-ui and all other assets | ||
if (requestContext.getUriInfo().getPath().contains("swagger")) { | ||
responseContext.getHeaders().add("Content-Security-Policy", | ||
"default-src 'self'; connect-src 'self'; media-src data:; img-src 'self' data:; " + | ||
"style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline';"); | ||
} | ||
} | ||
|
||
} |