1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-06-30 19:48:17 +02:00

feat: support end to bridge encryption

by implementing appservice logins
This commit is contained in:
digital 2023-01-18 23:21:23 +01:00
parent 815db0d962
commit 4d589d9788

View file

@ -26,6 +26,7 @@ pub async fn get_login_types_route(
) -> Result<get_login_types::v3::Response> {
Ok(get_login_types::v3::Response::new(vec![
get_login_types::v3::LoginType::Password(Default::default()),
get_login_types::v3::LoginType::ApplicationService(Default::default()),
]))
}
@ -103,6 +104,27 @@ pub async fn login_route(body: Ruma<login::v3::Request>) -> Result<login::v3::Re
));
}
}
login::v3::LoginInfo::ApplicationService(login::v3::ApplicationService { identifier }) => {
info!("hi");
if !body.from_appservice {
return Err(Error::BadRequest(
ErrorKind::Forbidden,
// TODO: is this the correct response
"Wrong username or password.",
));
};
let username = if let UserIdentifier::UserIdOrLocalpart(user_id) = identifier {
user_id.to_lowercase()
} else {
return Err(Error::BadRequest(ErrorKind::Forbidden, "Bad login type."));
};
let user_id =
UserId::parse_with_server_name(username, services().globals.server_name())
.map_err(|_| {
Error::BadRequest(ErrorKind::InvalidUsername, "Username is invalid.")
})?;
user_id
}
_ => {
return Err(Error::BadRequest(
ErrorKind::Unknown,