Add more description; default client_id, client_secret generate

0.5
LSZ 2016-05-31 00:35:08 +08:00
parent 5d8ce06f3b
commit c0b0cf4529
4 changed files with 28 additions and 12 deletions

View File

@ -1,6 +1,7 @@
package com.monkeyk.sos.domain.dto; package com.monkeyk.sos.domain.dto;
import com.monkeyk.sos.domain.oauth.OauthClientDetails; import com.monkeyk.sos.domain.oauth.OauthClientDetails;
import com.monkeyk.sos.domain.shared.GuidGenerator;
import com.monkeyk.sos.infrastructure.DateUtils; import com.monkeyk.sos.infrastructure.DateUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -14,13 +15,14 @@ import java.util.List;
public class OauthClientDetailsDto implements Serializable { public class OauthClientDetailsDto implements Serializable {
private static final long serialVersionUID = -690401014127462329L;
private String createTime; private String createTime;
private boolean archived; private boolean archived;
private String clientId; private String clientId = GuidGenerator.generate();
private String resourceIds; private String resourceIds;
private String clientSecret; private String clientSecret = GuidGenerator.generateClientSecret();
private String scope; private String scope;

View File

@ -1,5 +1,7 @@
package com.monkeyk.sos.domain.shared; package com.monkeyk.sos.domain.shared;
import org.springframework.security.oauth2.common.util.RandomValueStringGenerator;
import java.util.UUID; import java.util.UUID;
/** /**
@ -7,6 +9,7 @@ import java.util.UUID;
*/ */
public abstract class GuidGenerator { public abstract class GuidGenerator {
private static RandomValueStringGenerator defaultClientSecretGenerator = new RandomValueStringGenerator(32);
/** /**
* private constructor * private constructor
@ -17,4 +20,9 @@ public abstract class GuidGenerator {
public static String generate() { public static String generate() {
return UUID.randomUUID().toString().replaceAll("-", ""); return UUID.randomUUID().toString().replaceAll("-", "");
} }
public static String generateClientSecret() {
return defaultClientSecretGenerator.generate();
}
} }

View File

@ -20,14 +20,14 @@
<h2>注册client</h2> <h2>注册client</h2>
<div ng-app> <div ng-app>
<p class="help-block"> <p class="help-block">
若对Oauth的<code>client_details</code>中的属性及作用不清楚, 若对Oauth的<code>client_details</code>中的属性及作用不清楚,
建议你先查看项目中的<code>db_table_description.html</code>文件(位于others目录)中对表<code>oauth_client_details</code>的说明, 建议你先查看项目中的<code>db_table_description.html</code>文件(位于others目录)中对表<code>oauth_client_details</code>的说明,
或在线访问<a href="http://andaily.com/spring-oauth-server/db_table_description.html" target="_blank">db_table_description.html</a>; 或在线访问<a href="http://andaily.com/spring-oauth-server/db_table_description.html" target="_blank">db_table_description.html</a>;
因为注册client实际上是向该表中按不同的条件添加数据. 因为注册client实际上是向该表中按不同的条件添加数据.
</p> </p>
<div ng-controller="RegisterClientCtrl"> <div ng-controller="RegisterClientCtrl">
<form:form commandName="formDto" cssClass="form-horizontal"> <form:form commandName="formDto" cssClass="form-horizontal">
<div class="form-group"> <div class="form-group">
<label for="clientId" class="col-sm-2 control-label">client_id<em class="text-danger">*</em></label> <label for="clientId" class="col-sm-2 control-label">client_id<em class="text-danger">*</em></label>
@ -110,7 +110,9 @@
refresh_token refresh_token
</label> </label>
<p class="help-block">至少勾选一项grant_type(s), 且不能只单独勾选<code>refresh_token</code></p> <p class="help-block">至少勾选一项grant_type(s), 且不能只单独勾选<code>refresh_token</code>, 若需更多帮助请访问 <a
href="https://andaily.com/blog/?p=103"
target="_blank">https://andaily.com/blog/?p=103</a></p>
</div> </div>
</div> </div>

View File

@ -32,13 +32,17 @@
<li> <li>
<p> <p>
菜单 Unity 与 Mobile 需要Oauth 验证后才能访问(即受保护的resource); <br/> 菜单 Unity 与 Mobile 需要Oauth 验证后才能访问(即受保护的resource); <br/>
Unity 需要 [ROLE_UNITY] 权限, Mobile 需要 [ROLE_MOBILE] 权限. Unity 需要 [ROLE_UNITY] 权限(resourceId:
<mark>unity-resource</mark>
), Mobile 需要 [ROLE_MOBILE] 权限(resourceId:
<mark>mobile-resource</mark>
).
</p> </p>
</li> </li>
<li> <li>
<p> <p>
在使用之前, 建议先了解OAuth2支持的5类<code>grant_type</code>, 请访问 <a href="https://andaily.com/blog/?p=103" 在使用之前, 建议先了解OAuth2支持的5类<code>grant_type</code>, 请访问 <a href="https://andaily.com/blog/?p=103"
target="_blank">https://andaily.com/blog/?p=103</a> target="_blank">https://andaily.com/blog/?p=103</a>
</p> </p>
</li> </li>
<li> <li>