Browse Source

update satoken 1.27.0 => 1.28.0 使用 jwt 插件代理 token 生成逻辑

疯狂的狮子li 3 years ago
parent
commit
7079a4e7e4

+ 7 - 1
pom.xml

@@ -25,7 +25,7 @@
         <poi.version>4.1.2</poi.version>
         <easyexcel.version>2.2.11</easyexcel.version>
         <velocity.version>1.7</velocity.version>
-        <satoken.version>1.27.0</satoken.version>
+        <satoken.version>1.28.0</satoken.version>
         <mybatis-plus.version>3.4.3.4</mybatis-plus.version>
         <p6spy.version>3.9.1</p6spy.version>
         <hutool.version>5.7.15</hutool.version>
@@ -142,6 +142,12 @@
                 <artifactId>sa-token-spring-aop</artifactId>
                 <version>${satoken.version}</version>
             </dependency>
+            <!-- Sa-Token 整合 jwt -->
+            <dependency>
+                <groupId>cn.dev33</groupId>
+                <artifactId>sa-token-jwt</artifactId>
+                <version>${satoken.version}</version>
+            </dependency>
 
             <!-- jdk11 缺失依赖 jaxb-->
             <dependency>

+ 3 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -114,7 +114,9 @@ sa-token:
   # token前缀
   token-prefix: "Bearer"
   # token风格
-  token-style: random-128
+  token-style: uuid
+  # jwt秘钥
+  jwt-secret-key: abcdefghijklmnopqrstuvwxyz
   # 是否输出操作日志
   is-log: true
 

+ 5 - 0
ruoyi-common/pom.xml

@@ -44,6 +44,11 @@
             <groupId>cn.dev33</groupId>
             <artifactId>sa-token-spring-aop</artifactId>
         </dependency>
+        <!-- Sa-Token 整合 jwt -->
+        <dependency>
+            <groupId>cn.dev33</groupId>
+            <artifactId>sa-token-jwt</artifactId>
+        </dependency>
 
         <!-- 自定义验证注解 -->
         <dependency>

+ 17 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SaTokenConfig.java

@@ -0,0 +1,17 @@
+package com.ruoyi.framework.config;
+
+import cn.dev33.satoken.jwt.StpLogicJwtForStyle;
+import cn.dev33.satoken.stp.StpLogic;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class SaTokenConfig {
+
+    @Bean
+    public StpLogic getStpLogicJwt() {
+        // Sa-Token 整合 jwt (Style模式)
+        return new StpLogicJwtForStyle();
+    }
+
+}