-
Notifications
You must be signed in to change notification settings - Fork 404
Ignore received EDUs if origin server in room ACL #18475
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: develop
Are you sure you want to change the base?
Conversation
changelog.d/18475.feature
Outdated
| @@ -0,0 +1 @@ | |||
| Make ACLs apply to EDUs. | |||
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.
Do we have any tests for ACLs on
/sendanywhere? I can't seem to find any and don't want to waste time reinventing the wheel trying to add tests for these 2 cases.
There is tests/federation_acl_test.go in Complement
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.
Complement PR: matrix-org/complement#783
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 Complement PR is still in draft and has a piece of pending review
Co-authored-by: Eric Eastwood <[email protected]>
| await self.check_server_matches_acl(origin_host, room_id) | ||
| except AuthError: | ||
| logger.warning( | ||
| "Ignoring typing EDU for room %s from banned server", room_id |
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.
| "Ignoring typing EDU for room %s from banned server", room_id | |
| "Ignoring typing EDU for room %s from banned server because of ACL's", room_id |
|
|
||
| if to_remove: | ||
| logger.warning( | ||
| "Ignoring receipts in EDU for rooms %s from banned server %s", |
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.
| "Ignoring receipts in EDU for rooms %s from banned server %s", | |
| "Ignoring receipts in EDU for rooms %s from banned server %s because of ACL's", |
| # > forbidden by the room's ACL. | ||
| if edu.edu_type == EduTypes.RECEIPT: | ||
| origin_host, _ = parse_server_name(origin) | ||
| to_remove = set() |
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_remove = set() | |
| to_remove_room_ids = set() |
| for room_id in edu.content.keys(): | ||
| try: | ||
| await self.check_server_matches_acl(origin_host, room_id) | ||
| except AuthError: |
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.
Feels like we should also have a general except Exception that logger.exception(...) like below.
Perhaps we should just nest everything under that single try
| ) | ||
|
|
||
| for room_id in to_remove: | ||
| edu.content.pop(room_id) |
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.
Mutating the edu itself it fine because we're creating it in this scope. But mutating edu.content is sketchy because that comes directly from the edu_dict being passed in.
Maybe one day we can lint for this kind thing (python/mypy#11076)
Implements: MSC4163: Make ACLs apply to EDUs
Part of #18118 to declare support for Matrix v1.13
Complement PR: matrix-org/complement#783
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.