标签:class 登录 use prot led exception enabled ant MLOG
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
Spring Boot1.X版本依赖Security 4.X,默认HttpBasic验证模式;Spring Boot2.X版本依赖Security 5.X,默认表单模式。
提供一种“防君子不防小人”的登录验证,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
Http请求中使用Authorization作为一个Header,值为Basic Base64(name:password)
标签:class 登录 use prot led exception enabled ant MLOG
原文地址:https://www.cnblogs.com/wjcx-sqh/p/13036935.html