Created
December 18, 2020 16:40
-
-
Save ahndmal/1a176d9b5cef588861a637e598b40328 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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