diff --git a/CHANGELOG.md b/CHANGELOG.md index be170e04..1826ebd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Improvements: * Add an `Error` type that represents the well-known errors in the client-server API +* Add OpenID token request endpoint. Breaking changes: diff --git a/src/r0/account.rs b/src/r0/account.rs index b16ab28f..bda1ecb0 100644 --- a/src/r0/account.rs +++ b/src/r0/account.rs @@ -8,6 +8,7 @@ pub mod get_username_availability; pub mod register; pub mod request_3pid_management_token_via_email; pub mod request_3pid_management_token_via_msisdn; +pub mod request_openid_token; pub mod request_password_change_token_via_email; pub mod request_password_change_token_via_msisdn; pub mod request_registration_token_via_email; diff --git a/src/r0/account/request_openid_token.rs b/src/r0/account/request_openid_token.rs new file mode 100644 index 00000000..a62f7b09 --- /dev/null +++ b/src/r0/account/request_openid_token.rs @@ -0,0 +1,41 @@ +//! [POST /_matrix/client/r0/user/{userId}/openid/request_token](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-user-userid-openid-request-token) + +use js_int::UInt; +use ruma_api::ruma_api; +use ruma_identifiers::UserId; +use serde::{Deserialize, Serialize}; + +ruma_api! { + metadata { + description: "Request an OpenID 1.0 token to verify identity with a third party.", + name: "request_openid_token", + method: POST, + path: "/_matrix/client/r0/user/:user_id/openid/request_token", + rate_limited: true, + requires_authentication: true, + } + + request { + /// User ID of authenticated user. + #[ruma_api(path)] + user_id: UserId, + } + + response { + /// Access token for verifying user's identity. + access_token: String, + /// Access token type. + token_type: TokenType, + /// Homeserver domain for verification of user's identity. + matrix_server_name: String, + /// Seconds until token expiration. + expires_in: UInt, + } +} + +/// Access token types. +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +pub enum TokenType { + /// Bearer token type + Bearer, +}