Skip to content
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

Specify room version 10: knock_restricted and int power levels #1099

Merged
merged 25 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f443b3d
Clarification on historical power level handling
neilalexander May 24, 2022
6b175d6
Revert "Clarification on historical power level handling"
neilalexander May 24, 2022
7fd54c4
Clean up
neilalexander May 24, 2022
666baf6
Let us try this again not using VS Code
neilalexander May 24, 2022
a5a4c1f
Markdown is full of mysteries
neilalexander May 24, 2022
503a815
Merge remote-tracking branch 'neilalexander/neilalexander/powerlevels…
turt2live May 30, 2022
3dd5bee
Move stringy power levels to room versions
turt2live May 30, 2022
b2fa4e5
Describe range
turt2live May 30, 2022
be12f1e
Fix minor issues with previous room version stuff
turt2live May 30, 2022
16e7383
Copy/paste v9 into v10
turt2live May 30, 2022
3d50019
Describe deprecated formatting
turt2live May 30, 2022
1f3dc21
Paste unmodified auth rules from v8 into v10
turt2live May 30, 2022
0174618
Move 9.1 to 9.3, add 9.1 and 9.2 for integer enforcement
turt2live May 30, 2022
0eec78d
Add knock_restricted to v10 auth
turt2live May 30, 2022
41ed640
Misc cleanup and clarification for fragments
turt2live May 30, 2022
5e3175a
Describe `knock_restricted` client changes
turt2live May 30, 2022
56157dc
Changelogs
turt2live May 30, 2022
a8cd1ae
spelling
turt2live May 30, 2022
290fa16
Merge branch 'main' into travis/spec/v10
turt2live May 30, 2022
1653b43
Apply suggestions from code review
turt2live Jun 7, 2022
67d2847
Apply code review suggestions manually
turt2live Jun 7, 2022
47169fd
Fix v9 redactions
turt2live Jun 7, 2022
1e2f4f6
Fix auth rules clarity issues
turt2live Jun 7, 2022
2b7483a
Apply suggestions from code review
turt2live Jun 8, 2022
05ad39d
Remove false integer requirements
turt2live Jun 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/client_server/newsfragments/1099.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for a new `knock_restricted` join rule in supported room versions, as per [MSC3787](https://github.com/matrix-org/matrix-spec-proposals/pull/3787).
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify that room versions 1 through 9 accept stringy power levels, as noted by [MSC3667](https://github.com/matrix-org/matrix-spec-proposals/pull/3667).
1 change: 1 addition & 0 deletions changelogs/room_versions/newsfragments/1099.feature.1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add room version 10 as per [MSC3604](https://github.com/matrix-org/matrix-spec-proposals/pull/3604).
1 change: 1 addition & 0 deletions changelogs/room_versions/newsfragments/1099.feature.2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enforce integer power levels in room version 10 as per [MSC3667](https://github.com/matrix-org/matrix-spec-proposals/pull/3667).
1 change: 1 addition & 0 deletions changelogs/room_versions/newsfragments/1099.feature.3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a `knock_restricted` join rule supported by room version 10 as per [MSC3787](https://github.com/matrix-org/matrix-spec-proposals/pull/3787).
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify the historical handling of non-integer power levels.
25 changes: 25 additions & 0 deletions content/client-server-api/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1969,6 +1969,13 @@ room listed in the join rules. If the server cannot verify membership for any
of the listed rooms then you can only join with an invite. Note that this rule
is only expected to work in room versions [which support it](/rooms/#feature-matrix).

{{% added-in v="1.3" %}} `knock_restricted`
This room can be joined as though it was `restricted` *or* `knock`. If you
interact with the room using knocking, the `knock` rule takes effect whereas
trying to join the room without an invite applies the `restricted` join rule.
Note that this rule is only expected to work in room versions
[which support it](/rooms/#feature-matrix).

The allowable state transitions of membership are:

![membership-flow-diagram](/diagrams/membership.png)
Expand All @@ -1984,6 +1991,15 @@ The allowable state transitions of membership are:
##### Knocking on rooms

{{% added-in v="1.1" %}}
{{% changed-in v="1.3" %}}

{{% boxes/note %}}
As of `v1.3`, it is possible to knock on a [restricted room](#restricted-rooms)
if the room supports and is using the `knock_restricted` join rule.

Note that `knock_restricted` is only expected to work in room versions
[which support it](/rooms/#feature-matrix).
{{% /boxes/note %}}

<!--
This section is here because it's most similar to being invited/joining a
Expand Down Expand Up @@ -2021,6 +2037,15 @@ server chose to auto-accept.
##### Restricted rooms

{{% added-in v="1.2" %}}
{{% changed-in v="1.3" %}}

{{% boxes/note %}}
As of `v1.3`, it is possible to [knock](#knocking-on-rooms) on a restricted
room if the room supports and is using the `knock_restricted` join rule.

Note that `knock_restricted` is only expected to work in room versions
[which support it](/rooms/#feature-matrix).
{{% /boxes/note %}}

Restricted rooms are rooms with a `join_rule` of `restricted`. These rooms
are accompanied by "allow conditions" as described in the
Expand Down
11 changes: 7 additions & 4 deletions content/rooms/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ Alternatively, consider flipping the column/row organization to be features
up top and versions on the left.
-->

| Feature \ Version | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|-------------------|---|---|---|---|---|---|---|---|---|
| **Knocking** | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✔ | ✔ | ✔ |
| **Restricted join rules** | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✔ | ✔ |
| Feature \ Version | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|-------------------|---|---|---|---|---|---|---|---|---|----|
| **Knocking** | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✔ | ✔ | ✔ | ✔ |
| **Restricted join rules** | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✔ | ✔ | ✔ |
| **`knock_restricted` join rule** | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✔ |

## Complete list of room versions

Expand Down Expand Up @@ -73,6 +74,8 @@ The available room versions are:
of another room to join without invite.
- [Version 9](/rooms/v9) - **Stable**. Builds on v8 to fix issues when
redacting some membership events.
- [Version 10](/rooms/v10) - **Stable**. Enforces integer-only power levels
and adds `knock_restricted` join rule.

## Room version grammar

Expand Down
13 changes: 13 additions & 0 deletions content/rooms/fragments/v1-deprecated-formatting-off-spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
toc_hide: true
---

Events sent into rooms of this version can have formats which are different
from their normal schema. Those cases are documented here.

{{% boxes/warning %}}
The behaviour described here is preserved strictly for backwards compatibility
only. A homeserver should take reasonable precautions to prevent users from
sending these so-called "malformed" events, and must never rely on the behaviours
described here as a default.
{{% /boxes/warning %}}
43 changes: 43 additions & 0 deletions content/rooms/fragments/v1-stringy-power-levels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
toc_hide: true
---

##### `m.room.power_levels` events accept values as strings

In order to maintain backwards compatibility with early implementations,
each of the integer-valued properties within
[`m.room.power_levels`](/client-server-api#mroompower_levels) events can
be encoded as strings instead of integers. This includes the nested values
within the `events`, `notifications` and `users` properties.
For example, the following is a valid `m.room.power_levels` event in this room version:

```json
{
"content": {
"ban": "50",
"events": {
"m.room.power_levels": "100"
},
"events_default": "0",
"state_default": "50",
"users": {
"@example:localhost": "100"
},
"users_default": "0"
},
"origin_server_ts": 1432735824653,
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
"sender": "@example:example.org",
"state_key": "",
"type": "m.room.power_levels"
}
```

When the value is representative of an integer, they must be the following format:

* a single base 10 integer, no float values or decimal points, optionally with
any number of leading zeroes (`"100"`, `"000100"`);
* optionally prefixed with a single `-` or `+` character before the integer (`"+100"`,
`"-100"`).
* optionally with any number of leading or trailing whitespace characters (`" 100 "`,
`" 00100 "`, `" +100 "`, `" -100 "`);
51 changes: 51 additions & 0 deletions content/rooms/fragments/v9-redactions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
toc_hide: true
---

{{% added-in this=true %}} `m.room.member` events now keep `join_authorised_via_users_server`
in addition to other keys in `content` when being redacted.

{{% boxes/rationale %}}
Without the `join_authorised_via_users_server` property, redacted join events
can become invalid when verifying the auth chain of a given event, thus creating
a split-brain scenario where the user is able to speak from one server's
perspective but most others will continually reject their events.

This can theoretically be worked around with a rejoin to the room, being careful
not to use the faulty events as `prev_events`, though instead it is encouraged
to use v9 rooms over v8 rooms to outright avoid the situation.

[Issue #3373](https://github.com/matrix-org/matrix-doc/issues/3373) has further
information.
{{% /boxes/rationale %}}

The full redaction algorithm follows.

Upon receipt of a redaction event, the server must strip off any keys
not in the following list:

- `event_id`
- `type`
- `room_id`
- `sender`
- `state_key`
- `content`
- `hashes`
- `signatures`
- `depth`
- `prev_events`
- `prev_state`
- `auth_events`
- `origin`
- `origin_server_ts`
- `membership`

The content object must also be stripped of all keys, unless it is one
of one of the following event types:

- `m.room.member` allows keys `membership`, `join_authorised_via_users_server`.
- `m.room.create` allows key `creator`.
- `m.room.join_rules` allows keys `join_rule`, `allow`.
- `m.room.power_levels` allows keys `ban`, `events`, `events_default`,
`kick`, `redact`, `state_default`, `users`, `users_default`.
- `m.room.history_visibility` allows key `history_visibility`.
6 changes: 6 additions & 0 deletions content/rooms/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ Events in version 1 rooms have the following structure:

{{% definition path="api/server-server/definitions/pdu" %}}

#### Deprecated event content schemas

{{% rver-fragment name="v1-deprecated-formatting-off-spec" %}}

{{% rver-fragment name="v1-stringy-power-levels" %}}

### Authorization rules

{{% rver-fragment name="v1-auth-rules" %}}
Expand Down
Loading