Development Documentation (main branch) - For stable release docs, see docs.rs/eidetica

eidetica/auth/validation/
permissions.rs

1//! Permission checking for authentication operations
2//!
3//! This module provides utilities for checking if resolved authentication
4//! has sufficient permissions for specific operations.
5
6use crate::{
7    Result,
8    auth::types::{Operation, ResolvedAuth},
9};
10
11/// Check if a resolved authentication has sufficient permissions for an operation
12pub fn check_permissions(resolved: &ResolvedAuth, operation: &Operation) -> Result<bool> {
13    match operation {
14        Operation::WriteData => {
15            Ok(resolved.effective_permission.can_write()
16                || resolved.effective_permission.can_admin())
17        }
18        Operation::WriteSettings => Ok(resolved.effective_permission.can_admin()),
19    }
20}