From c70b4eaadea4655e2b2bd2c492749cca47c4748d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Tue, 6 Sep 2022 21:31:04 +0200 Subject: [PATCH] keycloak-admin-client: Provide logout method to TokenService --- .../keycloak/admin/client/token/TokenManager.java | 15 +++++++++++++++ .../keycloak/admin/client/token/TokenService.java | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java index 9e0f297d4d..38c8547034 100644 --- a/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java +++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java @@ -126,6 +126,21 @@ public class TokenManager { } } + public synchronized void logout() { + if (currentToken.getRefreshToken() == null) { + return; + } + + Form form = new Form().param(REFRESH_TOKEN, currentToken.getRefreshToken()); + + if (config.isPublicClient()) { + form.param(CLIENT_ID, config.getClientId()); + } + + tokenService.logout(config.getRealm(), form.asMap()); + currentToken = null; + } + public synchronized void setMinTokenValidity(long minTokenValidity) { this.minTokenValidity = minTokenValidity; } diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenService.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenService.java index 0cedec6b01..91a921fc87 100755 --- a/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenService.java +++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenService.java @@ -42,4 +42,8 @@ public interface TokenService { @Path("/realms/{realm}/protocol/openid-connect/token") AccessTokenResponse refreshToken(@PathParam("realm") String realm, MultivaluedMap map); + @POST + @Path("/realms/{realm}/protocol/openid-connect/logout") + void logout(@PathParam("realm") String realm, MultivaluedMap map); + }