client, jsp -> html , test flow

pull/4/head
shengzhaoli.shengz 2023-10-16 20:28:12 +08:00
parent 10853f03c7
commit 0ea8e76328
2 changed files with 48 additions and 23 deletions

View File

@ -124,7 +124,7 @@
<label class="checkbox-inline"> <label class="checkbox-inline">
<input type="checkbox" th:name="authorizationGrantTypes" th:value="password" <input type="checkbox" th:name="authorizationGrantTypes" th:value="password"
th:field="*{authorizationGrantTypes}"/> password <em th:field="*{authorizationGrantTypes}"/> password <em
class="label label-danger">不推荐使用</em> class="label label-danger">OAuth2.1不支持</em>
</label> </label>
<label class="checkbox-inline"> <label class="checkbox-inline">
<input type="checkbox" th:name="authorizationGrantTypes" <input type="checkbox" th:name="authorizationGrantTypes"

View File

@ -23,7 +23,7 @@
</p> </p>
<div ng-controller="TestClientCtrl"> <div ng-controller="TestClientCtrl">
<div class="well well-sm"> <div class="alert alert-info">
请先输入client_secret: <input type="text" value="" placeholder="client_secret" ng-model="clientSecret" 请先输入client_secret: <input type="text" value="" placeholder="client_secret" ng-model="clientSecret"
size="100" required="required"/> size="100" required="required"/>
</div> </div>
@ -34,17 +34,24 @@
<p class="text-muted">输入每一步必要的信息后点击其下面的链接地址.</p> <p class="text-muted">输入每一步必要的信息后点击其下面的链接地址.</p>
<ol> <ol>
<li> <li>
<p> <div>
<code>从 spring-oauth-server获取 'code'</code> <code>从 spring-oauth-server获取 'code'</code>
<br/> <br/>
redirect_uri: <input type="text" value="" ng-model="redirectUri" size="70" redirect_uri: <input type="text" value="" ng-model="redirectUri" size="70"
required="required"/> required="required"/>
<br/> <br/>
<a href="${contextPath}/oauth/authorize?client_id={{clientId}}&redirect_uri={{redirectUri}}&response_type=code&scope={{scope}}" <form th:action="@{/oauth2/authorize}" th:method="get">
target="_blank"> <input type="hidden" name="client_id" value="{{clientId}}"/>
/oauth/authorize?client_id={{clientId}}&redirect_uri={{redirectUri}}&response_type=code&scope={{scope}}</a> <input type="hidden" name="redirect_uri" value="{{redirectUri}}"/>
<input type="hidden" name="scope" value="{{scope}}"/>
<input type="hidden" name="state" value="{{state}}"/>
<input type="hidden" name="response_type" value="code"/>
<button class="btn btn-link" type="submit">
/oauth2/authorize?client_id={{clientId}}&redirect_uri={{redirectUri}}&response_type=code&scope={{scope}}&state={{state}}
</button>
</form>
<span class="label label-info">GET</span> <span class="label label-info">GET</span>
</p> </div>
</li> </li>
<li> <li>
<code>用 'code' 换取 'access_token'</code> <code>用 'code' 换取 'access_token'</code>
@ -53,10 +60,14 @@
required="required"/> required="required"/>
<br/> <br/>
<form action="${contextPath}/oauth/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=authorization_code&code={{code}}&redirect_uri={{redirectUri}}" <form th:action="@{/oauth2/token}" th:method="post" target="_blank">
method="post" target="_blank"> <input type="hidden" name="client_id" value="{{clientId}}"/>
<input type="hidden" name="redirect_uri" value="{{redirectUri}}"/>
<input type="hidden" name="client_secret" value="{{clientSecret}}"/>
<input type="hidden" name="code" value="{{code}}"/>
<input type="hidden" name="grant_type" value="authorization_code"/>
<button class="btn btn-link" type="submit"> <button class="btn btn-link" type="submit">
/oauth/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=authorization_code&code={{code}}&redirect_uri={{redirectUri}} /oauth2/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=authorization_code&code={{code}}&redirect_uri={{redirectUri}}
</button> </button>
<span class="label label-warning">POST</span> <span class="label label-warning">POST</span>
</form> </form>
@ -66,7 +77,7 @@
</div> </div>
<div th:if="${clientDetailsDto.containsPassword}" class="panel panel-default"> <div th:if="${clientDetailsDto.containsPassword}" class="panel panel-default">
<div class="panel-heading">Test [password]</div> <div class="panel-heading">Test [password] <em class="label label-danger">OAuth2.1不支持</em></div>
<div class="panel-body"> <div class="panel-body">
<p class="text-muted">输入username, password 后点击链接地址.</p> <p class="text-muted">输入username, password 后点击链接地址.</p>
username: <input type="text" required="required" ng-model="username"/> username: <input type="text" required="required" ng-model="username"/>
@ -75,10 +86,15 @@
<br/> <br/>
<form action="${contextPath}/oauth/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=password&scope={{scope}}&username={{username}}&password={{password}}" <form th:action="@{/oauth2/token}" th:method="post" target="_blank">
method="post" target="_blank"> <input type="hidden" name="client_id" value="{{clientId}}"/>
<input type="hidden" name="redirect_uri" value="{{redirectUri}}"/>
<input type="hidden" name="username" value="{{username}}"/>
<input type="hidden" name="password" value="{{password}}"/>
<input type="hidden" name="scope" value="{{scope}}"/>
<input type="hidden" name="grant_type" value="password"/>
<button class="btn btn-link" type="submit"> <button class="btn btn-link" type="submit">
/oauth/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=password&scope={{scope}}&username={{username}}&password={{password}} /oauth2/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=password&scope={{scope}}&username={{username}}&password={{password}}
</button> </button>
<span class="label label-warning">POST</span> <span class="label label-warning">POST</span>
</form> </form>
@ -92,12 +108,20 @@
redirect_uri: <input type="text" value="" ng-model="implicitRedirectUri" size="70" redirect_uri: <input type="text" value="" ng-model="implicitRedirectUri" size="70"
required="required"/> required="required"/>
<p> <div>
<a href="${contextPath}/oauth/authorize?client_id={{clientId}}&client_secret={{clientSecret}}&response_type=token&scope={{scope}}&redirect_uri={{implicitRedirectUri}}" <form th:action="@{/oauth2/authorize}" th:method="get" target="_blank">
target="_blank" <input type="hidden" name="client_id" value="{{clientId}}"/>
>/oauth/authorize?client_id={{clientId}}&client_secret={{clientSecret}}&response_type=token&scope={{scope}}&redirect_uri={{implicitRedirectUri}}</a> <input type="hidden" name="client_secret" value="{{clientSecret}}"/>
<input type="hidden" name="redirect_uri" value="{{implicitRedirectUri}}"/>
<input type="hidden" name="scope" value="{{scope}}"/>
<input type="hidden" name="response_type" value="token"/>
<button class="btn btn-link" type="submit">
/oauth2/authorize?client_id={{clientId}}&client_secret={{clientSecret}}&response_type=token&scope={{scope}}&redirect_uri={{implicitRedirectUri}}
</button>
<span class="label label-warning">POST</span>
</form>
<span class="label label-info">GET</span> <span class="label label-info">GET</span>
</p> </div>
</div> </div>
</div> </div>
@ -113,7 +137,7 @@
<input type="hidden" name="scope" value="{{scope}}"/> <input type="hidden" name="scope" value="{{scope}}"/>
<input type="hidden" name="grant_type" value="client_credentials"/> <input type="hidden" name="grant_type" value="client_credentials"/>
<button class="btn btn-link" type="submit"> <button class="btn btn-link" type="submit">
/oauth/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=client_credentials&scope={{scope}} /oauth2/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=client_credentials&scope={{scope}}
</button> </button>
<span class="label label-warning">POST</span> <span class="label label-warning">POST</span>
</form> </form>
@ -134,7 +158,7 @@
<input type="hidden" name="refresh_token" value="{{refreshToken}}"/> <input type="hidden" name="refresh_token" value="{{refreshToken}}"/>
<input type="hidden" name="grant_type" value="refresh_token"/> <input type="hidden" name="grant_type" value="refresh_token"/>
<button class="btn btn-link" type="submit"> <button class="btn btn-link" type="submit">
/oauth/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=refresh_token&refresh_token={{refreshToken}} /oauth2/token?client_id={{clientId}}&client_secret={{clientSecret}}&grant_type=refresh_token&refresh_token={{refreshToken}}
</button> </button>
<span class="label label-warning">POST</span> <span class="label label-warning">POST</span>
</form> </form>
@ -155,10 +179,10 @@
var redirectUri = [[${clientDetailsDto.redirectUris}]]; var redirectUri = [[${clientDetailsDto.redirectUris}]];
if (redirectUri === '') { if (redirectUri === '') {
// $scope.implicitRedirectUri = location.href; $scope.implicitRedirectUri = location.href;
$scope.redirectUri = "http://localhost:8080/unity/dashboard"; $scope.redirectUri = "http://localhost:8080/unity/dashboard";
} else { } else {
// $scope.implicitRedirectUri = "${clientDetailsDto.webServerRedirectUri}"; $scope.implicitRedirectUri = [[${clientDetailsDto.redirectUris}]];
$scope.redirectUri = [[${clientDetailsDto.redirectUris}]]; $scope.redirectUri = [[${clientDetailsDto.redirectUris}]];
} }
@ -166,6 +190,7 @@
$scope.password = "mobile"; $scope.password = "mobile";
//a temp value //a temp value
$scope.refreshToken = "xYCsaPu7YV_hB6TfLbWsFBws1YvP7D_qAJFlSCvT5u-RbP6uMwEudHZaVnoyw3wuaXO-8F3t_GY"; $scope.refreshToken = "xYCsaPu7YV_hB6TfLbWsFBws1YvP7D_qAJFlSCvT5u-RbP6uMwEudHZaVnoyw3wuaXO-8F3t_GY";
$scope.state = Math.floor(Math.random() * 1000000000).toString();
}]; }];
</script> </script>