client, jsp -> html , test

pull/4/head
shengzhaoli.shengz 2023-10-16 15:46:04 +08:00
parent 9ab182e476
commit 49f40439a8
6 changed files with 196 additions and 13 deletions

View File

@ -40,6 +40,8 @@ public class ClientSettingsDto implements Serializable {
/**
* client jwk URL
* , null
* <p>
* todo: v3.0.0
*/
private String jwkSetUrl;
@ -60,7 +62,10 @@ public class ClientSettingsDto implements Serializable {
this.requireAuthorizationConsent = settings.isRequireAuthorizationConsent();
this.requireProofKey = settings.isRequireProofKey();
this.tokenEndpointAuthenticationSigningAlgorithm = settings.getTokenEndpointAuthenticationSigningAlgorithm().getName();
JwsAlgorithm jAlg = settings.getTokenEndpointAuthenticationSigningAlgorithm();
if (jAlg != null) {
this.tokenEndpointAuthenticationSigningAlgorithm = jAlg.getName();
}
this.jwkSetUrl = settings.getJwkSetUrl();
}
@ -106,4 +111,14 @@ public class ClientSettingsDto implements Serializable {
public void setTokenEndpointAuthenticationSigningAlgorithm(String tokenEndpointAuthenticationSigningAlgorithm) {
this.tokenEndpointAuthenticationSigningAlgorithm = tokenEndpointAuthenticationSigningAlgorithm;
}
@Override
public String toString() {
return "{" +
"requireProofKey=" + requireProofKey +
", requireAuthorizationConsent=" + requireAuthorizationConsent +
// ", jwkSetUrl='" + jwkSetUrl + '\'' +
", tokenEndpointAuthenticationSigningAlgorithm='" + tokenEndpointAuthenticationSigningAlgorithm + '\'' +
'}';
}
}

View File

@ -172,4 +172,17 @@ public class TokenSettingsDto implements Serializable {
public void setIdTokenSignatureAlgorithm(String idTokenSignatureAlgorithm) {
this.idTokenSignatureAlgorithm = idTokenSignatureAlgorithm;
}
@Override
public String toString() {
return "{" +
"authorizationCodeTimeToLive=" + authorizationCodeTimeToLive +
", accessTokenTimeToLive=" + accessTokenTimeToLive +
", accessTokenFormat='" + accessTokenFormat + '\'' +
", deviceCodeTimeToLive=" + deviceCodeTimeToLive +
", reuseRefreshTokens=" + reuseRefreshTokens +
", refreshTokenTimeToLive=" + refreshTokenTimeToLive +
", idTokenSignatureAlgorithm='" + idTokenSignatureAlgorithm + '\'' +
'}';
}
}

View File

@ -16,8 +16,11 @@ import java.util.List;
/**
* Handle 'client_details' management
* <p>
* v3.0.0 'RegisteredClient', table: oauth2_registered_client
*
* @author Shengzhao Li
* @see org.springframework.security.oauth2.server.authorization.client.RegisteredClient
*/
@Controller
public class ClientDetailsController {
@ -38,18 +41,18 @@ public class ClientDetailsController {
}
/*
* Logic delete
* */
/**
* Logic delete
*/
@RequestMapping("archive_client/{clientId}")
public String archiveClient(@PathVariable("clientId") String clientId) {
oauthService.archiveOauthClientDetails(clientId);
return "redirect:../client_details";
}
/*
* Test client
* */
/**
* Test client
*/
@RequestMapping("test_client/{clientId}")
public String testClient(@PathVariable("clientId") String clientId, Model model) {
OauthClientDetailsDto clientDetailsDto = oauthService.loadOauthClientDetailsDto(clientId);
@ -58,9 +61,9 @@ public class ClientDetailsController {
}
/*
* Register client
* */
/**
* Register client
*/
@RequestMapping(value = "register_client", method = RequestMethod.GET)
public String registerClient(Model model) {
model.addAttribute("formDto", new OauthClientDetailsDto());
@ -68,9 +71,9 @@ public class ClientDetailsController {
}
/*
* Submit register client
* */
/**
* Submit register client
*/
@RequestMapping(value = "register_client", method = RequestMethod.POST)
public String submitRegisterClient(@ModelAttribute("formDto") OauthClientDetailsDto formDto, BindingResult result) {
clientDetailsDtoValidator.validate(formDto, result);

View File

@ -0,0 +1,86 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,user-scalable=no"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<link rel="shortcut icon" href="../../static/favicon.ico" th:href="@{/favicon.ico}"/>
<title>client_details - Spring Security&OAuth2.1</title>
<th:block th:insert="~{fragments/main::header-css}"/>
<style>
.list-group li:hover {
background-color: #f9f9f9;
}
</style>
</head>
<body class="container">
<a th:href="@{/}">Home</a>
<div class="row">
<div class="col-md-10">
<h3>client_details</h3>
</div>
<div class="col-md-2">
<div class="pull-right">
<a th:href="@{register_client}" class="btn btn-success btn-sm">注册client</a>
</div>
</div>
</div>
<hr/>
<div>
<ul class="list-group">
<li th:each="cli:${clientDetailsDtoList}" class="list-group-item">
<div class="pull-right">
<div th:if="${not cli.archived}">
<a th:href="@{test_client/${cli.clientId}}">test</a>
<a th:href="@{archive_client/${cli.clientId}}" class="text-danger"
onclick="return confirm('Are you sure archive the client ?')">archive</a>
</div>
<strong th:if="${cli.archived}" class="text-muted">Archived</strong>
</div>
<h3 class="list-group-item-heading">
[[${cli.clientId}]] - <span th:text="${cli.clientName}" class="text-primary"></span>
<small th:text="${cli.authorizationGrantTypes}"></small>
</h3>
<div class="list-group-item-text text-muted">
client_id: <span class="text-danger" th:text="${cli.clientId}"></span>&nbsp;
client_secret: <span class="text-primary">***</span>&nbsp;
<br/>
grant_types: <span class="text-primary" th:text="${cli.authorizationGrantTypes}"></span>&nbsp;
authentication_methods: <span class="text-primary" th:text="${cli.clientAuthenticationMethods}"></span>&nbsp;
<br/>
scopes: <span class="text-primary" th:text="${cli.scopes}"></span>&nbsp;
redirect_uri: <span class="text-primary" th:text="${cli.redirectUris}"></span>&nbsp;
<br/>
client_id_issued: <span class="text-primary" th:text="${cli.clientIdIssuedAt}"></span>&nbsp;
client_secret_expires: <span class="text-primary" th:text="${cli.clientSecretExpiresAt}"></span>
<br/>
client_settings: <span class="text-primary" th:text="${cli.clientSettings}"></span>
<br/>
token_settings: <span class="text-primary" th:text="${cli.tokenSettings}"></span>
<br/>
create_time: <span class="text-primary" th:text="${cli.createTime}"></span>&nbsp;
archived: <strong th:class="${cli.archived?'text-warning':'text-primary'}"
th:text="${cli.archived}"></strong>&nbsp;
</div>
</li>
</ul>
<div class="help-block">
每一个item对应<code>oauth2_registered_client</code>表中的一条数据; 共<strong
th:text="${clientDetailsDtoList.size()}"></strong>条数据.
<br/>
对数据库表的详细说明请访问
<a href="https://andaily.com/spring-oauth-server/db_table_description_3.0.0.html" target="_blank">https://andaily.com/spring-oauth-server/db_table_description_3.0.0.html</a>
(或访问项目others目录的db_table_description.html文件)
</div>
</div>
<div th:replace="~{fragments/main :: footer}"/>
</body>
</html>

View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,user-scalable=no"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<link rel="shortcut icon" href="../../static/favicon.ico" th:href="@{/favicon.ico}"/>
<title>Mobile 资源 - Spring Security&OAuth2.1</title>
<th:block th:insert="~{fragments/main::header-css}"/>
</head>
<body class="container">
<a th:href="@{/}">Home</a>
<h2>Hi Mobile
<small>你已成功访问 [mobile] 资源</small>
</h2>
用户信息:
<br/>
<strong th:text="${#authentication.principal.username}"></strong>
<br/>
<br/>
<p class="text-info">
访问API
</p>
<a th:href="@{/m/user_info?access_token=${param.access_token}}">用户信息(JSON)</a>
<div th:replace="~{fragments/main :: footer}"/>
</body>
</html>

View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,user-scalable=no"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<link rel="shortcut icon" href="../../static/favicon.ico" th:href="@{/favicon.ico}"/>
<title>Unity 资源 - Spring Security&OAuth2.1</title>
<th:block th:insert="~{fragments/main::header-css}"/>
</head>
<body class="container">
<a th:href="@{/}">Home</a>
<h2>Hi Mobile
<small>你已成功访问 [unity] 资源</small>
</h2>
用户信息:
<br/>
<strong th:text="${#authentication.principal.username}"></strong>
<br/>
<br/>
<p class="text-info">
访问API
</p>
<a th:href="@{/unity/user_info?access_token=${param.access_token}}">用户信息(JSON)</a>
<div th:replace="~{fragments/main :: footer}"/>
</body>
</html>