81,092
社区成员
发帖
与我相关
我的任务
分享
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.jdbcAuthentication()
.dataSource(dataSource).passwordEncode(new BCryPasswordEncoder());
}
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/user/**").hasRole("USER")
.antMatchers("/admin/**").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login.html")
.usernameParameter("username")
.passwordParameter("password")
.loginProcessingUrl("/login")
.defaultSuccessUrl("/login-success.html")
.failureUrl("/login-error.html")
.permitAll()
.and()
.logout().logoutUrl("/logout")
.logoutSuccessUrl("/logout-success.html");
}