ruma_identity_service_api/keys/get_public_key.rs
1//! `GET /_matrix/identity/*/pubkey/{keyId}`
2//!
3//! Get the public key for the given key ID.
4
5pub mod v2 {
6 //! `/v2/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/latest/identity-service-api/#get_matrixidentityv2pubkeykeyid
9
10 use ruma_common::{
11 api::{request, response},
12 metadata,
13 third_party_invite::IdentityServerBase64PublicKey,
14 OwnedServerSigningKeyId,
15 };
16
17 metadata! {
18 method: GET,
19 rate_limited: false,
20 authentication: NoAuthentication,
21 history: {
22 1.0 => "/_matrix/identity/v2/pubkey/{key_id}",
23 }
24 }
25
26 /// Request type for the `get_public_key` endpoint.
27 #[request]
28 pub struct Request {
29 /// The ID of the key.
30 #[ruma_api(path)]
31 pub key_id: OwnedServerSigningKeyId,
32 }
33
34 /// Response type for the `get_public_key` endpoint.
35 #[response]
36 pub struct Response {
37 /// Unpadded base64-encoded public key.
38 pub public_key: IdentityServerBase64PublicKey,
39 }
40
41 impl Request {
42 /// Create a `Request` with the given key_id.
43 pub fn new(key_id: OwnedServerSigningKeyId) -> Self {
44 Self { key_id }
45 }
46 }
47
48 impl Response {
49 /// Create a `Response` with the given base64-encoded (unpadded) public key.
50 pub fn new(public_key: IdentityServerBase64PublicKey) -> Self {
51 Self { public_key }
52 }
53 }
54}