Repository navigation
when the realm session limit is exceeded and behavior is set to Termi… - #48064
Conversation
|
@martinkrcka - please add a sign-off to your commit as outlined in the CONTRIBUTING.md file. |
Done :-) |
|
@martinkrcka Still not done :/ The commit needs to contain the "Signed-off-by: xxx"... you can add the |
Finally it should be done! |
|
@martinkrcka Thanks! As this PR is clearly built on top of @mateenali66's PR, you should add this note to the commit description: As I think this approach with |
|
@martinkrcka It'd be also good to return-fast, when the count is 0, so similar to what @mateenali66 did here: if (numberOfSessionsThatNeedToBeLoggedOut == 0) {
logger.debug("No additional sessions that need to be logged out");
return Collections.emptyList();
} |
…nate oldest session, the authenticator calls handleLimitExceeded(userSessionsForClient, userClientLimit) first. if the user has fewer existing sessions for the current client than userClientLimit - 1, getNumberOfSessionsThatNeedToBeLoggedOut() returns a negative value and Stream.limit(negative) throws IllegalArgumentException, producing a 500 on every login to that client. This change ensures that getNumberOfSessionsThatNeedToBeLoggedOut returns 0 if the calculated value is negative. The dependent execution steps remain unchanged. A result of 0 sessions to be purged from the current client triggers the removal of the oldest sessions across all clients. also added a regression test in UserSessionLimitsTest that reproduces the scenario: realm limit=2, client limit=3, two logins on client-a to saturate the realm, then login on client-b (0 existing client sessions). Fixes keycloak#48040 Co-authored-by: Mateen Anjum <mateenali66@gmail.com> Signed-off-by: Martin Krcka <martin.krcka@adesso.de>
Signed-off-by: Martin Bartoš <mabartos@redhat.com>
There was a problem hiding this comment.
@martinkrcka I've added the last missing piece.
@martinkrcka @mateenali66 Thanks for the contribution!
@keycloak/core-authn Anyone want to review it as well?
There was a problem hiding this comment.
Thanks @martinkrcka and @mabartos! LGTM too!
There was a problem hiding this comment.
Approving based on previous reviews.
keycloak#48064) * when the realm session limit is exceeded and behavior is set to Terminate oldest session, the authenticator calls handleLimitExceeded(userSessionsForClient, userClientLimit) first. if the user has fewer existing sessions for the current client than userClientLimit - 1, getNumberOfSessionsThatNeedToBeLoggedOut() returns a negative value and Stream.limit(negative) throws IllegalArgumentException, producing a 500 on every login to that client. This change ensures that getNumberOfSessionsThatNeedToBeLoggedOut returns 0 if the calculated value is negative. The dependent execution steps remain unchanged. A result of 0 sessions to be purged from the current client triggers the removal of the oldest sessions across all clients. also added a regression test in UserSessionLimitsTest that reproduces the scenario: realm limit=2, client limit=3, two logins on client-a to saturate the realm, then login on client-b (0 existing client sessions). Fixes keycloak#48040 --------- Signed-off-by: Martin Krcka <martin.krcka@adesso.de> Signed-off-by: Martin Bartoš <mabartos@redhat.com> Co-authored-by: Mateen Anjum <mateenali66@gmail.com> Co-authored-by: Martin Bartoš <mabartos@redhat.com> (cherry picked from commit 953cd26)
keycloak#48064) * when the realm session limit is exceeded and behavior is set to Terminate oldest session, the authenticator calls handleLimitExceeded(userSessionsForClient, userClientLimit) first. if the user has fewer existing sessions for the current client than userClientLimit - 1, getNumberOfSessionsThatNeedToBeLoggedOut() returns a negative value and Stream.limit(negative) throws IllegalArgumentException, producing a 500 on every login to that client. This change ensures that getNumberOfSessionsThatNeedToBeLoggedOut returns 0 if the calculated value is negative. The dependent execution steps remain unchanged. A result of 0 sessions to be purged from the current client triggers the removal of the oldest sessions across all clients. also added a regression test in UserSessionLimitsTest that reproduces the scenario: realm limit=2, client limit=3, two logins on client-a to saturate the realm, then login on client-b (0 existing client sessions). Fixes keycloak#48040 --------- Signed-off-by: Martin Krcka <martin.krcka@adesso.de> Signed-off-by: Martin Bartoš <mabartos@redhat.com> Co-authored-by: Mateen Anjum <mateenali66@gmail.com> Co-authored-by: Martin Bartoš <mabartos@redhat.com>
when the realm session limit is exceeded and behavior is set to Terminate oldest session, the authenticator calls
handleLimitExceeded(userSessionsForClient, userClientLimit) first.
if the user has fewer existing sessions for the current client than userClientLimit - 1, getNumberOfSessionsThatNeedToBeLoggedOut() returns a negative value and Stream.limit(negative) throws IllegalArgumentException, producing a 500 on every login to that client.
This change ensures that getNumberOfSessionsThatNeedToBeLoggedOut returns 0 if the calculated value is negative. The dependent execution steps remain unchanged.
A result of 0 sessions to be purged from the current client triggers the removal of the oldest sessions across all clients.
also added a regression test in UserSessionLimitsTest that reproduces the scenario: realm limit=2, client limit=3, two logins on client-a to saturate the realm, then login on client-b (0 existing client sessions).
Fixes #48040