api: change endpoint name and allow it to be called even if not in current token scope

This commit is contained in:
Xavier Stouder
2025-07-03 21:59:07 +02:00
parent 58a96dc687
commit 9a31b9c077
6 changed files with 21 additions and 20 deletions
+2 -1
View File
@@ -24,6 +24,7 @@ use garage_api_common::generic_server::*;
use garage_api_common::helpers::*;
use crate::api::*;
use crate::api::AdminApiRequest::GetCurrentAdminTokenInfo;
use crate::error::*;
use crate::router_v0;
use crate::router_v1;
@@ -273,7 +274,7 @@ fn verify_authorization(
.get_local(&EmptyKey, &prefix.to_string())?
.and_then(|k| k.state.into_option())
.filter(|p| !p.is_expired(now_msec()))
.filter(|p| p.has_scope(endpoint_name))
.filter(|p| p.has_scope(endpoint_name) || endpoint_name == "GetCurrentAdminTokenInfo")
.ok_or_else(|| Error::forbidden(invalid_msg))?
.token_hash
} else {