Reputation: 65
I have the problem, that Spring Security is redirecting me to much. So the browser can't build up the side. Whats wrong with my code?
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/resources/**").permitAll()
.and()
.authorizeRequests()
.anyRequest()
.fullyAuthenticated()
.and()
.authorizeRequests()
.antMatchers("/login").permitAll()
.and()
.formLogin()
.and()
.httpBasic()
.and()
.requiresChannel()
.anyRequest()
.requiresSecure()
.and()
.csrf().disable();
}
I thought, that the user would be able to access to "localhost:8585/login", because of the .antMatchers("/login").permitAll() ?
Upvotes: 2
Views: 543
Reputation: 11017
order matters here
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/resources/**").permitAll()
.antMatchers("/login*").anonymous()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login")
.and()
.logout().logoutSuccessUrl("/login.html")
.and()
.httpBasic()
.and()
.requiresChannel()
.anyRequest()
.requiresSecure()
.and()
.csrf().disable();
}
Upvotes: 2