OpenID routes

Co-Authored-By: Matthias Ahouansou <matthias@ahouansou.cz>
This commit is contained in:
mikoto 2024-05-28 00:22:11 +02:00 committed by Matthias Ahouansou
parent 47aadcea1d
commit a888c7cb16
No known key found for this signature in database
10 changed files with 127 additions and 4 deletions

View file

@ -24,6 +24,7 @@ use ruma::{
event::{get_event, get_missing_events, get_room_state, get_room_state_ids},
keys::{claim_keys, get_keys},
membership::{create_invite, create_join_event, prepare_join_event},
openid::get_openid_userinfo,
query::{get_profile_information, get_room_information},
transactions::{
edu::{DeviceListUpdateContent, DirectDeviceContent, Edu, SigningKeyUpdateContent},
@ -1914,6 +1915,25 @@ pub async fn claim_keys_route(
})
}
/// # `GET /_matrix/federation/v1/openid/userinfo`
///
/// Get information about the user that generated the OpenID token.
pub async fn get_openid_userinfo_route(
body: Ruma<get_openid_userinfo::v1::Request>,
) -> Result<get_openid_userinfo::v1::Response> {
Ok(get_openid_userinfo::v1::Response::new(
services()
.users
.find_from_openid_token(&body.access_token)?
.ok_or_else(|| {
Error::BadRequest(
ErrorKind::Unauthorized,
"OpenID token has expired or does not exist.",
)
})?,
))
}
/// # `GET /.well-known/matrix/server`
///
/// Returns the federation server discovery information.