diff options
Diffstat (limited to 'src/api/mod.rs')
| -rw-r--r-- | src/api/mod.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/api/mod.rs b/src/api/mod.rs index affb9ef..bec7764 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -25,6 +25,7 @@ use utoipa::OpenApi; use utoipa_swagger_ui::SwaggerUi; use crate::api::auth::{AuthState, AuthenticatedUser, basic_auth}; +use crate::document::meta; use crate::document::store::StoreError; use crate::state::AppState; @@ -117,13 +118,11 @@ fn parse_write_path( method: &str, ) -> Result<Vec<String>, StatusCode> { let path = parse_key_path(key)?; - if path.first().map(String::as_str) != Some(crate::remake::snapshot::META_ROOT) { + if !meta::is_protocol(&path) { return Ok(path); } // `_continuum` itself, epoch metadata and the swarm ID: nobody. - let fixed = path.len() < 2 - || path[1] == crate::remake::snapshot::EPOCHS - || path[1] == crate::remake::snapshot::SWARM; + let fixed = path.len() < 2 || path[1] == meta::EPOCHS || path[1] == meta::SWARM; if fixed || !state.protocol_writers.contains(&user.0) { warn!(user = %user.0, method, path = %key, "Refused a write to protocol data"); return Err(StatusCode::FORBIDDEN); |
