1
0
mirror of synced 2026-05-22 14:43:15 +00:00

增加 state 值校验

This commit is contained in:
click33
2024-08-24 20:18:23 +08:00
parent d3b337a6a6
commit e0a609b128
5 changed files with 76 additions and 4 deletions
+14 -3
View File
@@ -30,8 +30,6 @@ OAuth2 集成常见问题整理
### 问:Sa-Token-OAuth2 怎么集成多账号模式?
`configOAuth2Server` 里指定 oauth2 模块使用的 `StpLogic` 对象即可:
@@ -45,4 +43,17 @@ public void configOAuth2Server(SaOAuth2ServerConfig oauth2Server) {
// 指定 oauth2 模块使用的 `StpLogic` 对象
SaOAuth2Manager.setStpLogic(StpUserUtil.stpLogic);
}
```
```
### 问:授权码流程中 state 参数是干吗用的?
state 参数用于验证授权码流程的发起端和接受端是否为同一个客户端,以防止OAuth-Server账号伪装攻击。
授权流程发起端必须保证:
- state 参数必须足够随机,不可被预测。
- state 参数与授权码流程发起客户端 一 一 对 应,授权流程发起时创建的 state 必须与接受时返回的 state 值一致。
- 安全起见,一个 state 参数只允许使用一次。