Ramsai
Ramsai8mo ago

Terminate all the active sessions at once.

Hi team, I have a user who has more than 20 sessions when I search the sessions that he has with https://zitadel.com/docs/apis/resources/session_service_v2/session-service-list-sessions. Do we have an option to terminate all the sessions at once instead of terminating the session one at a time with https://zitadel.com/docs/apis/resources/session_service_v2/session-service-delete-session ? This termination at once would help us a lot. Thanks
ZITADEL Docs
Terminate your own session or if granted any other session.
17 Replies
fabienne
fabienne8mo ago
I believe at the moment we do not have a bulk terminate, terminate all user sessions. @livio @stebenz you might be able to add more information, in case i missed something
shree_harsha
shree_harsha8mo ago
Firstly, is there a way to get all-active session of the user? So that we can terminate active sessions one at a time. If not there is no bulk option. In addition to that, https://zitadel.com/docs/apis/resources/session_service_v2/session-service-list-sessions. The response, for this request does not provide user agent info and expiration date for the hosted instance. If we have that expiration date we can minimize calls based on the expiration date whether to ignore that particular session or not. Otherwise irrespective of session is active or not, needed to make the termination request for all sessions.
fabienne
fabienne8mo ago
from what i see in our api docs, the response should include the user agent and the expiration date, is it empty ?
No description
Ramsai
RamsaiOP8mo ago
Yes, this is the format of the response we are receiving { "id": "", "creationDate": "2024-12-18T06:04:18.983543Z", "changeDate": "2024-12-18T06:04:18.983543Z", "sequence": "4", "factors": { "user": { "verifiedAt": "2024-12-18T06:04:18.973849Z", "id": "", "loginName": "", "displayName": "", "organizationId": "" }, "intent": { "verifiedAt": "2024-12-18T06:04:18.975776Z" } } },
fabienne
fabienne8mo ago
ok, in that case it looks like a bug, can you open up an issue in the github repository? It is easier to track there than in discord
shree_harsha
shree_harsha8mo ago
We will create a GitHub issue. To the earlier question, is there a way to get only active sessions of the user ID? In our case, we want our clients to have only two active sessions. As we have license-based subscriptions.
fabienne
fabienne8mo ago
From what I see in the docs, this is currently not possible. But let me loop in @stebenz and @livio they might be able to help
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
shree_harsha
shree_harsha8mo ago
@stebenz We noticed that when using a hosted instance, the expiration and userAgent fields were missing from the response, for that we raised a Git issue(https://github.com/zitadel/zitadel/issues/9276). The active filter is essential for accurately tracking active sessions. Relying solely on expiration might lead to edge cases where terminated sessions are included in the latest fetched data, potentially missing out on truly active sessions. For example, if a system allows only five concurrent sessions, fetching the latest five sessions might return only terminated ones, while actual active sessions exist beyond that window. This could lead to unintended access issues. Having a dedicated active filter would be beneficial for many users, especially those implementing session-based access restrictions. This enhancement would add significant value.
GitHub
Issues · zitadel/zitadel
ZITADEL - Identity infrastructure, simplified for you. - Issues · zitadel/zitadel
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
shree_harsha
shree_harsha8mo ago
What if the session is not terminated but expired. Then will that be listed in the session list api. I could see that expired ones are included in the response.
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
shree_harsha
shree_harsha8mo ago
Yeah got that. I just wanted to know whether you would be interested in implementing that enhancement. Why you are not including terminated ones? As an admin, I would like to look at the sessions of the client. For example, to keep track of unusual logging out pattersn, etc
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
shree_harsha
shree_harsha8mo ago
ok sure
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
shree_harsha
shree_harsha8mo ago
In my case (to get active sessions), what event_type would be ideal for us with events api?

Did you find this page helpful?