From 8235fe7633e2c5035885ed3bd7413d6c10d54d5f Mon Sep 17 00:00:00 2001 From: click33 <2393584716@qq.com> Date: Sat, 24 Aug 2024 17:02:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20oauth2=20=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=B8=B8=E8=A7=81=E9=97=AE=E7=AD=94=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sa-token-doc/_sidebar.md | 2 +- sa-token-doc/oauth2/oauth2-questions.md | 48 +++++++++++++++++++++++++ sa-token-doc/use/config.md | 1 + 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 sa-token-doc/oauth2/oauth2-questions.md diff --git a/sa-token-doc/_sidebar.md b/sa-token-doc/_sidebar.md index eaa5c341..f11153ff 100644 --- a/sa-token-doc/_sidebar.md +++ b/sa-token-doc/_sidebar.md @@ -64,7 +64,7 @@ - [开启 OIDC 协议](/oauth2/oauth2-oidc) - [OAuth2-与登录会话实现数据互通](/oauth2/oauth2-interworking) - [OAuth2 代码 API 参考](/oauth2/oauth2-dev) - + - [常见问题总结](/oauth2/oauth2-questions) - diff --git a/sa-token-doc/oauth2/oauth2-questions.md b/sa-token-doc/oauth2/oauth2-questions.md new file mode 100644 index 00000000..0b92e069 --- /dev/null +++ b/sa-token-doc/oauth2/oauth2-questions.md @@ -0,0 +1,48 @@ +# Sa-Token-OAuth2整合-常见问题总结 + +OAuth2 集成常见问题整理 + +[[toc]] + +--- + + +### 问:搭建好 oauth2-server 服务后,访问返回:`{"msg": "not handle"}`。 + +返回这个信息,代表你访问的路由有错误,比如说: + +- 统一认证登录地址是:`http://{host}:{port}/oauth2/authorize`。 +- 而你访问的却是:`http://{host}:{port}/oauth2/authorize2`。 + +地址写错了,框架就不会处理这个请求,会直接返回 `{"msg": "not handle"}`,所有开放地址可参考:[SSO 开放接口](/oauth2/oauth2-apidoc) + +如果仔细检查地址后没有写错,却依然返回了这个信息,那有可能是对应的接口没有打开,比如说: + +- sso-server 端的单点注销地址:`http://{host}:{port}/sso/signout`; +- sso-client 端的注销地址:`http://{host}:{port}/sso/logout`; + +都需要在配置文件配置:`sa-token.sso.is-slo=true`后,才会打开。 + + + +### 问:我参照文档搭建 oauth2-server,一直提示:code 无效,请问怎么回事? +一个 code 码只能使用一次,多次使用就会报这个错。 + + + + + +### 问:Sa-Token-OAuth2 怎么集成多账号模式? + +在 `configOAuth2Server` 里指定 oauth2 模块使用的 `StpLogic` 对象即可: + +``` java +// Sa-Token OAuth2 定制化配置 +@Autowired +public void configOAuth2Server(SaOAuth2ServerConfig oauth2Server) { + // 其它配置 ... + + // 指定 oauth2 模块使用的 `StpLogic` 对象 + SaOAuth2Manager.setStpLogic(StpUserUtil.stpLogic); +} +``` \ No newline at end of file diff --git a/sa-token-doc/use/config.md b/sa-token-doc/use/config.md index 210175e7..aa081436 100644 --- a/sa-token-doc/use/config.md +++ b/sa-token-doc/use/config.md @@ -310,6 +310,7 @@ sa-token.sso-client.is-slo=true | higherScope | String | | 指定高级权限,多个用逗号隔开 | | lowerScope | String | | 指定低级权限,多个用逗号隔开 | | mode4ReturnAccessToken | Boolean | false | 模式4是否返回 AccessToken 字段,用于兼容OAuth2标准协议 | +| hideStatusField | Boolean | false | 是否在返回值中隐藏默认的状态字段 (code、msg、data) | | oidc | SaOAuth2OidcConfig | new SaOAuth2OidcConfig() | OIDC 相关配置 | 配置示例: