refactor: 封装公共配置,降低使用复杂度

This commit is contained in:
2023-11-25 20:45:16 +08:00
parent 4a8e4e4408
commit dafb2d8f5b
9 changed files with 123 additions and 0 deletions

View File

@@ -31,8 +31,10 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import top.charles7c.continew.starter.core.handler.GeneralPropertySourceFactory;
/**
* Sa-Token 自动配置
@@ -45,6 +47,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@RequiredArgsConstructor
@EnableConfigurationProperties(SaTokenExtensionProperties.class)
@ConditionalOnProperty(prefix = "sa-token.extension", name = "enabled", havingValue = "true")
@PropertySource(value = "classpath:default-auth-satoken.yml", factory = GeneralPropertySourceFactory.class)
public class SaTokenAutoConfiguration implements WebMvcConfigurer {
private final SaTokenExtensionProperties properties;

View File

@@ -0,0 +1,10 @@
--- ### Sa-Token 配置https://sa-token.cc/doc.html#/use/config
sa-token:
# token 前缀(例如填写 Bearer实际传参 token 键: Bearer xxxx-xxxx-xxxx-xxxx
token-prefix: Bearer
# 是否尝试从 请求体 里读取 Token
is-read-body: true
# 是否尝试从 header 里读取 Token
is-read-header: true
# 是否尝试从 cookie 里读取 Token此值为 false 后StpUtil.login(id) 登录时也不会再往前端注入 Cookie适合前后端分离模式
is-read-cookie: false