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 {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-02-16 16:02:03 +01:00
|
|
|
/// 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);
|
|
|
|
}
|