diff --git a/src/main/java/com/monkeyk/sos/domain/dto/OauthClientDetailsDto.java b/src/main/java/com/monkeyk/sos/domain/dto/OauthClientDetailsDto.java index 137c0bd..e0e3d0c 100644 --- a/src/main/java/com/monkeyk/sos/domain/dto/OauthClientDetailsDto.java +++ b/src/main/java/com/monkeyk/sos/domain/dto/OauthClientDetailsDto.java @@ -1,6 +1,7 @@ package com.monkeyk.sos.domain.dto; import com.monkeyk.sos.domain.oauth.OauthClientDetails; +import com.monkeyk.sos.domain.shared.GuidGenerator; import com.monkeyk.sos.infrastructure.DateUtils; import org.apache.commons.lang.StringUtils; @@ -14,13 +15,14 @@ import java.util.List; public class OauthClientDetailsDto implements Serializable { + private static final long serialVersionUID = -690401014127462329L; private String createTime; private boolean archived; - private String clientId; + private String clientId = GuidGenerator.generate(); private String resourceIds; - private String clientSecret; + private String clientSecret = GuidGenerator.generateClientSecret(); private String scope; diff --git a/src/main/java/com/monkeyk/sos/domain/shared/GuidGenerator.java b/src/main/java/com/monkeyk/sos/domain/shared/GuidGenerator.java index 799ac54..29fdad6 100644 --- a/src/main/java/com/monkeyk/sos/domain/shared/GuidGenerator.java +++ b/src/main/java/com/monkeyk/sos/domain/shared/GuidGenerator.java @@ -1,5 +1,7 @@ package com.monkeyk.sos.domain.shared; +import org.springframework.security.oauth2.common.util.RandomValueStringGenerator; + import java.util.UUID; /** @@ -7,6 +9,7 @@ import java.util.UUID; */ public abstract class GuidGenerator { + private static RandomValueStringGenerator defaultClientSecretGenerator = new RandomValueStringGenerator(32); /** * private constructor @@ -17,4 +20,9 @@ public abstract class GuidGenerator { public static String generate() { return UUID.randomUUID().toString().replaceAll("-", ""); } + + + public static String generateClientSecret() { + return defaultClientSecretGenerator.generate(); + } } \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/clientdetails/register_client.jsp b/src/main/webapp/WEB-INF/jsp/clientdetails/register_client.jsp index 949f15e..87ed799 100644 --- a/src/main/webapp/WEB-INF/jsp/clientdetails/register_client.jsp +++ b/src/main/webapp/WEB-INF/jsp/clientdetails/register_client.jsp @@ -20,14 +20,14 @@

注册client

-

- 若对Oauth的client_details中的属性及作用不清楚, - 建议你先查看项目中的db_table_description.html文件(位于others目录)中对表oauth_client_details的说明, - 或在线访问db_table_description.html; - 因为注册client实际上是向该表中按不同的条件添加数据. -

+

+ 若对Oauth的client_details中的属性及作用不清楚, + 建议你先查看项目中的db_table_description.html文件(位于others目录)中对表oauth_client_details的说明, + 或在线访问db_table_description.html; + 因为注册client实际上是向该表中按不同的条件添加数据. +

-
+
@@ -110,7 +110,9 @@ refresh_token -

至少勾选一项grant_type(s), 且不能只单独勾选refresh_token

+

至少勾选一项grant_type(s), 且不能只单独勾选refresh_token, 若需更多帮助请访问 https://andaily.com/blog/?p=103

diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 70abd06..8eaf159 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -32,13 +32,17 @@
  • 菜单 Unity 与 Mobile 需要Oauth 验证后才能访问(即受保护的resource);
    - Unity 需要 [ROLE_UNITY] 权限, Mobile 需要 [ROLE_MOBILE] 权限. + Unity 需要 [ROLE_UNITY] 权限(resourceId: + unity-resource + ), Mobile 需要 [ROLE_MOBILE] 权限(resourceId: + mobile-resource + ).

  • 在使用之前, 建议先了解OAuth2支持的5类grant_type, 请访问 https://andaily.com/blog/?p=103 + target="_blank">https://andaily.com/blog/?p=103