forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KEYCLOAK-14232 Add Referrer-Policy: no-referrer to each response from…
… Keycloak (cherry picked from commit 0b49640231abc6e465542bd2608e1c908c079ced)
- Loading branch information
Showing
11 changed files
with
144 additions
and
163 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
48 changes: 48 additions & 0 deletions
48
server-spi-private/src/main/java/org/keycloak/models/ContentSecurityPolicyBuilder.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,48 @@ | ||
package org.keycloak.models; | ||
|
||
public class ContentSecurityPolicyBuilder { | ||
|
||
private String frameSrc = "'self'"; | ||
private String frameAncestors = "'self'"; | ||
private String objectSrc = "'none'"; | ||
|
||
private boolean first; | ||
private StringBuilder sb; | ||
|
||
public static ContentSecurityPolicyBuilder create() { | ||
return new ContentSecurityPolicyBuilder(); | ||
} | ||
|
||
public ContentSecurityPolicyBuilder frameSrc(String frameSrc) { | ||
this.frameSrc = frameSrc; | ||
return this; | ||
} | ||
|
||
public ContentSecurityPolicyBuilder frameAncestors(String frameancestors) { | ||
this.frameAncestors = frameancestors; | ||
return this; | ||
} | ||
|
||
public String build() { | ||
sb = new StringBuilder(); | ||
first = true; | ||
|
||
build("frame-src", frameSrc); | ||
build("frame-ancestors", frameAncestors); | ||
build("object-src", objectSrc); | ||
|
||
return sb.toString(); | ||
} | ||
|
||
private void build(String k, String v) { | ||
if (v != null) { | ||
if (!first) { | ||
sb.append(" "); | ||
} | ||
first = false; | ||
|
||
sb.append(k).append(" ").append(v).append(";"); | ||
} | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.