sipb / uplink

SIPB's integrated chatroom project
GNU Affero General Public License v3.0
6 stars 1 forks source link

Develop custom access control plug in #104

Open gabrc52 opened 10 months ago

gabrc52 commented 10 months ago

Features

Implementation

event name: edu.mit.sipb.custom_acl state key can be an empty string since we have no use for it

  1. if there is no such event, allow
  2. if any of the deny entries is satisfied, deny
  3. if any of the allow entries is satisfied, allow
  4. otherwise, deny

Types

Error messages

Element relays the error messages from the homeserver, so if someone tries to join a semi-unfederated room as in the example below, it would be better for the error message to say You are not invited to this room or for the other example You are not invited to this room, please ask a MIT student to invite you.

I don't know how to implement custom error messages while also allowing full flexibility, but we could handle a few special cases, and return a generic error message otherwise. It is also possible that for the case of the moira list ones, we may not want to tell people why they were rejected from a room.

Examples

These are all illustrative but within the MIT context, and do not mean I endorse having rooms like that.

Semi-undefederated room: only people in our homeserver can join unless they are invited

{
  "allow": [
    {"type": "homeserver", "value": "matrix.mit.edu"},
    {"type": "invited", "value": "true"},
  ]
}

Allow anyone in ec-discuss or r-h-t

{
  "allow": [
    {"type": "moira_list", "value": "ec-discuss"},
    {"type": "moira_list", "value": "r-h-t"},
  ]
}

Allow all MIT students or anyone who was invited to the room

This is what we need for classes.

{
  "allow": [
    {"type": "affiliation", "value": "student@mit.edu"},
    {"type": "invited", "value": "true"},
  ]
}

Allow all MIT students and allow all SIPB members regardless of whether they are a student or not

{
  "allow": [
    {"type": "moira_list", "value": "sipb"},
    {"type": "affiliation", "value": "student@mit.edu"}
  ]
}

Allow all EC residents except Tetazoans

{
  "allow": [
    {"type": "moira_list", "value": "ec-residents"}
  ],
  "deny": [
    {"type": "moira_list", "value": "3e-residents"}
  ]
}

Allow MIT kerb-holders (through matrix.mit.edu) who are not MIT students

{
  "allow": [
    {"type": "homserver", "value": "matrix.mit.edu"},
  ],
  "deny": [
    {"type": "affiliation", "value": "student@mit.edu"],
  ],
}

Allow only invited students

Since this would require an AND, it is not implementable through this current proposal, but it can be done by combining a join rule event with this event. If we do a MSC, care is to be taken so that things like this still work.

Notes

gabrc52 commented 10 months ago

Thinking of it a bit more, I'm not sure how this all plays in with federation. I was assuming our home server would be the arbiter but there are more homeservers and this is why the spec about server ACLs has this whole thing about how to deal with noncompliant servers.

Let's just do a simple plugin which handles the classes part first and then actually work in making a new plugin we can publish. The MSC can be a draft since I'd be able to get feedback and iterate.

Rooms don't just live in one home server and if you can't join via one you can join via another.

This means if you let one person from one server in you might be letting in everyone else in that home sever.

gabrc52 commented 10 months ago

image

Yeah it's probably not a good idea to send a MSC yet since they have plans of adding role-based access control and if that is so we might be able to mirror moira lists to that

gabrc52 commented 10 months ago

Also we might want to hook user_may_invite too otherwise people might have stuck invites or invites they just can't join and can only decline

gabrc52 commented 10 months ago

Also note that the Synapse module API allows returning specific error codes but not messages so that might need work too for friendlier messages