fabaccess-bffh/src/access.rs

26 lines
531 B
Rust
Raw Normal View History

2020-02-14 12:20:17 +01:00
//! Access control logic
//!
use casbin::prelude::*;
use super::config::Config;
2020-02-17 03:44:02 +01:00
use crate::api::api;
#[derive(Clone)]
pub struct Permissions;
impl api::permissions::Server for Permissions {
}
/// This line documents init
2020-02-14 12:20:17 +01:00
pub async fn init(config: &Config) -> Result<Enforcer, Box<dyn std::error::Error>> {
let model = Model::from_file(config.access.model.clone()).await?;
let adapter = Box::new(FileAdapter::new(config.access.policy.clone()));
let e = Enforcer::new(model, adapter).await?;
return Ok(e);
}