2023-11-22 18:18:51 +02:00
|
|
|
pub mod cli;
|
2023-11-22 19:44:10 +02:00
|
|
|
pub mod to_config;
|
|
|
|
use labadoor_acl::ACL;
|
|
|
|
use to_config::ToConfig;
|
2023-11-22 18:18:51 +02:00
|
|
|
|
2023-11-25 18:08:56 +02:00
|
|
|
macro_rules! add_cliargs {
|
|
|
|
($d:ident,$section:expr,$i:ident) => {
|
|
|
|
$d.add_source(config::File::from_str(
|
|
|
|
&format!("[{}]\n{}", $section, toml::to_string($i).unwrap()),
|
|
|
|
config::FileFormat::Toml,
|
|
|
|
))
|
|
|
|
.build()
|
|
|
|
.unwrap()
|
2023-11-22 18:18:51 +02:00
|
|
|
};
|
|
|
|
}
|
2023-11-25 18:08:56 +02:00
|
|
|
|
|
|
|
use std::collections::{HashMap, HashSet};
|
|
|
|
pub fn auth(cli: &cli::Cli, config: config::ConfigBuilder<config::builder::DefaultState>) {
|
|
|
|
let config = add_cliargs!(config, "auth", cli);
|
|
|
|
let backends = config.get::<Vec<cli::Backend>>("auth.backends").unwrap();
|
|
|
|
for backend in backends {
|
|
|
|
let acl = match backend {
|
|
|
|
#[cfg(feature = "csv")]
|
|
|
|
cli::Backend::CSV => config.get::<cli::CSV>("csv").unwrap().to_config().new(),
|
|
|
|
};
|
|
|
|
match &cli.command {
|
|
|
|
cli::Command::Open(cliargs) => {
|
|
|
|
let found = acl.auth_user(
|
|
|
|
cliargs.method.clone(),
|
|
|
|
cliargs.identifier.clone(),
|
|
|
|
cliargs.resource.clone(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|