Spring Security
2020-12-26 07:29
标签:class 登录 use prot led exception enabled ant MLOG Spring Boot1.X版本依赖Security 4.X,默认HttpBasic验证模式;Spring Boot2.X版本依赖Security 5.X,默认表单模式。 提供一种“防君子不防小人”的登录验证, 默认用户名 Http请求中使用Authorization作为一个Header,值为 Spring Security 标签:class 登录 use prot led exception enabled ant MLOG 原文地址:https://www.cnblogs.com/wjcx-sqh/p/13036935.htmlSpring Security
HttpBasic模式
security.basic.enabled
已过时,需手动开启@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic()//开启httpbasic认证
.and().authorizeRequests().anyRequest().authenticated();//所有请求都需要登录认证才能访问
}
}
user
,密码在控制台有打印。或自定义spring:
security:
user:
name: user_1
password: snant
Basic Base64(name:password)
formLogin登录认证模式