-
Notifications
You must be signed in to change notification settings - Fork 399
MSC4155: Invite filtering #4155
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
Signed-off-by: Johannes Marbach <[email protected]>
ddd43ec
to
6adc165
Compare
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.
Implementation requirements:
- Client supporting the feature, and using it
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.
Since I believe all the gematik implementations will be closed source, I'll reference #3860 (comment) as an example for how cases like this were handled in the past. Thanks @clokep for digging it up.
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.
element-hq/synapse#18288 is a serverside implementation, albeit with #4155 (comment) "corrected"
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.
element-hq/element-web#29603 exposes the serverside settings in the client, but does no filtering of itself. @Johennes does this evoke any worries from you if the invite filtering is done server-side?
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.
No, I this is fine and consistent with the proposal which allows but doesn't enforce the filtering on either the client or the server. Now that I think of it, we might need a capability so that the client knows when the server does not filter in which case the client needs to filter itself.
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.
Well, I still need to get all this stuff approved but hopefully yes :). EWeb has lots of nice safety features landing :)
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.
Similar implementations:
- Implementing the gematik spec: https://github.com/famedly/synapse-invite-checker/blob/5608f40ffeaef1320edef8554cb432fa2c881fdd/synapse_invite_checker/types.py#L71
- Nheko (missing UI, using a slightly different format): Nheko-Reborn/mtxclient@d6a0a4e and Nheko-Reborn/nheko@978174a
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.
Partial implementation as a synapse module: https://github.com/matrix-org/msc4155-synapse-invite-filter
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.
element-hq/synapse#18288 supports the updated proposal.
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.
With my SCT hat:
The following implementations demonstrate the desire for filtering, and experiment with different ordering, but all demonstrate that the code is more than possible:
- Add support for MSC4155 Invite filtering element-hq/synapse#18288
- Nheko-Reborn/mtxclient@d6a0a4e
- Nheko-Reborn/nheko@978174a
- https://github.com/famedly/synapse-invite-checker/blob/5608f40ffeaef1320edef8554cb432fa2c881fdd/synapse_invite_checker/types.py#L71
- https://github.com/matrix-org/msc4155-synapse-invite-filter
The following implementations show that there's desire, but don't do much with the actual config:
Collectively, I feel this satisfies the implementation component, though we should monitor for user feedback if the rule processing order feels wrong. If so, we can correct it with a future MSC relatively easily (it'll suck for people on implementations which use the 'old' rules, but as those implementations update users will see the changes).
proposals/4155-invite-filtering.md
Outdated
|
||
The `default` field defines the standard setting that is applied to all invites that don't match an | ||
exception. Exceptions invert the default setting and are provided via the `user_exceptions` and | ||
`server_exceptions` fields which follow the format of the `ignored_users` field in `m.ignored_user_list`. |
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 think this comes with a problem of data loss. If you flip the "default" here, you end up with one of two problems. Either:
- The exemptions are now blocked/allowed, so if I start with my invites allowed but block
@badguy:scam.org
and then flip the default then the only person who can talk to me is bad guy! - If the client flips the
default
and removes the exceptions then that data is lost forever and I need to reconstruct my list.
Could we make an easy change here where the exceptions are explicit about their behavior by including the block/allow for each key. While this looks redundant, it means flipping bits won't cause unexpected behavior here.
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.
Hm, this is a problem indeed. Adding the block / allow behavior into each exception sounds reasonable to me.
It might be worth pointing out that this would make the proposal somewhat equivalent to the combination of #3847 and #4150. The only significant difference is storing the rules in a single account data event vs. as multiple policy events in a room.
I won't add this into the proposal yet because I'm hoping the SCT can provide some guidance on #4192 so that we don't spend our time in vein on the different options.
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 looking to work on an experimental implementation of this, for the current T&S safety sprint I'm doing so I'm just doing some review on that basis.
#4192 felt a bit heavy a quick experiment, so I want to give this one a fair tryout.
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, I see! And sorry, I wasn't aware you're actually part of T&S. If you want to go ahead with putting the type into the exceptions, that sounds reasonable to me, like I said. I'll happily add this into the proposal if it turns out worthwhile in the implementation.
Also, since we have this in the gematik specification (though with a different event type), there must already be implementations of this somewhere, just apparently not in open source clients, sadly. 😕
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 think this would be relatively easy to handle with just prefixing fields for now:
{
"allowed_users": [...],
"allowed_servers": [...],
"denied_users": [...],
"denied_servers": [...]
}
Though verbose, it carries the same meaning. If we consider #4283 then we might extend this to:
allowed_users
ignored_users
blocked_users
allowed_servers
ignored_servers
blocked_servers
A later MSC (namely #3847) would handle change history of the rules more easily.
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.
https://github.com/matrix-org/msc4155-synapse-invite-filter is a partial implementation of the variant.
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.
Thanks for expanding. I have updated proposal text accordingly.
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'd like to keep it separate for now, for ease of use by developers. Having too many 'tricks' like this makes the protocol feel more complicated than it is, sometimes.
So basically it's because "you like it this way"? I can accept that but there should be some consesus instead of your sole opinion, ain't it?
Seems like a clear duplicate functionality, and I guess the code would look like matching the sender of the invite with the list entries, so in this case two lists instead of one, using the same matching. I don't see how this would make developers' life simpler.
There were mentions elsewhere about ordering (name matches first, server later, to make it possible to disable everone but allow someone), which is not mentioned here as a pro, but feels like it would be a mess anyway people guessing the double ordering (first names, then servers).
Using common globs (servers and users) does not feel complex to me, and clinet developers can create separate UI for servers if they feel like, I'm sure it's not very complex to understand/remember that *:servername
is a "server" entry.
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 had the same question initially but I think splitting users and servers is actually helpful. Having dedicated fields for servers prevents unintended globbing issues (server names can contain :
as well) and is more explicit and easier to understand. Furhtermore, overlapping user / server globs don't strike me as problematic because we have a defined evaluation order for all settings.
I'm reopening this in case other people have thoughts on 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.
(not considering this thread as a blocker against the checklist in this case)
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.
other than the confusion of block versus ignore, this looks good to me - thank you!
If we do switch to using split out fields, supporting globs would be ideal.
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.
thanks for updating this! I'll do some implementation review then hopefully send this for FCP (with the assumption that the listed suggestions aren't too controversial 😇 )
Co-authored-by: Travis Ralston <[email protected]>
Co-authored-by: Travis Ralston <[email protected]>
Co-authored-by: Travis Ralston <[email protected]>
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.
Would be nice to get more exmplanation why it's out of scope...
@mscbot resolve Rule order |
Co-authored-by: R Midhun Suresh <[email protected]>
@mscbot concern Clarify ignore behaviour (preferred: send an event, but don't deliver, like normal user ignores) |
@mscbot concern Confusing behavior of whether enforced by clients or servers |
Sounds resolved now clients are not involved. |
@mscbot resolve Confusing behavior of whether enforced by clients or servers |
Co-authored-by: Will Hunt <[email protected]>
Co-authored-by: Will Hunt <[email protected]>
This implements matrix-org/matrix-spec-proposals#4155, which adds support for a new account data type that blocks an invite based on some conditions in the event contents. --------- Co-authored-by: Andrew Morgan <[email protected]>
1. Verify the invite against each `*_users` setting: | ||
1. If it matches `allowed_users`, stop processing and allow. | ||
2. If it matches `ignored_users`, stop processing and ignore. | ||
3. If it matches `blocked_users`, stop processing and block. | ||
2. Verify the invite against each `*_servers` setting: | ||
1. If it matches `allowed_servers`, stop processing and allow. | ||
2. If it matches `ignored_servers`, stop processing and ignore. | ||
3. If it matches `blocked_servers`, stop processing and block. | ||
3. Otherwise, allow. |
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.
The allow
semantic here is in the reverse order to server ACL, and the implication is that an allow rules overrule ban rules. This will cause problems later if an allow policy rule recommendation is created, because it will have different semantics based on context.
To be explicit, for it to be consistent with server ACL, the allow rule would have to be applied first and processing can only continue if there is a match.
Rendered
In line with matrix-org/matrix-spec#1700, the following disclosure applies:
I am a Systems Architect at gematik, Software Engineer at Unomed, Matrix community member and former Element employee. This proposal was written and published with my gematik hat on.
SCT stuff:
MSC checklist
FCP tickyboxes