-
Notifications
You must be signed in to change notification settings - Fork 61
Add experimental and preliminary policy-driven session limiting when logging in OAuth 2 sessions. #5221
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
base: main
Are you sure you want to change the base?
Conversation
b6ad7a4 to
9f3d978
Compare
9f3d978 to
203bf44
Compare
203bf44 to
071830e
Compare
sandhose
left a comment
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.
I'm going to assume TODO after this is mostly dealing with the compat API
| pub soft_limit: u64, | ||
| pub hard_limit: u64, |
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.
TBD, how does it behave when a limit is set to zero? Would it be worth using NonZeroU64?
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.
crates/policy/src/lib.rs
Outdated
| } | ||
|
|
||
| #[derive(Debug)] | ||
| #[derive(Serialize, Debug)] |
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.
alternatively this could have a serializeable static part plus rest as two separate properties, which feels a smidge less 'smart', but also fine with this
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.
ok you tricked me into writing DataBase
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.
|
|
||
| let session_counts = count_user_sessions_for_limiting(&mut repo, &session.user) | ||
| .await | ||
| .map_err(|e| RouteError::Internal(e.into()))?; |
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.
surprised RouteError doesn't implement From that error?
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.
oh, anyhow, that's why. Fine then
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.
to be fair, maybe I should have double-thought it and passed through the database error
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.
Co-authored-by: Copilot <[email protected]>
e0d7fb9 to
08959fa
Compare
Part of: #4339
Intended for commit-by-commit review.
Introduces a soft and hard session limit. At login time, we count the user's existing sessions (OAuth 2, Compat and self-owned Personal) and refuse creation of a new one if the limit is reached. This is configurable by policy.
The soft limit will be used for interactive logins where the user could be shown a web UI to remove devices, whereas the hard limit will be used for
m.login.passwordlogins where the user can't be shown such a UI.Limitations:
These limitations will be handled in future PRs, but for now this is part of the experimental config section.