Skip to content

Conversation

@reivilibre
Copy link
Contributor

Part of: #4339
Follows: #5221

This PR introduces a new policy for compatibility logins and starts off by adding a session limit.

Compatibility login is a bit troublesome in that the actual device creation is uninteractive, so we can't show an interactive screen to clean up devices at the time of actually creating the device!
Only for m.login.sso-style logins can we do an optimistic 'please clean up some devices' screen (although this PR on its own just displays a generic policy violation screen),
but this can only happen before the actual creation of the session.

For this reason we will make use of a soft and hard limit. The soft limit will display a policy violation screen in interactive contexts but not be enforced in uninteractive contexts.
Meanwhile the hard limit will be enforced in the uninteractive contexts, eventually (in the future) through automatic eviction of a session.

@reivilibre reivilibre force-pushed the rei/policy_for_compat_login branch from dd9fc94 to 5b7e908 Compare November 25, 2025 18:40
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 25, 2025

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

Latest commit: 444e084
Status: ✅  Deploy successful!
Preview URL: https://7011f741.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://rei-policy-for-compat-login.matrix-authentication-service-docs.pages.dev

View logs

@reivilibre reivilibre force-pushed the rei/policy_for_compat_login branch from 5b7e908 to 1ce2c39 Compare November 25, 2025 18:41
Comment on lines 211 to 212
// TODO I don't know if we should keep this anymore, not used by current policy
pub login_type: CompatLoginType,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

thoughts?

@reivilibre reivilibre force-pushed the rei/policy_for_compat_login branch from 060253f to 959e383 Compare November 26, 2025 13:48
@reivilibre reivilibre marked this pull request as ready for review November 27, 2025 15:13
@reivilibre reivilibre requested a review from a team as a code owner November 27, 2025 15:13
@reivilibre reivilibre force-pushed the rei/policy_for_compat_login branch from cf82370 to 0ff619f Compare November 28, 2025 12:42

// TODO is this actually what we care about? Don't we care a bit more about whether we're in an
// interactive context or a non-interactive context? (SSO type has both phases :()
pub login_type: CompatLoginType,
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if the context also included the SSO redirect URI on m.login.sso? Surely we'll want to limit those in some contexts


# This is a web-based interactive login
# TODO not strictly correct...
input.login_type == "m.login.sso"
Copy link
Member

Choose a reason for hiding this comment

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

you could easily do a helper like

is_interactive if {
    input.login_type == "m.login.sso"
}

})
.await?;
if !res.valid() {
if res.violations.len() == 1 {
Copy link
Member

Choose a reason for hiding this comment

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

what's the reasoning behind having a different message only if there is a single "too-many-sessions" violation vs. if it is one of them in the list?

In any case, I think this would benefit from a comment of what we're doing and why

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely should comment, but I think the underlying thought was: If you have too many sessions but also your client 'Tnemele' is banned, isn't showing you the UI for 'pick a device to delete' missing the point?

})
.await?;
if !res.valid() {
let ctx = CompatLoginPolicyViolationContext::for_violations(
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should just pass the violation result? I assume this is a dependency problem, mas-templates would need to depend on mas-policy? Not a strong opinion if it's too annoying

/// - true when asking for consent,
/// - false when actually performing the login (at which point we create the
/// compat session, but it's too late to show a web page)
pub is_interactive: bool,
Copy link
Member

Choose a reason for hiding this comment

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

what if the distinction was instead m.login.token on the login type since that's the actual login type that is going through at this stage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did consider, no super strong opinion on that, but if you veer towards it let's do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants