Skip to content

Commit 84659c1

Browse files
committed
Always store auth context in session
If a session auth context is provided during authentication, we will now always store it to a session. If no session exists at this point, we will create a session because we can treat the presence of a SessionAuthContext as a sufficient indicator that the creation of a session is expected/required. Previously, we were only storing the auth context in the session if the session existed. Most likely because of a refactoring of the SessionCreator in 5cdac60, the listener that persists the data is now called before the session is created.
1 parent de587bb commit 84659c1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

graylog2-server/src/main/java/org/graylog2/shared/security/PersistSessionDataListener.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ public void onSuccess(AuthenticationToken token, AuthenticationInfo info) {
3737
if (info instanceof AuthenticationInfoWithSessionAuthContext(
3838
AuthenticationInfo ignored, SessionAuthContext sessionAuthContext
3939
)) {
40-
final var session = SecurityUtils.getSubject().getSession(false);
41-
if (session != null) {
42-
session.setAttribute(SessionUtils.AUTH_CONTEXT_SESSION_KEY, sessionAuthContext);
43-
}
40+
SecurityUtils.getSubject().getSession()
41+
.setAttribute(SessionUtils.AUTH_CONTEXT_SESSION_KEY, sessionAuthContext);
4442
}
4543
}
4644

0 commit comments

Comments
 (0)