-
Notifications
You must be signed in to change notification settings - Fork 398
MSC2403: Add "knock" feature #2403
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
501d7ec
add knock proposal
Sorunome bee4e9e
move to correct msc number
Sorunome 1ef7c17
remove stray heading
Sorunome 1396498
remove question regarding federation api version, as it has to be v2
Sorunome f0411a3
make clear displayname and avatar_url are optional, add status codes
Sorunome 776436a
forgot to update one json example
Sorunome 53435d4
update with new endpoints
Sorunome 5ae462d
address issues
Sorunome d47cb1f
Small grammatical fixes
anoadragon453 c92752d
Reflow text to <79 chars
anoadragon453 38d6708
Note that spam is a preventable, but real possibility as a result
anoadragon453 de038f5
Fix the response format of send_knock
anoadragon453 39c2168
small grammar
anoadragon453 74a341a
Mention that knock -> ban is possible
anoadragon453 716db4e
Spell out some possible abuse vectors and how to mitigate them
anoadragon453 d6d5858
knock->knock and rescinding of knocks are not allowed
anoadragon453 1051084
Switch from Power Levels -> Join Rules
anoadragon453 bc90f1c
Fix typo
anoadragon453 aad6ff4
Remove remaining traces of [200, {}] response format
anoadragon453 f3fc539
Move client recommendations into its own section
anoadragon453 651e73b
It's possible to fight against spam
anoadragon453 965c47b
Remove unnecessary sentence
anoadragon453 ae8ec66
Spec how a client is notified of pending knock progress
anoadragon453 5bfd65c
Federation knock_room_state and minor cleanup
anoadragon453 e93a19f
Indicate that this proposal requires a new room version
anoadragon453 c9a7b44
Merge branch 'soru/knock' of github.com:sorunome/matrix-doc into soru…
anoadragon453 58cb299
Update proposals/2403-knock.md
anoadragon453 703fa07
Remove extraneous text
anoadragon453 61fea58
Merge branch 'soru/knock' of github.com:sorunome/matrix-doc into soru…
anoadragon453 630f7c4
Allow users to knock over and over, removing CS complexity
anoadragon453 fd9d57b
Match state events sent to a remote server when inviting a user
anoadragon453 6e47e86
Add unstable endpoint replacements
anoadragon453 340f888
Mention unstable prefixes for sync, join_rules and membership events
anoadragon453 e58e207
Go into more depth about membership changes surrounding knocking
anoadragon453 9e5ac04
Explicitly state that the hs that received the knock must put in the …
anoadragon453 fd8176b
Clarify endpoint calls clients and servers need to use to handle knocks
anoadragon453 6b99228
Remove section duplicated by membership change section
anoadragon453 5097fad
Fix unstable prefix bullet points
anoadragon453 6f7bcb6
Explicitly state what changes to the auth rules are necessary
anoadragon453 525d1d3
Some clarifications and wording fixes
anoadragon453 a924f5b
Fix incorrect assumptions about the sender field of a knock event
anoadragon453 815dae6
Note that redactions of knocks are not a concern
anoadragon453 6c75b83
Address Travis and Patrick's feedback
anoadragon453 7dcff8f
Disallow invite->knock membership changes
anoadragon453 42e01b8
Add join_rules to room chunks returned on a public room dir query
anoadragon453 e99649c
Foreshadow power level requirements for approval/denial of knock
anoadragon453 51a7778
typo
anoadragon453 6a0d07c
Public rooms directory backwards compatibility note
anoadragon453 5c620de
typo fix
anoadragon453 d5a2a28
Note clients should try to prevent impersonation attacks during knocking
anoadragon453 8400877
Make ver a required parameter for make_knock
anoadragon453 337c87b
Add 404 on make_knock if unknown room ID
anoadragon453 04cd6b3
fix typo
anoadragon453 74f3b12
Note experimental room version ID
anoadragon453 248a3da
Switch /send_knock/ from v2 to v1; leave a note as to why
anoadragon453 eda6584
Comment on push rules
anoadragon453 24f61c2
Note that implementations may choose to auto-accept knock-related inv…
anoadragon453 e790ad2
Apply suggestions from code review
anoadragon453 49a7286
Allow knock->knock transitions
anoadragon453 c9f34e8
Link to /join/roomIdOrAlias
anoadragon453 c575f88
Move endpoint extras under endpoint's header
anoadragon453 53ad7e3
Ensure we return the room_id after knocking via the CS API
anoadragon453 09018be
Link to existing spec documentation on the public rooms directory
anoadragon453 c915b64
Update alternatives section
anoadragon453 6556b95
Move API endpoint sections up to the top of the proposal
anoadragon453 ef840c1
Split the 'Membership change to ' section into rejecting/rescinding k…
anoadragon453 8bfef19
Remove further traces of old /rooms/roomId/knock CS endpoint
anoadragon453 68d2d7c
Note that homeservers should pass down invites to the client if they …
anoadragon453 7f0b2d6
Update unstable endpoints from i.e xyz.amorgan/knock -> xyz.amorgan.k…
anoadragon453 a1a40c6
Be consistent about event auth rules
anoadragon453 11996fb
clarify some words
anoadragon453 10267df
Add missing 403/404 response codes
anoadragon453 9ebfd98
Apply suggestions from code review
anoadragon453 a8f4ada
Make join_rules field of PublicRoomChunk an optional value
anoadragon453 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
# MSC2403: Add "knock" feature | ||
Many people are in invite-only rooms. Sometimes, someone wants to join such a room and can't, as | ||
they aren't invited. This proposal adds a feature for this user to indicate that they want to join | ||
said room. | ||
|
||
# Proposal | ||
This proposal implements the reserved "knock" membership type for the `m.room.member` state event. | ||
This state event indicates that a user knocks a room, that is asking for permission to join. It | ||
contains an optional "reason" parameter to specify the reason you want to join. Like other | ||
memtership types the parameters "displayname" and "avatar_url" are optional. This membership can | ||
Sorunome marked this conversation as resolved.
Show resolved
Hide resolved
|
||
be set from users who aren't currently in said room. An example for the membership would look as | ||
follows: | ||
```json | ||
{ | ||
"membership": "knock", | ||
"displayname": "Alice", | ||
"avatar_url": "mxc://example.org/avatar", | ||
"reason": "I want to join this room as I really love foxes!" | ||
} | ||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
After a knock is received in a room it is expected to be displayed in the timeline, similar to other | ||
Sorunome marked this conversation as resolved.
Show resolved
Hide resolved
|
||
membership changes. Clients can optionally add a way for users of a room to review all current | ||
knocks. After a knock in a room a member of the room can invite the knocker. | ||
Sorunome marked this conversation as resolved.
Show resolved
Hide resolved
Sorunome marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
To be able to implement this properly two new endpoints need to be added, one in the client-server | ||
API and one in the server-server API. | ||
|
||
## Restrictions | ||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
There are restrictions to being able to set this membership. | ||
|
||
### Current membership | ||
Only users without a current membership or with their current membership being "leave" can knock a | ||
room. This means that a user that is banned or currently in the room can't knock on it. | ||
|
||
### Join Rules | ||
The `join_rule` of `m.room.join_rules` must be set to "invite". This means that people can't knock | ||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
in public rooms. Additionaly the new join rule "private" is introduced. This is so that people can, | ||
when creating a new room, prevent anyone from knocking. | ||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Power levels | ||
The default power level for "knock" is 0. If a user has a too low power level to knock they aren't | ||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
allowed to do this. As power levels can be set for users not currently in the room this can be used | ||
as a way to limit who can knock and who can't. | ||
|
||
#### Example: | ||
`@alice:example.org` CAN knock, but `@bob:example.org` can't: The (incomplete) content of | ||
`m.room.power_levels` is as follows: | ||
```json | ||
{ | ||
"users": { | ||
"@alice:example.org": 1 | ||
}, | ||
"users_default": 0, | ||
"knock": 1 | ||
} | ||
``` | ||
|
||
## Client-Server API | ||
The new endpoint for the client-server API is `POST /_matrix/client/r0/rooms/{roomId}/knock`. | ||
The path parameter (`roomId`) is the room you want to knock. It is required. The post body accepts | ||
an optional parameter, `reason`, which is the reason you want to join the room. A request could look | ||
as follows: | ||
|
||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
POST /_matrix/client/r0/rooms/%21d41d8cd%3Amatrix.org/knock HTTP/1.1 | ||
Content-Type: application/json | ||
|
||
{ | ||
"reason": "I want to join this room as I really love foxes!" | ||
} | ||
``` | ||
|
||
### Responses: | ||
#### Status code 200: | ||
The user knocked successfully. Empty reply: | ||
```json | ||
{} | ||
``` | ||
|
||
#### Status code 400: | ||
This request was invalid, e.g. bad JSON. Example reply: | ||
```json | ||
{ | ||
"errcode": "M_UNKNOWN", | ||
"error": "An unknown error occurred"} | ||
Sorunome marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
#### Status code 403: | ||
The user wasn't allowed to knock (e.g. they are banned). Error reply: | ||
```json | ||
{ | ||
"errcode": "M_FORBIDDEN", | ||
"error": "The user isn't allowed to knock in this room." | ||
} | ||
``` | ||
|
||
#### Status code 429: | ||
This request was rate-limited. Example reply: | ||
```json | ||
{ | ||
"errcode": "M_LIMIT_EXCEEDED", | ||
"error": "Too many requests", | ||
"retry_after_ms": 2000 | ||
} | ||
``` | ||
|
||
## Server-Server API | ||
The new endpoint for the server-server API is `PUT /_matrix/federation/v2/knock/{roomId}/{eventId}`. | ||
The path parameters are the room id you want to knock and the event id of the knock event. The post | ||
body consists of an `event` parameter, which is the knock event. A request could look as follows: | ||
|
||
``` | ||
PUT /_matrix/federation/v2/knock/%21abc123%3Amatrix.org/%24abc123%3Aexample.org HTTP/1.1 | ||
Content-Type: application/json | ||
|
||
{ | ||
"event": { | ||
"sender": "@alice:example.org", | ||
"origin": "example.org", | ||
"origin_server_ts": 1234567890, | ||
"type: "m.room.member", | ||
"state_key": "@alice:example.org", | ||
"content": { | ||
"membership": "knock", | ||
Sorunome marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"displayname": "Alice", | ||
"avatar_url": "mxc://example.org/avatar", | ||
"reason": "I want to join this room as I really love foxes!" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Responses | ||
#### Status code 200: | ||
The knock was performed successfully. The knock event is sent back with the "event" key. | ||
```json | ||
{ | ||
"event": { | ||
"sender": "@alice:example.org", | ||
"origin": "example.org", | ||
"origin_server_ts": 1234567890, | ||
"type": "m.room.member", | ||
"state_key": "@alice:example.org", | ||
"content": { | ||
"membership": "knock", | ||
"displayname": "Alice", | ||
"avatar_url": "mxc://example.org/avatar", | ||
"reason": "I want to join this room as I really love foxes!" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#### Status code 400: | ||
This request was invalid, e.g. bad JSON. Example reply: | ||
```json | ||
{ | ||
"errcode": "M_UNKNOWN", | ||
"error": "An unknown error occurred"} | ||
``` | ||
|
||
#### Status code 403: | ||
The user wasn't allowed to knock. Error reply: | ||
```json | ||
{ | ||
"errcode": "M_FORBIDDEN", | ||
"error": "The user isn't allowed to knock in this room." | ||
} | ||
``` | ||
|
||
# Potential issues | ||
richvdh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This new feature would allow users to spam rooms that they don't partake in. That is why this proposal | ||
adds both the new join rule and the new power level, in order to allow room admins to mitigate such | ||
potential spam. | ||
|
||
# Alternatives | ||
As for the join rule "invite", instead the join rule "knock" could be introduced, meaning the room | ||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
is like "invite" only that people can also knock. The difference is for existing rooms: With this | ||
proposal people can knock in existing "invite" rooms, with the alternative suggestion they can't. | ||
|
||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Security considerations | ||
Sorunome marked this conversation as resolved.
Show resolved
Hide resolved
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
None. This doesn't allow users access to a room in any way. | ||
turt2live marked this conversation as resolved.
Show resolved
Hide resolved
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.