Search in sources :

Example 1 with StickySessionEncoderProvider

use of org.keycloak.sessions.StickySessionEncoderProvider in project keycloak by keycloak.

the class AuthenticationSessionManager method setAuthSessionCookie.

/**
 * @param authSessionId decoded authSessionId (without route info attached)
 * @param realm
 */
public void setAuthSessionCookie(String authSessionId, RealmModel realm) {
    UriInfo uriInfo = session.getContext().getUri();
    String cookiePath = AuthenticationManager.getRealmCookiePath(realm, uriInfo);
    boolean sslRequired = realm.getSslRequired().isRequired(session.getContext().getConnection());
    StickySessionEncoderProvider encoder = session.getProvider(StickySessionEncoderProvider.class);
    String encodedAuthSessionId = encoder.encodeSessionId(authSessionId);
    CookieHelper.addCookie(AUTH_SESSION_ID, encodedAuthSessionId, cookiePath, null, null, -1, sslRequired, true, SameSiteAttributeValue.NONE);
    log.debugf("Set AUTH_SESSION_ID cookie with value %s", encodedAuthSessionId);
}
Also used : UriInfo(javax.ws.rs.core.UriInfo) StickySessionEncoderProvider(org.keycloak.sessions.StickySessionEncoderProvider)

Example 2 with StickySessionEncoderProvider

use of org.keycloak.sessions.StickySessionEncoderProvider in project keycloak by keycloak.

the class AuthenticationSessionManager method decodeAuthSessionId.

/**
 * @param encodedAuthSessionId encoded ID with attached route in cluster environment (EG. "5e161e00-d426-4ea6-98e9-52eb9844e2d7.node1" )
 * @return object with decoded and actually encoded authSessionId
 */
AuthSessionId decodeAuthSessionId(String encodedAuthSessionId) {
    log.debugf("Found AUTH_SESSION_ID cookie with value %s", encodedAuthSessionId);
    StickySessionEncoderProvider encoder = session.getProvider(StickySessionEncoderProvider.class);
    String decodedAuthSessionId = encoder.decodeSessionId(encodedAuthSessionId);
    String reencoded = encoder.encodeSessionId(decodedAuthSessionId);
    return new AuthSessionId(decodedAuthSessionId, reencoded);
}
Also used : StickySessionEncoderProvider(org.keycloak.sessions.StickySessionEncoderProvider)

Aggregations

StickySessionEncoderProvider (org.keycloak.sessions.StickySessionEncoderProvider)2 UriInfo (javax.ws.rs.core.UriInfo)1