#[cfg(feature = "authorization-handler-allow-keys")]
pub mod allow_keys;
#[cfg(feature = "authorization-handler-maintenance")]
pub mod maintenance;
mod permission_map;
#[cfg(feature = "authorization-handler-rbac")]
pub mod rbac;
pub(in crate::rest_api) mod routes;
use crate::error::InternalError;
use super::identity::Identity;
pub(in crate::rest_api) use permission_map::PermissionMap;
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Permission {
Check {
permission_id: &'static str,
permission_display_name: &'static str,
permission_description: &'static str,
},
AllowAuthenticated,
AllowUnauthenticated,
}
pub enum AuthorizationHandlerResult {
Allow,
Deny,
Continue,
}
pub trait AuthorizationHandler: Send + Sync {
fn has_permission(
&self,
identity: &Identity,
permission_id: &str,
) -> Result<AuthorizationHandlerResult, InternalError>;
fn clone_box(&self) -> Box<dyn AuthorizationHandler>;
}
impl Clone for Box<dyn AuthorizationHandler> {
fn clone(&self) -> Box<dyn AuthorizationHandler> {
self.clone_box()
}
}