Skip to content

Commit

Permalink
Use the nested builder support in HttpSecurity DSL of WebSecurityConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
drumonii committed Oct 28, 2019
1 parent 79381b8 commit 86d70a0
Showing 1 changed file with 26 additions and 20 deletions.
Expand Up @@ -43,26 +43,32 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests()
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole(UserRole.ADMIN)
.and()
.formLogin()
.loginPage("/admin/login")
.loginProcessingUrl(apiPath + "/admin/login")
.successHandler(authenticationSuccessHandler())
.failureHandler(authenticationFailureHandler())
.permitAll()
.and()
.logout()
.logoutUrl(apiPath + "/admin/logout")
.logoutSuccessHandler(logoutSuccessHandler())
.permitAll()
.and()
.csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.and()
.exceptionHandling()
.authenticationEntryPoint(authenticationEntryPoint());
.authorizeRequests(authorizeRequests ->
authorizeRequests
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole(UserRole.ADMIN)
)
.formLogin(formLogin ->
formLogin
.loginPage("/admin/login")
.loginProcessingUrl(apiPath + "/admin/login")
.successHandler(authenticationSuccessHandler())
.failureHandler(authenticationFailureHandler())
.permitAll()
)
.logout(logout ->
logout
.logoutUrl(apiPath + "/admin/logout")
.logoutSuccessHandler(logoutSuccessHandler())
.permitAll()
)
.csrf(csrf ->
csrf
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
)
.exceptionHandling(exceptionHandling ->
exceptionHandling
.authenticationEntryPoint(authenticationEntryPoint())
);
// @formatter:on
}

Expand Down

0 comments on commit 86d70a0

Please sign in to comment.