Add OpenID request token endpoint

This commit is contained in:
iinuwa 2020-02-18 12:15:32 -06:00 committed by GitHub
parent a63e73a32d
commit 0139ebc41a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 0 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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,
}