-
Notifications
You must be signed in to change notification settings - Fork 66
Revoke personal sessions when users are deactivated #5181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Deploying matrix-authentication-service-docs with
|
| Latest commit: |
409f354
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3a983a49.matrix-authentication-service-docs.pages.dev |
| Branch Preview URL: | https://rei-pat-revoke-on-deactivate.matrix-authentication-service-docs.pages.dev |
| let status = match self { | ||
| Self::Internal(_) => StatusCode::INTERNAL_SERVER_ERROR, | ||
| Self::UserNotFound => StatusCode::NOT_FOUND, | ||
| Self::UserDeactivated => StatusCode::GONE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure why not :D
| .await? | ||
| .ok_or(RouteError::UserNotFound)?; | ||
|
|
||
| if actor_user.deactivated_at.is_some() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe check just is_valid (assuming it does the right thing) so that we also check for locked status?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now using is_valid_actor
| .table(PersonalSessions::Table) | ||
| .value(PersonalSessions::RevokedAt, revoked_at) | ||
| .and_where( | ||
| Expr::col((PersonalSessions::Table, PersonalSessions::PersonalSessionId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a chunky subquery. I assume you need this because of the JOIN; could you stick in a comment explaining that? Also we could be doing that in a CTE, but not convinced the code would be clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added some comments
yeah, it's a bit chunky, the sea-query doesn't help with that verbosity either, but hopefully the new comments make the intent clear
Part of: #4492
Revoke both personal sessions that are owned by, and acting as, the deactivated user.
Owned by because: it doesn't make sense for a deactivated user to be able to control themselves or other users, so them having active personal sessions is just confusing.
Acting as because: current precedent is that deactivated users are not controllable, even by admins.
To uphold this, the admin API is also fixed to stop allowing the creation of personal sessions for deactivated users.