chore: WebServer in config as vector for Multiples Webs

This commit is contained in:
Jesús Pérez Lorenzo 2021-09-07 14:57:05 +01:00
parent 3c0922f8d0
commit b7733d50e4
5 changed files with 80 additions and 55 deletions

View file

@ -7,7 +7,7 @@ use tokio::sync::RwLock;
use casbin::prelude::*;
use warp::{Rejection};
use app_env::{AppStore,config::Config};
use app_env::{AppStore,config::WebServer};
use app_tools::{trim_newline,from_base64};
pub const BEARER_PREFIX: &str = "Bearer ";
@ -96,7 +96,7 @@ pub struct AuthStore {
impl AuthStore {
#[must_use]
pub fn new(config: &Config, enforcer: SharedEnforcer,verbose: &str) -> Self {
pub fn new(config: &WebServer, enforcer: SharedEnforcer,verbose: &str) -> Self {
Self {
users: Arc::new(RwLock::new(AuthStore::create_user_map(config,&verbose))),
shadows: Arc::new(RwLock::new(AuthStore::create_shadows_map(config,&verbose))),
@ -135,7 +135,7 @@ impl AuthStore {
shadows
}
#[must_use]
pub fn create_user_map(config: &Config,verbose: &str) -> HashMap<String, User> {
pub fn create_user_map(config: &WebServer,verbose: &str) -> HashMap<String, User> {
// TODO load form YAML o CONFIG
let mut usrs = HashMap::new();
match config.usrs_store.as_str() {
@ -150,7 +150,7 @@ impl AuthStore {
usrs
}
#[must_use]
pub fn create_shadows_map(config: &Config,verbose: &str) -> HashMap<String, UserShadow> {
pub fn create_shadows_map(config: &WebServer,verbose: &str) -> HashMap<String, UserShadow> {
// TODO load form YAML o CONFIG
let mut shadows = HashMap::new();
match config.usrs_shadow_store.as_str() {