Commit 6b79788b5aebdd7fd0d3a5ec663c5a0a3778dd86

Authored by YunaiV
1 parent bf700ab1

完善 oauth2.0 的注释

yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenController.java
@@ -106,7 +106,7 @@ public class OAuth2OpenController { @@ -106,7 +106,7 @@ public class OAuth2OpenController {
106 @RequestParam(value = "scope", required = false) String scope, // 密码模式 106 @RequestParam(value = "scope", required = false) String scope, // 密码模式
107 @RequestParam(value = "refresh_token", required = false) String refreshToken) { // 刷新模式 107 @RequestParam(value = "refresh_token", required = false) String refreshToken) { // 刷新模式
108 List<String> scopes = OAuth2Utils.buildScopes(scope); 108 List<String> scopes = OAuth2Utils.buildScopes(scope);
109 - // 授权类型 109 + // 1.1 校验授权类型
110 OAuth2GrantTypeEnum grantTypeEnum = OAuth2GrantTypeEnum.getByGranType(grantType); 110 OAuth2GrantTypeEnum grantTypeEnum = OAuth2GrantTypeEnum.getByGranType(grantType);
111 if (grantTypeEnum == null) { 111 if (grantTypeEnum == null) {
112 throw exception0(BAD_REQUEST.getCode(), StrUtil.format("未知授权类型({})", grantType)); 112 throw exception0(BAD_REQUEST.getCode(), StrUtil.format("未知授权类型({})", grantType));
@@ -115,12 +115,12 @@ public class OAuth2OpenController { @@ -115,12 +115,12 @@ public class OAuth2OpenController {
115 throw exception0(BAD_REQUEST.getCode(), "Token 接口不支持 implicit 授权模式"); 115 throw exception0(BAD_REQUEST.getCode(), "Token 接口不支持 implicit 授权模式");
116 } 116 }
117 117
118 - // 校验客户端 118 + // 1.2 校验客户端
119 String[] clientIdAndSecret = obtainBasicAuthorization(request); 119 String[] clientIdAndSecret = obtainBasicAuthorization(request);
120 OAuth2ClientDO client = oauth2ClientService.validOAuthClientFromCache(clientIdAndSecret[0], clientIdAndSecret[1], 120 OAuth2ClientDO client = oauth2ClientService.validOAuthClientFromCache(clientIdAndSecret[0], clientIdAndSecret[1],
121 grantType, scopes, redirectUri); 121 grantType, scopes, redirectUri);
122 122
123 - // 根据授权模式,获取访问令牌 123 + // 2. 根据授权模式,获取访问令牌
124 OAuth2AccessTokenDO accessTokenDO; 124 OAuth2AccessTokenDO accessTokenDO;
125 switch (grantTypeEnum) { 125 switch (grantTypeEnum) {
126 case AUTHORIZATION_CODE: 126 case AUTHORIZATION_CODE:
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/oauth2/OAuth2GrantService.java
@@ -12,7 +12,7 @@ import java.util.List; @@ -12,7 +12,7 @@ import java.util.List;
12 * 将自身的 AdminUser 用户,授权给第三方应用,采用 OAuth2.0 的协议。 12 * 将自身的 AdminUser 用户,授权给第三方应用,采用 OAuth2.0 的协议。
13 * 13 *
14 * 问题:为什么自身也作为一个第三方应用,也走这套流程呢? 14 * 问题:为什么自身也作为一个第三方应用,也走这套流程呢?
15 - * 回复:当然可以这么做,采用 Implicit 模式。考虑到大多数开发者使用不到这个特性,OAuth2.0 毕竟有一定学习成本,所以暂时没有采取这种方式。 15 + * 回复:当然可以这么做,采用 password 模式。考虑到大多数开发者使用不到这个特性,OAuth2.0 毕竟有一定学习成本,所以暂时没有采取这种方式。
16 * 16 *
17 * @author 芋道源码 17 * @author 芋道源码
18 */ 18 */
yudao-ui-admin/src/views/sso.vue
@@ -57,7 +57,6 @@ export default { @@ -57,7 +57,6 @@ export default {
57 name: "Login", 57 name: "Login",
58 data() { 58 data() {
59 return { 59 return {
60 - tenantEnable: true,  
61 loginForm: { 60 loginForm: {
62 scopes: [], // 已选中的 scope 数组 61 scopes: [], // 已选中的 scope 数组
63 }, 62 },