LCOV - differential code coverage report
Current view: top level - safekeeper/src - auth.rs (source / functions) Coverage Total Hit UBC CBC
Current: cd44433dd675caa99df17a61b18949c8387e2242.info Lines: 80.0 % 15 12 3 12
Current Date: 2024-01-09 02:06:09 Functions: 100.0 % 1 1 1
Baseline: 66c52a629a0f4a503e193045e0df4c77139e344b.info
Baseline Date: 2024-01-08 15:34:46

           TLA  Line data    Source code
       1                 : use utils::auth::{AuthError, Claims, Scope};
       2                 : use utils::id::TenantId;
       3                 : 
       4 CBC         191 : pub fn check_permission(claims: &Claims, tenant_id: Option<TenantId>) -> Result<(), AuthError> {
       5             191 :     match (&claims.scope, tenant_id) {
       6 UBC           0 :         (Scope::Tenant, None) => Err(AuthError(
       7               0 :             "Attempt to access management api with tenant scope. Permission denied".into(),
       8               0 :         )),
       9 CBC         144 :         (Scope::Tenant, Some(tenant_id)) => {
      10             144 :             if claims.tenant_id.unwrap() != tenant_id {
      11               5 :                 return Err(AuthError("Tenant id mismatch. Permission denied".into()));
      12             139 :             }
      13             139 :             Ok(())
      14                 :         }
      15               1 :         (Scope::PageServerApi, _) => Err(AuthError(
      16               1 :             "PageServerApi scope makes no sense for Safekeeper".into(),
      17               1 :         )),
      18              46 :         (Scope::SafekeeperData, _) => Ok(()),
      19                 :     }
      20             191 : }
        

Generated by: LCOV version 2.1-beta