api: correct according to review

This commit is contained in:
Xavier Stouder
2025-07-04 21:36:34 +02:00
parent 9a31b9c077
commit b4f6ab963c
4 changed files with 55 additions and 147 deletions
+2 -1
View File
@@ -23,8 +23,8 @@ use garage_util::time::now_msec;
use garage_api_common::generic_server::*;
use garage_api_common::helpers::*;
use crate::api::*;
use crate::api::AdminApiRequest::GetCurrentAdminTokenInfo;
use crate::api::*;
use crate::error::*;
use crate::router_v0;
use crate::router_v1;
@@ -274,6 +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()))
// GetCurrentAdminTokenInfo endpoint must be accessible even if it is not in the token scopes
.filter(|p| p.has_scope(endpoint_name) || endpoint_name == "GetCurrentAdminTokenInfo")
.ok_or_else(|| Error::forbidden(invalid_msg))?
.token_hash