Search in sources :

Example 6 with HttpScope

use of org.wildfly.security.http.HttpScope in project keycloak by keycloak.

the class ElytronSamlSessionStore method isLoggingIn.

@Override
public boolean isLoggingIn() {
    HttpScope session = exchange.getScope(Scope.SESSION);
    if (!session.exists())
        return false;
    CurrentAction action = (CurrentAction) session.getAttachment(CURRENT_ACTION);
    return action == CurrentAction.LOGGING_IN;
}
Also used : HttpScope(org.wildfly.security.http.HttpScope)

Example 7 with HttpScope

use of org.wildfly.security.http.HttpScope in project keycloak by keycloak.

the class ElytronSamlSessionStore method logoutSessionIds.

protected void logoutSessionIds(List<String> sessionIds) {
    sessionIds.forEach(id -> {
        HttpScope scope = exchange.getScope(Scope.SESSION, id);
        if (scope.exists()) {
            log.debugf("Invalidating session %s", id);
            scope.setAttachment(SamlSession.class.getName(), null);
            scope.invalidate();
        }
    });
}
Also used : HttpScope(org.wildfly.security.http.HttpScope) SamlSession(org.keycloak.adapters.saml.SamlSession)

Example 8 with HttpScope

use of org.wildfly.security.http.HttpScope in project keycloak by keycloak.

the class ElytronSamlSessionStore method saveRequest.

@Override
public void saveRequest() {
    exchange.suspendRequest();
    HttpScope scope = exchange.getScope(Scope.SESSION);
    if (!scope.exists()) {
        scope.create();
    }
    scope.setAttachment(SAML_REDIRECT_URI, exchange.getRequest().getURI());
}
Also used : HttpScope(org.wildfly.security.http.HttpScope)

Example 9 with HttpScope

use of org.wildfly.security.http.HttpScope in project keycloak by keycloak.

the class ElytronSamlSessionStore method saveAccount.

@Override
public void saveAccount(SamlSession account) {
    HttpScope session = getSession(true);
    session.setAttachment(SamlSession.class.getName(), account);
    String sessionId = changeSessionId(session);
    idMapperUpdater.map(idMapper, account.getSessionIndex(), account.getPrincipal().getSamlSubject(), sessionId);
}
Also used : HttpScope(org.wildfly.security.http.HttpScope) SamlSession(org.keycloak.adapters.saml.SamlSession)

Example 10 with HttpScope

use of org.wildfly.security.http.HttpScope in project keycloak by keycloak.

the class ElytronSamlSessionStore method getRedirectUri.

@Override
public String getRedirectUri() {
    HttpScope session = exchange.getScope(Scope.SESSION);
    String redirect = (String) session.getAttachment(SAML_REDIRECT_URI);
    if (redirect == null) {
        URI uri = exchange.getURI();
        String path = uri.getPath();
        String relativePath = exchange.getRequest().getRelativePath();
        String contextPath = path.substring(0, path.indexOf(relativePath));
        if (!contextPath.isEmpty()) {
            contextPath = contextPath + "/";
        }
        String baseUri = KeycloakUriBuilder.fromUri(path).replacePath(contextPath).build().toString();
        return SamlUtil.getRedirectTo(exchange, contextPath, baseUri);
    }
    return redirect;
}
Also used : HttpScope(org.wildfly.security.http.HttpScope) URI(java.net.URI)

Aggregations

HttpScope (org.wildfly.security.http.HttpScope)18 KeycloakSecurityContext (org.keycloak.KeycloakSecurityContext)7 RefreshableKeycloakSecurityContext (org.keycloak.adapters.RefreshableKeycloakSecurityContext)7 SamlSession (org.keycloak.adapters.saml.SamlSession)4 URI (java.net.URI)3 KeycloakDeployment (org.keycloak.adapters.KeycloakDeployment)3 HttpServerExchange (io.undertow.server.HttpServerExchange)2 ServletRequestContext (io.undertow.servlet.handlers.ServletRequestContext)2 BufferedInputStream (java.io.BufferedInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2 ServletInputStream (javax.servlet.ServletInputStream)2 ServletRequest (javax.servlet.ServletRequest)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletRequestWrapper (javax.servlet.http.HttpServletRequestWrapper)2 AuthenticationError (org.keycloak.adapters.spi.AuthenticationError)2 LogoutError (org.keycloak.adapters.spi.LogoutError)2