Skip to content

Commit

Permalink
Merge pull request eclipse-tractusx#154 from catenax-ng/main
Browse files Browse the repository at this point in the history
Merge to eclipse
  • Loading branch information
mkanal authored Aug 21, 2023
2 parents 5d0e0aa + efcac7c commit 13fec26
Show file tree
Hide file tree
Showing 3 changed files with 387 additions and 301 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.header.writers.ContentSecurityPolicyHeaderWriter;
import org.springframework.security.web.header.writers.PermissionsPolicyHeaderWriter;
import org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter;
import org.springframework.security.web.header.writers.XXssProtectionHeaderWriter;
import org.springframework.security.web.util.matcher.AnyRequestMatcher;
import org.springframework.web.cors.CorsConfiguration;
Expand Down Expand Up @@ -69,6 +71,7 @@ public class SecurityConfiguration {
};
private static final long HSTS_MAX_AGE_DAYS = 365;
private static final String ONLY_SELF_SCRIPT_SRC = "script-src 'self'";
private static final String PERMISSION_POLICY = "microphone=(), geolocation=(), camera=()";

@SuppressWarnings("PMD.SignatureDeclareThrowsException")
@Bean
Expand All @@ -92,6 +95,9 @@ public class SecurityConfiguration {
httpSecurity.headers(headers -> headers.addHeaderWriter(new ContentSecurityPolicyHeaderWriter(ONLY_SELF_SCRIPT_SRC)));

httpSecurity.headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin));
httpSecurity.headers(headers -> headers.addHeaderWriter(new ReferrerPolicyHeaderWriter(
ReferrerPolicyHeaderWriter.ReferrerPolicy.SAME_ORIGIN)));
httpSecurity.headers(headers -> headers.addHeaderWriter(new PermissionsPolicyHeaderWriter(PERMISSION_POLICY)));

httpSecurity.sessionManagement(sessionManagement -> sessionManagement
.sessionCreationPolicy(STATELESS));
Expand Down
Loading

0 comments on commit 13fec26

Please sign in to comment.