Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 602535c1 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Update Securioty config with exception handler for "http basic"

parent ec9dfc5b
No related branches found
No related tags found
No related merge requests found
......@@ -93,12 +93,15 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
httpSecurity
.csrf().csrfTokenRepository(csrfTokenRepository).requireCsrfProtectionMatcher(csrfURLMatcher).and()
.exceptionHandling().authenticationEntryPoint(new SpringSecurityExceptionHandler()).and()
.headers().frameOptions().deny().contentTypeOptions().and().xssProtection().xssProtectionEnabled(true).and().and()
.exceptionHandling()
.authenticationEntryPoint(new SpringSecurityExceptionHandler())
.accessDeniedHandler(new SpringSecurityExceptionHandler())
.and()
.headers().frameOptions().deny().contentTypeOptions().and().xssProtection().xssProtectionEnabled(true).and().and()
.addFilter(blueCoatAuthenticationFilter)
.addFilter(x509AuthenticationFilter)
.httpBasic()
.httpBasic().authenticationEntryPoint(new SpringSecurityExceptionHandler())
.and() // username
.anonymous().authorities(SMPAuthority.S_AUTHORITY_ANONYMOUS.getAuthority()).and()
.authorizeRequests().antMatchers(HttpMethod.DELETE, "/ui/rest/security/authentication").permitAll()
......@@ -119,8 +122,6 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
SMPAuthority.S_AUTHORITY_SERVICE_GROUP.getAuthority(),
SMPAuthority.S_AUTHORITY_SYSTEM_ADMIN.getAuthority()).and()
;
}
@Override
......
......@@ -45,7 +45,7 @@ public class SpringSecurityExceptionHandler extends BasicAuthenticationEntryPoin
private static final Logger log = LoggerFactory.getLogger(SpringSecurityExceptionHandler.class);
public SpringSecurityExceptionHandler() {
this.setRealmName("any realm name");
this.setRealmName("SMPSecurityRealm");
}
@Override
......@@ -79,8 +79,8 @@ public class SpringSecurityExceptionHandler extends BasicAuthenticationEntryPoin
String errorUniqueId = ((ErrorResponse) response.getBody()).getErrorUniqueId();
String logMsg = format("Error unique ID: %s", errorUniqueId);
log.warn(logMsg, exception);
log.warn("Security error:[{}] with [{}].", errorMsg, logMsg);
log.debug(logMsg, exception);
return response;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment