Ich verwende Spring Security, um Benutzer basierend auf der Rolle zu authentifizieren. Authentifizieren für /**
ist zu geben:Ich kann Authentifizierung in Spring Security vornehmen?
Page load failed with error: too many HTTP redirects
Fehler und Login-Seite wird nicht angezeigt.
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/login*").authenticated()
.antMatchers("/**").authenticated()
.and()
.formLogin().loginPage("/login").failureUrl("/login?error").defaultSuccessUrl("/welcome")
.usernameParameter("username").passwordParameter("password")
.and()
.logout().logoutSuccessUrl("/login?logout").logoutUrl("/login?logout")
.and()
.exceptionHandling().accessDeniedPage("/accessDenied")
.and()
.csrf();
}
Aber wenn ich so tun:
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/login").authenticated()
.antMatchers("/").authenticated()
.and()
.formLogin().loginPage("/login").failureUrl("/login?error").defaultSuccessUrl("/welcome")
.usernameParameter("username").passwordParameter("password")
.and()
.logout().logoutSuccessUrl("/login?logout").logoutUrl("/login?logout")
.and()
.exceptionHandling().accessDeniedPage("/accessDenied")
.and()
.csrf();
}
Was ist falsch in diesem Code für /**
URL zu authentifizieren?