From 5a5ba1d634ead9d6e277b900fcb895c32dde9030 Mon Sep 17 00:00:00 2001 From: click33 <2393584716@qq.com> Date: Sat, 17 Jun 2023 17:46:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E4=B9=89=20sa-token-bom=20=E5=8C=85?= =?UTF-8?q?=EF=BC=8C=E6=96=B9=E4=BE=BF=E5=BC=95=E5=85=A5=20sa-token=20?= =?UTF-8?q?=E6=97=B6=E5=AF=B9=E9=BD=90=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mvn clean.bat | 37 +++- pom.xml | 3 +- sa-token-bom/.gitignore | 13 ++ sa-token-bom/pom.xml | 171 ++++++++++++++++++ .../sa-token-demo-bom-import/.gitignore | 12 ++ .../sa-token-demo-bom-import/pom.xml | 84 +++++++++ .../java/com/pj/SaTokenDemoApplication.java | 27 +++ .../java/com/pj/current/GlobalException.java | 20 ++ .../main/java/com/pj/test/TestController.java | 32 ++++ .../src/main/resources/application.yml | 52 ++++++ sa-token-dependencies/pom.xml | 153 +--------------- 11 files changed, 450 insertions(+), 154 deletions(-) create mode 100644 sa-token-bom/.gitignore create mode 100644 sa-token-bom/pom.xml create mode 100644 sa-token-demo/sa-token-demo-bom-import/.gitignore create mode 100644 sa-token-demo/sa-token-demo-bom-import/pom.xml create mode 100644 sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/SaTokenDemoApplication.java create mode 100644 sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/current/GlobalException.java create mode 100644 sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/test/TestController.java create mode 100644 sa-token-demo/sa-token-demo-bom-import/src/main/resources/application.yml diff --git a/mvn clean.bat b/mvn clean.bat index c15f651f..f2df64a4 100644 --- a/mvn clean.bat +++ b/mvn clean.bat @@ -22,17 +22,42 @@ cd sa-token-demo-springboot3-redis & call mvn clean & cd .. cd sa-token-demo-springboot-redis & call mvn clean & cd .. cd sa-token-demo-springboot-redisson & call mvn clean & cd .. cd sa-token-demo-test & call mvn clean & cd .. -cd sa-token-demo-sso1-client & call mvn clean & cd .. -cd sa-token-demo-sso2-client & call mvn clean & cd .. -cd sa-token-demo-sso3-client & call mvn clean & cd .. -cd sa-token-demo-sso3-client-nosdk & call mvn clean & cd .. -cd sa-token-demo-sso-server & call mvn clean & cd .. -cd sa-token-demo-sso-server-solon & call mvn clean & cd .. cd sa-token-demo-thymeleaf & call mvn clean & cd .. cd sa-token-demo-webflux & call mvn clean & cd .. cd sa-token-demo-webflux-springboot3 & call mvn clean & cd .. cd sa-token-demo-websocket & call mvn clean & cd .. cd sa-token-demo-websocket-spring & call mvn clean & cd .. +cd sa-token-demo-bom-import & call mvn clean & cd .. + +cd sa-token-demo-sso +cd sa-token-demo-sso-server & call mvn clean & cd .. +cd sa-token-demo-sso1-client & call mvn clean & cd .. +cd sa-token-demo-sso2-client & call mvn clean & cd .. +cd sa-token-demo-sso3-client & call mvn clean & cd .. +cd sa-token-demo-sso3-client-nosdk & call mvn clean & cd .. +cd .. + +cd sa-token-demo-sso-for-solon +cd sa-token-demo-sso1-client-solon & call mvn clean & cd .. +cd sa-token-demo-sso2-client-solon & call mvn clean & cd .. +cd sa-token-demo-sso3-client-solon & call mvn clean & cd .. +cd sa-token-demo-sso-server-solon & call mvn clean & cd .. +cd .. + +cd sa-token-demo-oauth2 +cd sa-token-demo-oauth2-client & call mvn clean & cd .. +cd sa-token-demo-oauth2-server & call mvn clean & cd .. +cd .. + +cd sa-token-demo-remember-me +cd server_project & call mvn clean & cd .. +cd .. + + + + + + cd .. diff --git a/pom.xml b/pom.xml index ed2f2297..c47da5c8 100644 --- a/pom.xml +++ b/pom.xml @@ -19,12 +19,13 @@ sa-token-dependencies + sa-token-bom sa-token-core sa-token-starter sa-token-plugin - + Apache 2 diff --git a/sa-token-bom/.gitignore b/sa-token-bom/.gitignore new file mode 100644 index 00000000..8122f47c --- /dev/null +++ b/sa-token-bom/.gitignore @@ -0,0 +1,13 @@ +target/ + +node_modules/ +bin/ +.settings/ +unpackage/ +.classpath +.project + +.factorypath + +.idea/ +.iml \ No newline at end of file diff --git a/sa-token-bom/pom.xml b/sa-token-bom/pom.xml new file mode 100644 index 00000000..3aaeacb4 --- /dev/null +++ b/sa-token-bom/pom.xml @@ -0,0 +1,171 @@ + + + 4.0.0 + + cn.dev33 + sa-token-bom + ${revision} + pom + sa-token-bom + Sa-Token Bom + + + 1.34.1 + + + + + + + cn.dev33 + sa-token-core + ${revision} + + + + + cn.dev33 + sa-token-starter + ${revision} + + + cn.dev33 + sa-token-jboot-plugin + ${revision} + + + cn.dev33 + sa-token-jfinal-plugin + ${revision} + + + cn.dev33 + sa-token-reactor-spring-boot-starter + ${revision} + + + cn.dev33 + sa-token-servlet + ${revision} + + + cn.dev33 + sa-token-jakarta-servlet + ${revision} + + + cn.dev33 + sa-token-solon-plugin + ${revision} + + + cn.dev33 + sa-token-spring-boot-autoconfig + ${revision} + + + cn.dev33 + sa-token-spring-boot-starter + ${revision} + + + cn.dev33 + sa-token-spring-boot3-starter + ${revision} + + + + + + cn.dev33 + sa-token-plugin + ${revision} + + + cn.dev33 + sa-token-alone-redis + ${revision} + + + cn.dev33 + sa-token-dubbo + ${revision} + + + cn.dev33 + sa-token-grpc + ${revision} + + + cn.dev33 + sa-token-redis + ${revision} + + + cn.dev33 + sa-token-redis-fastjson + ${revision} + + + cn.dev33 + sa-token-redis-fastjson2 + ${revision} + + + cn.dev33 + sa-token-redis-jackson + ${revision} + + + cn.dev33 + sa-token-redisson-jackson + ${revision} + + + cn.dev33 + sa-token-redisx + ${revision} + + + cn.dev33 + sa-token-dialect-thymeleaf + ${revision} + + + cn.dev33 + sa-token-jwt + ${revision} + + + cn.dev33 + sa-token-oauth2 + ${revision} + + + cn.dev33 + sa-token-quick-login + ${revision} + + + cn.dev33 + sa-token-spring-aop + ${revision} + + + cn.dev33 + sa-token-sso + ${revision} + + + cn.dev33 + sa-token-temp-jwt + ${revision} + + + + + + + \ No newline at end of file diff --git a/sa-token-demo/sa-token-demo-bom-import/.gitignore b/sa-token-demo/sa-token-demo-bom-import/.gitignore new file mode 100644 index 00000000..99a6e767 --- /dev/null +++ b/sa-token-demo/sa-token-demo-bom-import/.gitignore @@ -0,0 +1,12 @@ +target/ + +node_modules/ +bin/ +.settings/ +unpackage/ +.classpath +.project + +.idea/ + +.factorypath \ No newline at end of file diff --git a/sa-token-demo/sa-token-demo-bom-import/pom.xml b/sa-token-demo/sa-token-demo-bom-import/pom.xml new file mode 100644 index 00000000..8746ea69 --- /dev/null +++ b/sa-token-demo/sa-token-demo-bom-import/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + cn.dev33 + sa-token-demo-bom-import + 0.0.1-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-parent + 2.5.14 + + + + + + 1.34.1 + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-aop + + + + + cn.dev33 + sa-token-spring-boot-starter + + + + + cn.dev33 + sa-token-redis-jackson + + + + + cn.dev33 + sa-token-jwt + + + + + org.apache.commons + commons-pool2 + + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + + + + + + + + cn.dev33 + sa-token-bom + 1.34.1 + pom + import + + + + + + \ No newline at end of file diff --git a/sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/SaTokenDemoApplication.java b/sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/SaTokenDemoApplication.java new file mode 100644 index 00000000..9ae761b9 --- /dev/null +++ b/sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/SaTokenDemoApplication.java @@ -0,0 +1,27 @@ +package com.pj; + +import cn.dev33.satoken.SaManager; +import cn.dev33.satoken.jwt.StpLogicJwtForSimple; +import cn.dev33.satoken.stp.StpLogic; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * Sa-Token 使用 bom 包引入框架 + */ +@SpringBootApplication +public class SaTokenDemoApplication { + + public static void main(String[] args) { + SpringApplication.run(SaTokenDemoApplication.class, args); + System.out.println("\n启动成功:Sa-Token配置如下:" + SaManager.getConfig()); + } + + // Sa-Token 整合 jwt (Simple 简单模式) + @Bean + public StpLogic getStpLogicJwt() { + return new StpLogicJwtForSimple(); + } + +} diff --git a/sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/current/GlobalException.java b/sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/current/GlobalException.java new file mode 100644 index 00000000..6b804761 --- /dev/null +++ b/sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/current/GlobalException.java @@ -0,0 +1,20 @@ +package com.pj.current; + +import cn.dev33.satoken.util.SaResult; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * 全局异常处理 + */ +@RestControllerAdvice +public class GlobalException { + + // 全局异常拦截(拦截项目中的所有异常) + @ExceptionHandler + public SaResult handlerException(Exception e){ + e.printStackTrace(); + return SaResult.error(e.getMessage()); + } + +} diff --git a/sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/test/TestController.java b/sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/test/TestController.java new file mode 100644 index 00000000..26fc75fb --- /dev/null +++ b/sa-token-demo/sa-token-demo-bom-import/src/main/java/com/pj/test/TestController.java @@ -0,0 +1,32 @@ +package com.pj.test; + +import cn.dev33.satoken.stp.StpUtil; +import cn.dev33.satoken.util.SaResult; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 测试专用Controller + * @author click33 + * + */ +@RestController +@RequestMapping("/test/") +public class TestController { + + // 测试 浏览器访问: http://localhost:8081/test/test + @RequestMapping("test") + public SaResult test() { + System.out.println("------------进来了"); + StpUtil.login(10001); + return SaResult.ok(); + } + + // 测试 浏览器访问: http://localhost:8081/test/test2 + @RequestMapping("test2") + public SaResult test2() { + StpUtil.checkLogin(); + return SaResult.ok(); + } + +} diff --git a/sa-token-demo/sa-token-demo-bom-import/src/main/resources/application.yml b/sa-token-demo/sa-token-demo-bom-import/src/main/resources/application.yml new file mode 100644 index 00000000..fc74e9a1 --- /dev/null +++ b/sa-token-demo/sa-token-demo-bom-import/src/main/resources/application.yml @@ -0,0 +1,52 @@ +# 端口 +server: + port: 8081 + +# sa-token 配置 +sa-token: + # token 名称 (同时也是 cookie 名称) + token-name: satoken + # token 有效期(单位:秒) 默认30天,-1 代表永久有效 + timeout: 2592000 + # token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结 + active-timeout: -1 + # 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录) + is-concurrent: true + # 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token) + is-share: true + # token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik) + token-style: uuid + # 是否输出操作日志 + is-log: true + # jwt秘钥 + jwt-secret-key: asdasdasifhueuiwyurfewbfjsdafjk + + +spring: + # redis配置 + redis: + # Redis数据库索引(默认为0) + database: 1 + # Redis服务器地址 + host: 127.0.0.1 + # Redis服务器连接端口 + port: 6379 + # Redis服务器连接密码(默认为空) + password: + # 连接超时时间 + timeout: 10s + lettuce: + pool: + # 连接池最大连接数 + max-active: 200 + # 连接池最大阻塞等待时间(使用负值表示没有限制) + max-wait: -1ms + # 连接池中的最大空闲连接 + max-idle: 10 + # 连接池中的最小空闲连接 + min-idle: 0 + + + + + \ No newline at end of file diff --git a/sa-token-dependencies/pom.xml b/sa-token-dependencies/pom.xml index defc5f24..87fd03e9 100644 --- a/sa-token-dependencies/pom.xml +++ b/sa-token-dependencies/pom.xml @@ -243,157 +243,16 @@ jjwt ${jjwt.version} - - - - + + cn.dev33 - sa-token-core + sa-token-bom ${revision} + pom + import - - - - cn.dev33 - sa-token-starter - ${revision} - - - cn.dev33 - sa-token-jboot-plugin - ${revision} - - - cn.dev33 - sa-token-jfinal-plugin - ${revision} - - - cn.dev33 - sa-token-reactor-spring-boot-starter - ${revision} - - - cn.dev33 - sa-token-servlet - ${revision} - - - cn.dev33 - sa-token-jakarta-servlet - ${revision} - - - cn.dev33 - sa-token-solon-plugin - ${revision} - - - cn.dev33 - sa-token-spring-boot-autoconfig - ${revision} - - - cn.dev33 - sa-token-spring-boot-starter - ${revision} - - - cn.dev33 - sa-token-spring-boot3-starter - ${revision} - - - - - - cn.dev33 - sa-token-plugin - ${revision} - - - cn.dev33 - sa-token-alone-redis - ${revision} - - - cn.dev33 - sa-token-dubbo - ${revision} - - - cn.dev33 - sa-token-grpc - ${revision} - - - cn.dev33 - sa-token-redis - ${revision} - - - cn.dev33 - sa-token-redis-fastjson - ${revision} - - - cn.dev33 - sa-token-redis-fastjson2 - ${revision} - - - cn.dev33 - sa-token-redis-jackson - ${revision} - - - cn.dev33 - sa-token-redisson-jackson - ${revision} - - - cn.dev33 - sa-token-redisx - ${revision} - - - cn.dev33 - sa-token-dialect-thymeleaf - ${revision} - - - cn.dev33 - sa-token-jwt - ${revision} - - - cn.dev33 - sa-token-oauth2 - ${revision} - - - cn.dev33 - sa-token-quick-login - ${revision} - - - cn.dev33 - sa-token-spring-aop - ${revision} - - - cn.dev33 - sa-token-sso - ${revision} - - - cn.dev33 - sa-token-temp-jwt - ${revision} - - - +