keycloak-admin-client: Provide logout method to TokenService

This commit is contained in:
Jan-Otto Kröpke 2022-09-06 21:31:04 +02:00 committed by GitHub
parent 68a07465a6
commit c70b4eaade
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -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) { public synchronized void setMinTokenValidity(long minTokenValidity) {
this.minTokenValidity = minTokenValidity; this.minTokenValidity = minTokenValidity;
} }

View file

@ -42,4 +42,8 @@ public interface TokenService {
@Path("/realms/{realm}/protocol/openid-connect/token") @Path("/realms/{realm}/protocol/openid-connect/token")
AccessTokenResponse refreshToken(@PathParam("realm") String realm, MultivaluedMap<String, String> map); AccessTokenResponse refreshToken(@PathParam("realm") String realm, MultivaluedMap<String, String> map);
@POST
@Path("/realms/{realm}/protocol/openid-connect/logout")
void logout(@PathParam("realm") String realm, MultivaluedMap<String, String> map);
} }