mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-10-22 19:01:20 +00:00
fix: Don't bail on unrecognized OAuth scopes
This commit is contained in:
1 file changed
+5
-7
@@ -115,7 +115,8 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
| Self::ClientApi => write!(f, "urn:matrix:client:api:*"),
|
||||
| Self::Device(device_id) => write!(f, "urn:matrix:client:device:{device_id}"),
|
||||
| Self::ServerAdministration => write!(f, "urn:matrix:client:cc.c10y.msc4484.server_administration"),
|
||||
| Self::ServerAdministration =>
|
||||
write!(f, "urn:matrix:client:cc.c10y.msc4484.server_administration"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +131,8 @@ pub fn to_scopes(&self) -> Result<HashSet<RequestedScope>, String> {
|
||||
regex!(r"urn:matrix:(client|org.matrix.msc2967.client):api:\*");
|
||||
let device_token_regex =
|
||||
regex!(r"urn:matrix:(client|org.matrix.msc2967.client):device:([a-zA-Z0-9-._~]{5,})");
|
||||
let server_administration_regex = regex!(r"urn:matrix:client:cc.c10y.msc4484.server_administration");
|
||||
let server_administration_regex =
|
||||
regex!(r"urn:matrix:client:cc.c10y.msc4484.server_administration");
|
||||
|
||||
let mut scopes = HashSet::new();
|
||||
|
||||
@@ -143,12 +145,8 @@ pub fn to_scopes(&self) -> Result<HashSet<RequestedScope>, String> {
|
||||
} else if let Some(captures) = device_token_regex.captures(token) {
|
||||
scopes
|
||||
.insert(RequestedScope::Device(captures.get(2).unwrap().as_str().into()))
|
||||
} else if token == "openid" {
|
||||
// TODO(unspecced): Element sets this scope but doesn't use
|
||||
// it for anything
|
||||
true
|
||||
} else {
|
||||
return Err(format!("Invalid scope: {token}"));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user