From 18a8ed3e9562ef8677d23261eb95670f43ba4769 Mon Sep 17 00:00:00 2001 From: Thomas Darimont Date: Fri, 24 Feb 2017 13:51:31 +0100 Subject: [PATCH] KEYCLOAK-4505 Expose current clientSession binding to ScriptBasedAuthenticator. Previously the ScriptBasedAuthenticator did not expose the current clientSession from the AuthenticationFlowContext. In order to implement client specific authentications with javascript one needs information about the current client. --- .../authenticators/browser/ScriptBasedAuthenticator.java | 2 ++ services/src/main/resources/scripts/authenticator-template.js | 1 + 2 files changed, 3 insertions(+) diff --git a/services/src/main/java/org/keycloak/authentication/authenticators/browser/ScriptBasedAuthenticator.java b/services/src/main/java/org/keycloak/authentication/authenticators/browser/ScriptBasedAuthenticator.java index 6ab290791b..0b400f07ac 100644 --- a/services/src/main/java/org/keycloak/authentication/authenticators/browser/ScriptBasedAuthenticator.java +++ b/services/src/main/java/org/keycloak/authentication/authenticators/browser/ScriptBasedAuthenticator.java @@ -47,6 +47,7 @@ import java.util.Map; *
  • {@code realm} the {@link RealmModel}
  • *
  • {@code user} the current {@link UserModel}
  • *
  • {@code session} the active {@link KeycloakSession}
  • + *
  • {@code clientSession} the current {@link org.keycloak.models.ClientSessionModel}
  • *
  • {@code httpRequest} the current {@link org.jboss.resteasy.spi.HttpRequest}
  • *
  • {@code LOG} a {@link org.jboss.logging.Logger} scoped to {@link ScriptBasedAuthenticator}/li> * @@ -159,6 +160,7 @@ public class ScriptBasedAuthenticator implements Authenticator { bindings.put("user", context.getUser()); bindings.put("session", context.getSession()); bindings.put("httpRequest", context.getHttpRequest()); + bindings.put("clientSession", context.getClientSession()); bindings.put("LOG", LOGGER); }); } diff --git a/services/src/main/resources/scripts/authenticator-template.js b/services/src/main/resources/scripts/authenticator-template.js index 20de702721..f18dfdf0e3 100644 --- a/services/src/main/resources/scripts/authenticator-template.js +++ b/services/src/main/resources/scripts/authenticator-template.js @@ -15,6 +15,7 @@ AuthenticationFlowError = Java.type("org.keycloak.authentication.AuthenticationF * session - current KeycloakSession {@see org.keycloak.models.KeycloakSession} * httpRequest - current HttpRequest {@see org.jboss.resteasy.spi.HttpRequest} * script - current script {@see org.keycloak.models.ScriptModel} + * clientSession - current client session {@see org.keycloak.models.ClientSessionModel} * LOG - current logger {@see org.jboss.logging.Logger} * * You one can extract current http request headers via: