fix Appservice AccessTokenOptional authentication type endpoints
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
a2a7b81076
commit
0301c7c083
1 changed files with 24 additions and 2 deletions
|
@ -84,8 +84,7 @@ where
|
||||||
appservice_registration
|
appservice_registration
|
||||||
{
|
{
|
||||||
match metadata.authentication {
|
match metadata.authentication {
|
||||||
// TODO: verify if just or'ing `AuthScheme::AppserviceToken` is correct here
|
AuthScheme::AccessToken | AuthScheme::AppserviceToken => {
|
||||||
AuthScheme::AccessToken | AuthScheme::AccessTokenOptional | AuthScheme::AppserviceToken => {
|
|
||||||
let user_id = query_params.user_id.map_or_else(
|
let user_id = query_params.user_id.map_or_else(
|
||||||
|| {
|
|| {
|
||||||
UserId::parse_with_server_name(
|
UserId::parse_with_server_name(
|
||||||
|
@ -97,6 +96,8 @@ where
|
||||||
|s| UserId::parse(s).unwrap(),
|
|s| UserId::parse(s).unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
debug!("User ID: {:?}", user_id);
|
||||||
|
|
||||||
if !services().users.exists(&user_id)? {
|
if !services().users.exists(&user_id)? {
|
||||||
return Err(Error::BadRequest(ErrorKind::Forbidden, "User does not exist."));
|
return Err(Error::BadRequest(ErrorKind::Forbidden, "User does not exist."));
|
||||||
}
|
}
|
||||||
|
@ -104,6 +105,27 @@ where
|
||||||
// TODO: Check if appservice is allowed to be that user
|
// TODO: Check if appservice is allowed to be that user
|
||||||
(Some(user_id), None, None, true)
|
(Some(user_id), None, None, true)
|
||||||
},
|
},
|
||||||
|
AuthScheme::AccessTokenOptional => {
|
||||||
|
let user_id = query_params.user_id.map_or_else(
|
||||||
|
|| {
|
||||||
|
UserId::parse_with_server_name(
|
||||||
|
registration.sender_localpart.as_str(),
|
||||||
|
services().globals.server_name(),
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
},
|
||||||
|
|s| UserId::parse(s).unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
|
debug!("User ID: {:?}", user_id);
|
||||||
|
|
||||||
|
if !services().users.exists(&user_id)? {
|
||||||
|
(None, None, None, true)
|
||||||
|
} else {
|
||||||
|
// TODO: Check if appservice is allowed to be that user
|
||||||
|
(Some(user_id), None, None, true)
|
||||||
|
}
|
||||||
|
},
|
||||||
AuthScheme::ServerSignatures => (None, None, None, true),
|
AuthScheme::ServerSignatures => (None, None, None, true),
|
||||||
AuthScheme::None => (None, None, None, true),
|
AuthScheme::None => (None, None, None, true),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue