Skip to content

Instantly share code, notes, and snippets.

@ahndmal
Created December 18, 2020 16:40
Show Gist options
  • Save ahndmal/1a176d9b5cef588861a637e598b40328 to your computer and use it in GitHub Desktop.
Save ahndmal/1a176d9b5cef588861a637e598b40328 to your computer and use it in GitHub Desktop.
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/")
.permitAll()
.antMatchers("/login")
.permitAll()
.antMatchers("/registration")
.permitAll()
.antMatchers("/admin/**")
.hasAuthority("ADMIN")
.anyRequest()
.authenticated()
.and()
.csrf()
.disable()
.formLogin()
.loginPage("/login")
.failureUrl("/login?error=true")
.defaultSuccessUrl("/home")
.usernameParameter("login")
.passwordParameter("password")
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/")
.and()
.exceptionHandling()
.accessDeniedPage("/access-denied");
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring()
.antMatchers("/resources/**", "/static/**", "/css/**", "/js/**", "/images/**");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment