Created
July 1, 2018 14:23
-
-
Save sirius2k/9097f782392255059ba922825002f39c to your computer and use it in GitHub Desktop.
Use h2 database console with SpringBoot and SpringSecurity
This file contains 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
public class SecurityConfig extends WebSecurityConfigurerAdapter { | |
... | |
@Override | |
public void configure(HttpSecurity httpSecurity) throws Exception { | |
httpSecurity.authorizeRequests() | |
.antMatchers("/login/**").permitAll() | |
.antMatchers("/login").permitAll() | |
.antMatchers("/h2/**").permitAll() // here | |
.antMatchers("/**").authenticated() | |
.and() | |
.formLogin() | |
.loginPage("/login/form") | |
.loginProcessingUrl("/login") | |
.defaultSuccessUrl("/") | |
.failureUrl("/login/form?error=true") | |
.usernameParameter("id") | |
.passwordParameter("password") | |
.and() | |
.headers() // here | |
.frameOptions() | |
.disable() | |
.and() | |
.csrf() // here | |
.ignoringAntMatchers("/h2/**") | |
.and() | |
.logout(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment