启用 HTTP Basic 认证
如果要启用 HTTP Basic 认证的话,只需在 configure() 方法所传入的 HttpSecurity 对象上调用 httpBasic() 即可。另外,还可以通过调用 realmName() 方法指定域。如下是在 Spring Security 中启用 HTTP Basic 认证的典型配置:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.formLogin()
.loginPage("/login");
.and()
.httpBasic()
.realmName("Spittr")
.and()
...
}
Last updated