Skip to content

Commit

Permalink
improve security headers
Browse files Browse the repository at this point in the history
by setting conten-security and feature policy and deny embedding in an iFrame

closes jhipster#9549
  • Loading branch information
atomfrede committed Jun 7, 2019
1 parent e857532 commit ddd3d02
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import org.springframework.security.web.csrf.CsrfFilter;
<%_ if (authenticationType === 'jwt' && applicationType !== 'microservice') { _%>
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
<%_ } _%>
import org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter;
<%_ if (applicationType !== 'microservice') { _%>
import org.springframework.web.filter.CorsFilter;
<%_ } _%>
Expand Down Expand Up @@ -223,8 +224,14 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
<%_ } _%>
.and()
.headers()
.contentSecurityPolicy("default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'")
.and()
.referrerPolicy(ReferrerPolicyHeaderWriter.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN)
.and()
.featurePolicy("geolocation 'none'; midi 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; speaker 'none'; fullscreen 'self'; payment 'none'")
.and()
.frameOptions()
.disable()
.deny()
.and()
<%_ if (authenticationType === 'jwt' || (authenticationType === 'oauth2' && applicationType === 'microservice')) { _%>
.sessionManagement()
Expand Down

0 comments on commit ddd3d02

Please sign in to comment.