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

Fix definition of response of POST /_matrix/federation/v1/user/keys/claim #1559

Merged
merged 3 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix definition of response of `POST /_matrix/federation/v1/user/keys/claim`.
38 changes: 20 additions & 18 deletions data/api/server-server/user_keys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,28 @@ paths:
type: object
# Key
additionalProperties:
type: object
title: KeyObject
properties:
key:
type: string
description: The key, encoded using unpadded base64.
signatures:
type: object
title: Signatures
additionalProperties:
type: object
additionalProperties:
oneOf:
- type: string
- type: object
Comment on lines +75 to +76
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unconvinced this is correct. Is it true that a string can be returned here? The description doesn't seem to say anything about that being permissible.

@KitsuneRal you seem to have suggested this is correct at #1351 (comment), but I don't know why you said that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - might very well be a copy-pasta on my end. Can one-time keys be unsigned - guess not? If not, my suggestion is incorrect and there should be KeyObject here, without alternatives.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so it's not a copy-pasta on my end at least. The alternative between string and object has been here since the very beginning, even though undocumented. My comment in #1351 referred to the correct nesting level and I mentioned that string has to be returned only because it has been there before. If it hasn't been correct from the beginning then I'd rather we fix it in a separate PR but I'm fine either way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I think I've figured this out!

Before we invented the signed_curve25519 key algorithm for one-time-keys, we just used curve25519 keys. These, not being signed, can be represented just by a string.

The curve25519 algorithm should no longer be used here, but removing them from the spec sounds like a different job.

So, 👍 to this fix.

Copy link
Member

@richvdh richvdh Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

title: KeyObject
properties:
key:
type: string
description: |-
Signature of the key object.
description: The key, encoded using unpadded base64.
signatures:
type: object
title: Signatures
additionalProperties:
type: object
additionalProperties:
type: string
description: |-
Signature of the key object.

The signature is calculated using the process described at [Signing JSON](/appendices/#signing-json).
required:
- key
- signatures
The signature is calculated using the process described at [Signing JSON](/appendices/#signing-json).
required:
- key
- signatures
example:
"@alice:example.com":
JLAFKJWSCS:
Expand Down
15 changes: 15 additions & 0 deletions layouts/partials/json-schema/resolve-additional-types.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@
{{ end }}
{{ end }}

{{/*
Handle object schemas using the `oneOf` keyword
(https://json-schema.org/understanding-json-schema/reference/combining.html#oneof)
*/}}
{{ if $this_object.oneOf }}
{{ range $idx, $item := $this_object.oneOf }}
{{ $additional_objects = partial "get-additional-objects" (dict
"this_object" $item
"additional_objects" $additional_objects
"anchor_base" $anchor_base
"name" (printf "%s.oneOf[%d]" $name $idx)
) }}
{{ end }}
{{ end }}

{{ return $additional_objects }}


Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/openapi/render-object-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{{ $property := partial "json-schema/resolve-allof" $property }}
{{ $type := $property.type }}

{{ if eq $property.type "object" }}
{{ if or (eq $property.type "object") (and $property.oneOf (reflect.IsSlice .oneOf)) }}
{{ $type = partial "type-or-title" $property }}
{{ end }}

Expand Down Expand Up @@ -108,7 +108,7 @@
{{ $types := slice }}

{{ range .oneOf }}
{{ $types = $types | append .type }}
{{ $types = $types | append (partial "type-or-title" .) }}
{{ end }}

{{ $type = delimit $types "|" }}
Expand Down
Loading