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::{auth_scheme::NoAuthentication, request, response},
12 metadata, OwnedUserId,
13 };
14
15 metadata! {
16 method: GET,
17 rate_limited: false,
18 authentication: NoAuthentication,
19 path: "/_matrix/federation/v1/openid/userinfo",
20 }
21
22 /// Request type for the `get_openid_userinfo` endpoint.
23 #[request]
24 pub struct Request {
25 /// The OpenID access token to get information about the owner for.
26 #[ruma_api(query)]
27 pub access_token: String,
28 }
29
30 /// Response type for the `get_openid_userinfo` endpoint.
31 #[response]
32 pub struct Response {
33 /// The Matrix User ID who generated the token.
34 pub sub: OwnedUserId,
35 }
36
37 impl Request {
38 /// Creates a new `Request` with the given access token.
39 pub fn new(access_token: String) -> Self {
40 Self { access_token }
41 }
42 }
43
44 impl Response {
45 /// Creates a new `Response` with the given user id.
46 pub fn new(sub: OwnedUserId) -> Self {
47 Self { sub }
48 }
49 }
50}