完善 oauth2.0 的注释

This commit is contained in:
YunaiV
2022-10-06 20:00:38 +08:00
parent bf700ab1fc
commit 6b79788b5a
3 changed files with 4 additions and 5 deletions

View File

@ -106,7 +106,7 @@ public class OAuth2OpenController {
@RequestParam(value = "scope", required = false) String scope, // 密码模式 @RequestParam(value = "scope", required = false) String scope, // 密码模式
@RequestParam(value = "refresh_token", required = false) String refreshToken) { // 刷新模式 @RequestParam(value = "refresh_token", required = false) String refreshToken) { // 刷新模式
List<String> scopes = OAuth2Utils.buildScopes(scope); List<String> scopes = OAuth2Utils.buildScopes(scope);
// 授权类型 // 1.1 校验授权类型
OAuth2GrantTypeEnum grantTypeEnum = OAuth2GrantTypeEnum.getByGranType(grantType); OAuth2GrantTypeEnum grantTypeEnum = OAuth2GrantTypeEnum.getByGranType(grantType);
if (grantTypeEnum == null) { if (grantTypeEnum == null) {
throw exception0(BAD_REQUEST.getCode(), StrUtil.format("未知授权类型({})", grantType)); throw exception0(BAD_REQUEST.getCode(), StrUtil.format("未知授权类型({})", grantType));
@ -115,12 +115,12 @@ public class OAuth2OpenController {
throw exception0(BAD_REQUEST.getCode(), "Token 接口不支持 implicit 授权模式"); throw exception0(BAD_REQUEST.getCode(), "Token 接口不支持 implicit 授权模式");
} }
// 校验客户端 // 1.2 校验客户端
String[] clientIdAndSecret = obtainBasicAuthorization(request); String[] clientIdAndSecret = obtainBasicAuthorization(request);
OAuth2ClientDO client = oauth2ClientService.validOAuthClientFromCache(clientIdAndSecret[0], clientIdAndSecret[1], OAuth2ClientDO client = oauth2ClientService.validOAuthClientFromCache(clientIdAndSecret[0], clientIdAndSecret[1],
grantType, scopes, redirectUri); grantType, scopes, redirectUri);
// 根据授权模式,获取访问令牌 // 2. 根据授权模式,获取访问令牌
OAuth2AccessTokenDO accessTokenDO; OAuth2AccessTokenDO accessTokenDO;
switch (grantTypeEnum) { switch (grantTypeEnum) {
case AUTHORIZATION_CODE: case AUTHORIZATION_CODE:

View File

@ -12,7 +12,7 @@ import java.util.List;
* 将自身的 AdminUser 用户,授权给第三方应用,采用 OAuth2.0 的协议。 * 将自身的 AdminUser 用户,授权给第三方应用,采用 OAuth2.0 的协议。
* *
* 问题:为什么自身也作为一个第三方应用,也走这套流程呢? * 问题:为什么自身也作为一个第三方应用,也走这套流程呢?
* 回复:当然可以这么做,采用 Implicit 模式。考虑到大多数开发者使用不到这个特性OAuth2.0 毕竟有一定学习成本,所以暂时没有采取这种方式。 * 回复:当然可以这么做,采用 password 模式。考虑到大多数开发者使用不到这个特性OAuth2.0 毕竟有一定学习成本,所以暂时没有采取这种方式。
* *
* @author 芋道源码 * @author 芋道源码
*/ */

View File

@ -57,7 +57,6 @@ export default {
name: "Login", name: "Login",
data() { data() {
return { return {
tenantEnable: true,
loginForm: { loginForm: {
scopes: [], // 已选中的 scope 数组 scopes: [], // 已选中的 scope 数组
}, },