Add impersonation sample for token exchange

Closes gh-1604
This commit is contained in:
Steve Riesenberg
2024-05-01 17:46:12 -05:00
parent 76322dcfde
commit 1cda1ca36d
6 changed files with 51 additions and 12 deletions

View File

@@ -134,12 +134,27 @@ public class AuthorizationController {
return "index";
}
@GetMapping(value = "/authorize", params = "grant_type=token_exchange")
public String tokenExchangeGrant(Model model) {
@GetMapping(value = "/authorize", params = {"grant_type=token_exchange", "use_case=delegation"})
public String tokenExchangeGrantUsingDelegation(Model model) {
String[] messages = this.defaultClientWebClient
.get()
.uri(this.userMessagesBaseUri)
.uri(this.userMessagesBaseUri + "?use_case=delegation")
.attributes(clientRegistrationId("user-client-authorization-code"))
.retrieve()
.bodyToMono(String[].class)
.block();
model.addAttribute("messages", messages);
return "index";
}
@GetMapping(value = "/authorize", params = {"grant_type=token_exchange", "use_case=impersonation"})
public String tokenExchangeGrantUsingImpersonation(Model model) {
String[] messages = this.defaultClientWebClient
.get()
.uri(this.userMessagesBaseUri + "?use_case=impersonation")
.attributes(clientRegistrationId("user-client-authorization-code"))
.retrieve()
.bodyToMono(String[].class)

View File

@@ -27,7 +27,8 @@
<li><a class="dropdown-item" href="/authorize?grant_type=client_credentials&client_auth=client_secret" th:href="@{/authorize?grant_type=client_credentials&client_auth=client_secret}">Client Credentials (client_secret_basic)</a></li>
<li><a class="dropdown-item" href="/authorize?grant_type=client_credentials&client_auth=mtls" th:href="@{/authorize?grant_type=client_credentials&client_auth=mtls}">Client Credentials (tls_client_auth)</a></li>
<li><a class="dropdown-item" href="/authorize?grant_type=client_credentials&client_auth=self_signed_mtls" th:href="@{/authorize?grant_type=client_credentials&client_auth=self_signed_mtls}">Client Credentials (self_signed_tls_client_auth)</a></li>
<li><a class="dropdown-item" href="/authorize?grant_type=token_exchange" th:href="@{/authorize?grant_type=token_exchange}">Token Exchange</a></li>
<li><a class="dropdown-item" href="/authorize?grant_type=token_exchange" th:href="@{/authorize?grant_type=token_exchange&use_case=delegation}">Token Exchange (delegation)</a></li>
<li><a class="dropdown-item" href="/authorize?grant_type=token_exchange" th:href="@{/authorize?grant_type=token_exchange&use_case=impersonation}">Token Exchange (impersonation)</a></li>
<li><a class="dropdown-item" href="/authorize?grant_type=device_code" th:href="@{/authorize?grant_type=device_code}">Device Code</a></li>
</ul>
</li>