【sa-token】shiro替换为sa-token,核心架构修改点

This commit is contained in:
JEECG
2025-10-16 11:14:53 +08:00
parent 468af57489
commit c7c31e0945
31 changed files with 1313 additions and 1394 deletions

View File

@ -1,30 +0,0 @@
package org.jeecg.config.init;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
/**
* Shiro缓存清理
* 在应用启动时清除所有的Shiro授权缓存
* 主要用于解决重启项目,用户未重新登录,按钮权限不生效的问题
*/
@Slf4j
@Component
public class ShiroCacheClearRunner implements ApplicationRunner {
@Autowired
private RedisUtil redisUtil;
@Override
public void run(ApplicationArguments args) {
// 清空所有授权redis缓存
log.info("——— Service restart, clearing all user shiro authorization cache ——— ");
redisUtil.removeAll(CommonConstant.PREFIX_USER_SHIRO_CACHE);
}
}

View File

@ -19,6 +19,31 @@ management:
exposure:
include: metrics,httpexchanges,jeecghttptrace
################ Sa-Token 配置 (文档: https://sa-token.cc) ################
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: X-Access-Token
# token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: false
# token 风格使用jwt-simple保持与原JWT token格式一致
token-style: jwt-simple
# 是否输出操作日志
is-log: false
# 是否从 cookie 中读取 token
is-read-cookie: false
# 是否从 head 中读取 token
is-read-header: true
# 是否从请求体URL参数里读取 token
is-read-body: true
# jwt秘钥重要请修改为你自己的秘钥确保足够复杂
jwt-secret-key: "dd05f1c54d63749eda95f9fa6d49v442a"
spring:
# main:
# # 启动加速 (建议开发环境开启后flyway自动升级失效)

View File

@ -18,7 +18,32 @@ management:
web:
exposure:
include: metrics,httpexchanges,jeecghttptrace
################ Sa-Token 配置 (文档: https://sa-token.cc) ################
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: X-Access-Token
# token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: false
# token 风格使用jwt-simple保持与原JWT token格式一致
token-style: jwt-simple
# 是否输出操作日志
is-log: false
# 是否从 cookie 中读取 token
is-read-cookie: false
# 是否从 head 中读取 token
is-read-header: true
# 是否从请求体URL参数里读取 token
is-read-body: true
# jwt秘钥重要请修改为你自己的秘钥确保足够复杂
jwt-secret-key: "dd05f1c54d63749eda95f9fa6d49v442a"
spring:
flyway:
# 是否启用flyway

View File

@ -18,7 +18,32 @@ management:
web:
exposure:
include: metrics,httpexchanges,jeecghttptrace
################ Sa-Token 配置 (文档: https://sa-token.cc) ################
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: X-Access-Token
# token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: false
# token 风格使用jwt-simple保持与原JWT token格式一致
token-style: jwt-simple
# 是否输出操作日志
is-log: false
# 是否从 cookie 中读取 token
is-read-cookie: false
# 是否从 head 中读取 token
is-read-header: true
# 是否从请求体URL参数里读取 token
is-read-body: true
# jwt秘钥重要请修改为你自己的秘钥确保足够复杂
jwt-secret-key: "dd05f1c54d63749eda95f9fa6d49v442a"
spring:
flyway:
# 是否启用flyway

View File

@ -18,7 +18,32 @@ management:
web:
exposure:
include: metrics,httpexchanges,jeecghttptrace
################ Sa-Token 配置 (文档: https://sa-token.cc) ################
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: X-Access-Token
# token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: false
# token 风格使用jwt-simple保持与原JWT token格式一致
token-style: jwt-simple
# 是否输出操作日志
is-log: false
# 是否从 cookie 中读取 token
is-read-cookie: false
# 是否从 head 中读取 token
is-read-header: true
# 是否从请求体URL参数里读取 token
is-read-body: true
# jwt秘钥重要请修改为你自己的秘钥确保足够复杂
jwt-secret-key: "dd05f1c54d63749eda95f9fa6d49v442a"
spring:
flyway:
# 是否启用flyway

View File

@ -18,7 +18,32 @@ management:
web:
exposure:
include: metrics,httpexchanges,jeecghttptrace
################ Sa-Token 配置 (文档: https://sa-token.cc) ################
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: X-Access-Token
# token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: false
# token 风格使用jwt-simple保持与原JWT token格式一致
token-style: jwt-simple
# 是否输出操作日志
is-log: false
# 是否从 cookie 中读取 token
is-read-cookie: false
# 是否从 head 中读取 token
is-read-header: true
# 是否从请求体URL参数里读取 token
is-read-body: true
# jwt秘钥重要请修改为你自己的秘钥确保足够复杂
jwt-secret-key: "dd05f1c54d63749eda95f9fa6d49v442a"
spring:
flyway:
# 是否启用flyway

View File

@ -18,7 +18,32 @@ management:
web:
exposure:
include: metrics,httpexchanges,jeecghttptrace
################ Sa-Token 配置 (文档: https://sa-token.cc) ################
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: X-Access-Token
# token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: false
# token 风格使用jwt-simple保持与原JWT token格式一致
token-style: jwt-simple
# 是否输出操作日志
is-log: false
# 是否从 cookie 中读取 token
is-read-cookie: false
# 是否从 head 中读取 token
is-read-header: true
# 是否从请求体URL参数里读取 token
is-read-body: true
# jwt秘钥重要请修改为你自己的秘钥确保足够复杂
jwt-secret-key: "dd05f1c54d63749eda95f9fa6d49v442a"
spring:
flyway:
# 是否启用flyway

View File

@ -18,7 +18,32 @@ management:
web:
exposure:
include: metrics,httpexchanges,jeecghttptrace
################ Sa-Token 配置 (文档: https://sa-token.cc) ################
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: X-Access-Token
# token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: false
# token 风格使用jwt-simple保持与原JWT token格式一致
token-style: jwt-simple
# 是否输出操作日志
is-log: false
# 是否从 cookie 中读取 token
is-read-cookie: false
# 是否从 head 中读取 token
is-read-header: true
# 是否从请求体URL参数里读取 token
is-read-body: true
# jwt秘钥重要请修改为你自己的秘钥确保足够复杂
jwt-secret-key: "dd05f1c54d63749eda95f9fa6d49v442a"
spring:
flyway:
# 是否启用flyway

View File

@ -18,7 +18,32 @@ management:
web:
exposure:
include: metrics,httpexchanges,jeecghttptrace
################ Sa-Token 配置 (文档: https://sa-token.cc) ################
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: X-Access-Token
# token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: false
# token 风格使用jwt-simple保持与原JWT token格式一致
token-style: jwt-simple
# 是否输出操作日志
is-log: false
# 是否从 cookie 中读取 token
is-read-cookie: false
# 是否从 head 中读取 token
is-read-header: true
# 是否从请求体URL参数里读取 token
is-read-body: true
# jwt秘钥重要请修改为你自己的秘钥确保足够复杂
jwt-secret-key: "dd05f1c54d63749eda95f9fa6d49v442a"
spring:
flyway:
# 是否启用flyway

View File

@ -18,7 +18,32 @@ management:
web:
exposure:
include: metrics,httpexchanges,jeecghttptrace
################ Sa-Token 配置 (文档: https://sa-token.cc) ################
sa-token:
# token 名称(同时也是 cookie 名称)
token-name: X-Access-Token
# token 有效期(单位:秒) 默认30天-1 代表永久有效
timeout: 2592000
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
active-timeout: -1
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token
is-share: false
# token 风格使用jwt-simple保持与原JWT token格式一致
token-style: jwt-simple
# 是否输出操作日志
is-log: false
# 是否从 cookie 中读取 token
is-read-cookie: false
# 是否从 head 中读取 token
is-read-header: true
# 是否从请求体URL参数里读取 token
is-read-body: true
# jwt秘钥重要请修改为你自己的秘钥确保足够复杂
jwt-secret-key: "dd05f1c54d63749eda95f9fa6d49v442a"
spring:
flyway:
# 是否启用flyway