Skip to content

Commit 6172a63

Browse files
committed
fix: handle azure incomplete logged out sessions
1 parent a209bcd commit 6172a63

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

docker/keycloak/extensions-26/services/src/main/java/com/github/bcgov/keycloak/authenticators/CookieStopAuthenticator.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,29 @@ public void authenticate(AuthenticationFlowContext context) {
7171
AuthenticatedClientSessionModel clientSessionModel = authResult.getSession()
7272
.getAuthenticatedClientSessionByClient(clientUUID);
7373

74-
// 4. If no Cookie session with the authenticating client, proceed to login
74+
// 4. If the authenticating user has a session with other client in the same
75+
// realm then remove it
76+
if (authResult != null) {
77+
if (authResult.getSession() != null) {
78+
authResult.getSession().getAuthenticatedClientSessions().forEach((k, v) -> {
79+
if (!k.equals(clientUUID)) {
80+
UserSessionProvider userSessionProvider = context.getSession().sessions();
81+
userSessionProvider.removeUserSession(context.getRealm(), authResult.getSession());
82+
}
83+
});
84+
context.attempted();
85+
return;
86+
}
87+
}
88+
89+
// 5. If no Cookie session with the authenticating client, proceed to login
7590
// process
7691
if (clientSessionModel == null) {
7792
context.attempted();
7893
return;
7994
}
8095

81-
// 5. Otherwise, attach the exisiting session to the user
96+
// 6. Otherwise, attach the exisiting session to the user
8297
context.getAuthenticationSession().setAuthNote(AuthenticationManager.SSO_AUTH, "true");
8398
context.setUser(authResult.getUser());
8499
context.attachUserSession(authResult.getSession());

localdev/macs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ COPY ./docker/keycloak/extensions-26 /tmp/
44
WORKDIR /tmp/
55
RUN mvn -B clean package --file pom.xml -Dmaven.test.skip=true
66

7-
FROM registry.redhat.io/rhbk/keycloak-rhel9:26.0-3 AS builder
7+
FROM registry.redhat.io/rhbk/keycloak-rhel9:26.2-4 AS builder
88

99
# Enable health and metrics support
1010
ENV KC_HEALTH_ENABLED=true

0 commit comments

Comments
 (0)