Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Mark sessions as finished in bulk #2977

Merged
merged 6 commits into from
Jul 16, 2024
Merged

Mark sessions as finished in bulk #2977

merged 6 commits into from
Jul 16, 2024

Conversation

sandhose
Copy link
Member

@sandhose sandhose commented Jul 16, 2024

This is reviewable commit by commit.

On top of #2970

  • Batch finish compatibility sessions
  • Batch finish OAuth 2.0 sessions
  • Batch finish browser sessions
  • Make mas-cli manage kill-sessions finish sessions in bulk
  • Kill all sessions when deactivating a user

This makes it so that when we finish sessions (like when deactivating a user), we can do that in bulk.
This introduces new APIs on the three repositories, which are then used by the mas-cli manage kill-sessions command.
The reason we need this, is so that we can kill all sessions when a user is deactivated, so that they don't leave active sessions behind, and don't get magically logged in once we reactivate them.

Copy link

cloudflare-workers-and-pages bot commented Jul 16, 2024

Deploying matrix-authentication-service-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 334acad
Status: ✅  Deploy successful!
Preview URL: https://b58b89a1.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://quenting-batch-logout.matrix-authentication-service-docs.pages.dev

View logs

@sandhose sandhose force-pushed the quenting/user-reactivation branch from 3f30498 to 6c0effd Compare July 16, 2024 11:13
@sandhose sandhose force-pushed the quenting/batch-logout branch from b425f9b to 7526713 Compare July 16, 2024 11:14
@sandhose sandhose requested a review from reivilibre July 16, 2024 11:16
Copy link
Contributor

@reivilibre reivilibre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just one comment really (but applies to all filters), rest looks sane

let (sql, arguments) = Query::update()
.table(CompatSessions::Table)
.value(CompatSessions::FinishedAt, finished_at)
.and_where_option(filter.user().map(|user| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the CompatSessionFilter be responsible for constructing its own WHERE clauses? I am a bit concerned we'd forget to update this code here if we added more to the filter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did think of this, but it was annoying in particular for the compatibility sessions, as when we query, we JOIN on the compat_sso_logins and filter on that, which we can't do for updating the finished_at field.

I'll have a shot though in another PR

@sandhose sandhose changed the base branch from quenting/user-reactivation to main July 16, 2024 11:55
@sandhose sandhose force-pushed the quenting/batch-logout branch from 7526713 to 21ed451 Compare July 16, 2024 11:58
@sandhose sandhose enabled auto-merge (rebase) July 16, 2024 12:12
@sandhose sandhose merged commit e47f26f into main Jul 16, 2024
16 checks passed
@sandhose sandhose deleted the quenting/batch-logout branch July 29, 2024 12:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants