ruma_federation_api/openid/
get_openid_userinfo.rs

1//! `GET /_matrix/federation/*/openid/userinfo`
2//!
3//! Exchange an OpenID access token for information about the user who generated the token.
4
5pub mod v1 {
6    //! `/v1/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/server-server-api/#get_matrixfederationv1openiduserinfo
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata, OwnedUserId,
13    };
14
15    const METADATA: Metadata = metadata! {
16        method: GET,
17        rate_limited: false,
18        authentication: None,
19        history: {
20            1.0 => "/_matrix/federation/v1/openid/userinfo",
21        }
22    };
23
24    /// Request type for the `get_openid_userinfo` endpoint.
25    #[request]
26    pub struct Request {
27        /// The OpenID access token to get information about the owner for.
28        #[ruma_api(query)]
29        pub access_token: String,
30    }
31
32    /// Response type for the `get_openid_userinfo` endpoint.
33    #[response]
34    pub struct Response {
35        /// The Matrix User ID who generated the token.
36        pub sub: OwnedUserId,
37    }
38
39    impl Request {
40        /// Creates a new `Request` with the given access token.
41        pub fn new(access_token: String) -> Self {
42            Self { access_token }
43        }
44    }
45
46    impl Response {
47        /// Creates a new `Response` with the given user id.
48        pub fn new(sub: OwnedUserId) -> Self {
49            Self { sub }
50        }
51    }
52}