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

Allow /versions to optionally accept authentication #1728

Merged
merged 3 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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/1728.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow `/versions` to optionally accept authentication, as per [MSC4026](https://github.com/matrix-org/matrix-spec-proposals/pull/4026).
21 changes: 17 additions & 4 deletions data/api/client-server/versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,21 @@ paths:
which has not yet landed in the spec. For example, a feature currently
undergoing the proposal process may appear here and eventually be taken
off this list once the feature lands in the spec and the server deems it
reasonable to do so. Servers may wish to keep advertising features here
after they've been released into the spec to give clients a chance to
upgrade appropriately. Additionally, clients should avoid using unstable
features in their stable releases.
reasonable to do so. Servers can choose to enable some features only for
some users, so clients should include authentication in the request to
get all the features available for the logged-in user. If no
authentication is provided, the server should only return the features
available to all users. Servers may wish to keep advertising features
here after they've been released into the spec to give clients a chance
to upgrade appropriately. Additionally, clients should avoid using
unstable features in their stable releases.
operationId: getVersions
security:
- {}
- accessToken: []
x-changedInMatrixVersion:
"1.10": |
This endpoint can behave differently when authentication is provided.
responses:
"200":
description: The versions supported by the server.
Expand Down Expand Up @@ -89,3 +99,6 @@ servers:
default: localhost:8008
basePath:
default: /_matrix/client
components:
securitySchemes:
$ref: definitions/security.yaml
17 changes: 16 additions & 1 deletion layouts/partials/openapi/render-operation.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,22 @@ <h1 id="{{ lower $method }}{{ $anchor }}">
</tr>
<tr>
<th>Requires authentication:</th>
<td>{{ if $operation_data.security }}Yes{{ else }}No{{ end }}</td>
{{/*
zecakeh marked this conversation as resolved.
Show resolved Hide resolved
Authentication is optional if one of these is true:
- the security key is not set
- the security value contains an empty object
*/}}
{{ $requires_authentication := 1 }}
{{ if $operation_data.security }}
{{ range $operation_data.security }}
{{ if eq (len (index $operation_data.security 0)) 0 }}
{{ $requires_authentication = 0 }}
{{ end }}
{{ end }}
{{ else }}
{{ $requires_authentication = 0 }}
{{ end }}
<td>{{ if $requires_authentication }}Yes{{ else }}No{{ end }}</td>
</tr>
</table>

Expand Down
Loading