Spring安全性:本地配置文件是基于令牌的,但Dev配置文件默认为用户名密码
我想实现基于令牌的身份验证。我可以通过添加过滤器来做到这一点。这似乎只在Spring安全性:本地配置文件是基于令牌的,但Dev配置文件默认为用户名密码,spring,spring-boot,spring-mvc,spring-security,spring-security-rest,Spring,Spring Boot,Spring Mvc,Spring Security,Spring Security Rest,我想实现基于令牌的身份验证。我可以通过添加过滤器来做到这一点。这似乎只在local配置文件中起作用,但当我进入dev配置文件时,我会使用生成的安全密码将默认设置为:xxx,日志也不会像在local配置文件中一样在dev配置文件中注册过滤器 应用程序本地.yml: spring: profiles: active: local h2: console: enabled: true main: allow-bean-definition-overrid
local
配置文件中起作用,但当我进入dev
配置文件时,我会使用生成的安全密码将默认设置为:xxx
,日志也不会像在local
配置文件中一样在dev
配置文件中注册过滤器
应用程序本地.yml
:
spring:
profiles:
active: local
h2:
console:
enabled: true
main:
allow-bean-definition-overriding: true
# Configuration used to validate header
auth:
userid: gibberish213 # header key: header value
spring:
profiles:
active: local
main:
allow-bean-definition-overriding: true
datasource:
# Datasource related configs
application:
name: token-auth
# Configuration used to validate
auth:
userid: gibberish213 # header key: header value
application-dev.yml
:
spring:
profiles:
active: local
h2:
console:
enabled: true
main:
allow-bean-definition-overriding: true
# Configuration used to validate header
auth:
userid: gibberish213 # header key: header value
spring:
profiles:
active: local
main:
allow-bean-definition-overriding: true
datasource:
# Datasource related configs
application:
name: token-auth
# Configuration used to validate
auth:
userid: gibberish213 # header key: header value
我有一个空的SpringSecurityInitializer类,是否需要在该类中添加一些配置:
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
public class SpringSecurityInitializer extends AbstractSecurityWebApplicationInitializer {
}
检查过滤器bean顶部是否有@Profile(“local”)注释。如果这样做,它们只在指定的配置文件下工作