【发布时间】:2017-05-07 05:21:37
【问题描述】:
我刚开始学习 Spring 和 Spring Security,并通过阅读 Spring Security 文档创建了一个简单的项目。我完成了以下基于 java 的配置。
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("admin")
.password("nimda")
.roles("ADMIN");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/admin**").access("hasRole('ADMIN')")
.and().formLogin();
http.csrf().disable();
}
}
当我选择“/admin”时,它会将我重定向到我知道 spring 使用此默认配置生成的登录页面,登录后它将显示登录页面。现在我的问题是:登录表单已发布到“/ login”,我没有定义任何“AuthenticationManager”和“UserDetailService”,我在自定义配置文档中阅读了这些信息,那么spring 如何发布表单并执行登录过程?基本上我想知道这个默认登录过程的内部工作的一些细节。
【问题讨论】:
-
查看stackoverflow.com/a/9788206/3447229 和文档...
标签: java spring spring-mvc spring-security