merge dev into master

sync dev master

Created-by: shengzhang_
Author-id: 774020
MR-id: 103634
Commit-by: click33;黄先生;刘潇;Jelex;林钟一六;noear
Merged-by: shengzhang_
E2E-issues: 
Description: sync dev master

See merge request: click33/sa-token!1
This commit is contained in:
shengzhang_
2024-06-21 12:50:40 +00:00
10 changed files with 138 additions and 29 deletions

View File

@@ -187,6 +187,14 @@ Sa-Token-OAuth2 模块分为四种授权模式,解决不同场景下的授权
- [[ Solon ]](https://gitee.com/noear/solon):一个更现代感的应用开发框架:更快、更小、更自由。
### 代码托管
- Gitee[https://gitee.com/dromara/sa-token](https://gitee.com/dromara/sa-token)
- GitHub[https://github.com/dromara/sa-token](https://github.com/dromara/sa-token)
- GitCode[https://gitcode.com/click33/sa-token](https://gitcode.com/click33/sa-token)
### 交流群
<!-- QQ交流群685792424 [点击加入](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=Y05Ld4125W92YSwZ0gA8e3RhG9Q4Vsfx&authKey=IomXuIuhP9g8G7l%2ByfkrRsS7i%2Fna0lIBpkTXxx%2BQEaz0NNEyJq00kgeiC4dUyNLS&noverify=0&group_code=685792424)-->
@@ -194,9 +202,9 @@ QQ交流群936523917 [点击加入](https://qm.qq.com/q/xfoMJA5Az0)
微信交流群:
<img src="https://oss.dev33.cn/sa-token/qr/wx-qr-m-400k.png" width="230px" title="微信群" />
<!-- <img src="https://oss.dev33.cn/sa-token/qr/wx-qr-m-400k.png" width="230px" title="微信群" /> -->
<!-- <img src="https://oss.dev33.cn/sa-token/qr/i-wx-qr2.png" width="230px" title="微信群" /> -->
<img src="https://oss.dev33.cn/sa-token/qr/i-wx-qr2.png" width="230px" title="微信群" />
(扫码添加微信备注sa-token邀您加入群聊)

View File

@@ -1,14 +1,9 @@
package com.pj.test;
import cn.dev33.satoken.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.dev33.satoken.annotation.SaCheckBasic;
import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.annotation.SaCheckSafe;
import cn.dev33.satoken.annotation.SaMode;
import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.util.SaResult;
@@ -71,7 +66,7 @@ public class AtController {
}
// 通过Basic认证后才可以进入 ---- http://localhost:8081/at/checkBasic
@SaCheckBasic(account = "sa:123456")
@SaCheckHttpBasic(account = "sa:123456")
@RequestMapping("checkBasic")
public SaResult checkBasic() {
return SaResult.ok();

View File

@@ -65,7 +65,7 @@ public class AtController {
}
// 通过Basic认证后才可以进入 ---- http://localhost:8080/sa_token_demo_ssm_war/at/checkBasic
@SaCheckBasic(account = "sa:123456")
@SaCheckHttpBasic(account = "sa:123456")
@RequestMapping("checkBasic")
public SaResult checkBasic() {
return SaResult.ok();

View File

@@ -537,8 +537,11 @@
<a href="https://sohelp.net/" target="_blank" title="宁波互邦软件有限公司">
<img class="lazy" data-original="https://oss.dev33.cn/sa-token/com/ningbohubang.png">
</a>
<a href="http://www.zdzxtech.com/" target="_blank" title="武汉真道智享科技有限公司">
<!-- <a href="http://www.zdzxtech.com/" target="_blank" title="武汉真道智享科技有限公司">
<img class="lazy" data-original="https://oss.dev33.cn/sa-token/com/zhendaozhiting.jpeg">
</a> -->
<a href="https://yimei.liuxin.online/" target="_blank" title="逸玫工作室">
<img class="lazy" data-original="https://oss.dev33.cn/sa-token/com/yimei-black.png">
</a>
</div>
<div style="height: 10px; clear: both;"></div>
@@ -743,8 +746,8 @@
<img class="lazy" data-original="https://oss.dev33.cn/sa-token/link/yft-design.png"
msg="基于 Canvas 的开源版 创客贴 支持导出jsonsvg, image文件。">
</a>
<a href="https://gitee.com/dromara/spring-file-storage" target="_blank">
<img class="lazy" data-original="https://oss.dev33.cn/sa-token/link/file4j.png"
<a href="https://gitee.com/dromara/x-file-storage" target="_blank">
<img class="lazy" data-original="https://oss.dev33.cn/sa-token/link/x-file-storage.svg"
msg="在 SpringBoot 中通过简单的方式将文件存储到 本地、阿里云 OSS、腾讯云 COS、七牛云 Kodo等">
</a>
<a href="https://wemq.nicholasld.cn/" target="_blank">
@@ -795,10 +798,22 @@
<img class="lazy" data-original="https://oss.dev33.cn/sa-token/link/dy-java.png"
msg="DyJava是一款功能强大的抖音Java开发工具包">
</a>
<a href="https://dromara.org/zh/projects/" target="_blank">
<a href="https://gitee.com/dromara/MilvusPlus" target="_blank">
<img class="lazy" data-original="https://oss.dev33.cn/sa-token/link/MilvusPlus.jpg"
msg="MilvusPlus简称 MP是一个 Milvus 的操作工具,旨在简化与 Milvus 向量数据库的交互,为开发者提供类似 MyBatis-Plus 注解和方法调用风格的直观 API,提高效率而生。">
</a>
<a href="http://www.easy-query.com/easy-query-doc/" target="_blank">
<img class="lazy" data-original="https://oss.dev33.cn/sa-token/link/easy-query.png"
msg="java下唯一一款同时支持强类型对象关系查询和强类型SQL语法查询的ORM,拥有对象模型筛选、隐式子查询、隐式join、显式子查询、显式join,支持Java/Kotlin">
</a>
<!-- <a href="https://dromara.org/zh/projects/" target="_blank">
<img class="lazy" data-original="https://oss.dev33.cn/sa-token/link/dromara.png"
msg="让每一位开源爱好者,体会到开源的快乐。">
</a>
</a> -->
</div>
<div style="height: 10px; clear: both;"></div>
<p>
@@ -905,19 +920,11 @@
<div class="ss-box">
<h3>联系我们</h3>
<ul class="list-unstyle">
<!-- <li>电话:<a href="tel:123;">123</a></li> -->
<!-- <li>QQ群 <a href="xxx" target="_blank">111</a></li> -->
<li>QQ群 <a href="doc.html#/more/join-group">点击加入</a></li>
<li>邮箱:<a href="javascript: alert('暂无');">暂无</a></li>
<li>联系:<a href="javascript: alert('暂无');">暂无</a></li>
</ul>
</div>
<!-- <div class="ss-box">
<h3 class="last">Dromara 知识星球</h3>
<div class="media-img padding-small-top" style="text-align: center;">
<img class="dro-qr" src="https://oss.dev33.cn/sa-token/dromara-xingqiu--sa-token.jpg" width="200" height="100" />
</div>
</div> -->
<div class="ss-box">
<h3 class="last" style="text-align: left; float: none; padding-left: 0px;">Sa-Token 公众号</h3>
<div class="media-img padding-small-top" style="text-align: left;">

View File

@@ -15,9 +15,9 @@ QQ交流群936523917 [点击加入](https://qm.qq.com/q/xfoMJA5Az0)
### 2、加入微信交流群
![微信群](https://oss.dev33.cn/sa-token/wx-qr-300.png ':size=180')
<!-- ![微信群](https://oss.dev33.cn/sa-token/wx-qr-300.png ':size=180') -->
<!-- ![微信群](https://oss.dev33.cn/sa-token/qr/i-wx-qr2.png ':size=175') -->
![微信群](https://oss.dev33.cn/sa-token/qr/i-wx-qr2.png ':size=175')
扫码添加微信备注sa邀您加入群聊

View File

@@ -33,7 +33,7 @@ sa-token:
<!------------- tab:properties 风格 ------------->
``` properties
# 配置允许单点登录的 url
sa-token.sso.allow-url=http://sa-sso-client1.com:9001/sso/login
sa-token.sso-server.allow-url=http://sa-sso-client1.com:9001/sso/login
```
<!---------------------------- tabs:end ---------------------------->

View File

@@ -34,6 +34,13 @@
// Sa-Token 权限认证Reactor响应式集成在线文档https://sa-token.cc
implementation 'cn.dev33:sa-token-reactor-spring-boot-starter:${sa.top.version}'
```
<!-------- tab:Gradle (Kotlin) 方式 -------->
注:如果你使用的是 `SpringBoot 3.x`,只需要将 `sa-token-reactor-spring-boot-starter` 修改为 `sa-token-reactor-spring-boot3-starter` 即可。
``` gradle
// Sa-Token 权限认证Reactor响应式集成在线文档https://sa-token.cc
implementation("cn.dev33:sa-token-reactor-spring-boot-starter:${sa.top.version}")
```
<!---------------------------- tabs:end ------------------------------>
@@ -43,6 +50,8 @@ implementation 'cn.dev33:sa-token-reactor-spring-boot-starter:${sa.top.version}'
### 3、创建启动类
在项目中新建包 `com.pj` ,在此包内新建主类 `SaTokenDemoApplication.java`,输入以下代码:
<!---------------------------- tabs:start ------------------------------>
<!-------- tab:Java -------->
``` java
@SpringBootApplication
public class SaTokenDemoApplication {
@@ -53,8 +62,24 @@ public class SaTokenDemoApplication {
}
```
<!-------- tab:Kotlin -------->
```kotlin
@SpringBootApplication
class SaTokenDemoApplication
fun main(args: Array<String>) {
runApplication<SaTokenDemoApplication>(*args)
println(SaManager.getConfig())
}
```
<!---------------------------- tabs:end ------------------------------>
### 4、创建全局过滤器
新建`SaTokenConfigure.java`,注册 Sa-Token 的全局过滤器
<!---------------------------- tabs:start ------------------------------>
<!-------- tab:Java -------->
``` java
/**
* [Sa-Token 权限认证] 全局配置类
@@ -85,10 +110,41 @@ public class SaTokenConfigure {
}
}
```
<!-------- tab:Kotlin -------->
```kotlin
@Configuration
class SaTokenConfigure {
/**
* 注册 [Sa-Token全局过滤器]
*/
@Bean
fun saReactorFilter(): SaReactorFilter = SaReactorFilter()
// 指定 [拦截路由]此处为拦截所有path
.addInclude("/**")
// 指定 [放行路由]
.addExclude("/favicon.ico")
// 指定[认证函数]: 每次请求执行
.setAuth {
println("---------- sa全局认证")
// SaRouter.match("/test/test", SaFunction { StpUtil.checkLogin() })
}
// 指定[异常处理函数]:每次[认证函数]发生异常时执行此函数
.setError { e: Throwable ->
println("---------- sa全局异常 ")
SaResult.error(e.message)
}
}
```
<!---------------------------- tabs:end ------------------------------>
你只需要按照此格式复制代码即可,有关过滤器的详细用法,会在之后的章节详细介绍。
### 5、创建测试Controller
<!---------------------------- tabs:start ------------------------------>
<!-------- tab:Java -------->
``` java
@RestController
@RequestMapping("/user/")
@@ -114,6 +170,27 @@ public class UserController {
}
```
<!-------- tab:Kotlin -------->
```kotlin
@RestController
@RequestMapping("/user/")
class UserController {
@RequestMapping("doLogin")
fun doLogin(username: String, password: String) =
// 此处仅作模拟示例,真实项目需要从数据库中查询数据进行比对
if ("zhang" == username && "123456" == password) {
StpUtil.login(10001)
"登录成功"
} else "登录失败"
@RequestMapping("isLogin")
fun isLogin() = "当前会话是否登录:" + StpUtil.isLogin()
}
```
<!---------------------------- tabs:end ------------------------------>
### 6、运行
启动代码,从浏览器依次访问上述测试接口:

View File

@@ -1110,4 +1110,25 @@ var donateList = [
"msg": "感谢您的开源项目!",
"date": "2024-05-07"
},
{
"name": "INS6",
"link": "https://gitee.com/feiyuchuixue",
"money": 188.0,
"msg": '<a href="https://szadmin.cn/" target="_blank">感谢Sa-Token开源Sz-Admin一个轻量化RBAC开源框架。</a>',
"date": "2024-06-05"
},
{
"name": "Zongyy",
"link": "https://gitee.com/zongyY11",
"money": 10.0,
"msg": "感谢您的开源项目!",
"date": "2024-06-05"
},
{
"name": "驰骋BPM",
"link": "https://gitee.com/chichengsoft",
"money": 100.0,
"msg": '感谢开源, 欢迎下载驰骋低代码BPM <a href="https://gitee.com/opencc/JFlow" target="_blank">https://gitee.com/opencc/JFlow</a>',
"date": "2024-06-11"
},
]

View File

@@ -221,7 +221,7 @@ sa-token.sign.secret-key=kQwIOrYvnXmSDkwEiFngrKidMcdrgKor
| ticketTimeout | long | 300 | ticket 有效期 (单位: 秒) |
| allowUrl | String | * | 所有允许的授权回调地址多个用逗号隔开不在此列表中的URL将禁止下放ticket参考[SSO整合配置域名校验](/sso/sso-check-domain) |
| homeRoute | String | | 主页路由:在 /sso/auth 登录后不指定 redirect 参数的情况下默认跳转的路由 |
| isSlo | Boolean | false | 是否打开单点注销功能 |
| isSlo | Boolean | true | 是否打开单点注销功能 |
| isHttp | Boolean | false | 是否打开模式三(此值为 true 时将使用 http 请求:校验 ticket 值、单点注销、获取 userinfo参考[详解](/use/config?id=配置项详解isHttp) |
| autoRenewTimeout | Bolean | false | 是否在每次下发 ticket 时,自动续期 token 的有效期(根据全局 timeout 值) |
| maxRegClient | int | 32 | 在 Access-Session 上记录 Client 信息的最高数量(-1=无限),超过此值将进行自动清退处理,先进先出 |

View File

@@ -18,8 +18,8 @@
<!-- parent 里的版本适合与 springboot2 兼容;其它更新的框架里版本容易冲突 -->
<properties>
<redisson.version>3.23.5</redisson.version>
<jackson.version>2.15.2</jackson.version>
<redisson.version>3.27.2</redisson.version>
<jackson.version>2.17.0</jackson.version>
</properties>
<dependencies>
@@ -34,6 +34,7 @@
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>${redisson.version}</version>
<exclusions>
<exclusion>
<groupId>org.yaml</groupId>