Authenticate using registry - part 2
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::{
|
||||
use ahash::AHashMap;
|
||||
use registry::schema::{
|
||||
prelude::Object,
|
||||
structs::{self, Authentication},
|
||||
structs::{self, DefaultDirectory},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use store::registry::bootstrap::Bootstrap;
|
||||
@@ -40,21 +40,23 @@ impl Directories {
|
||||
}
|
||||
}
|
||||
|
||||
let mut default_directory = None;
|
||||
let auth = bp.setting_infallible::<Authentication>().await;
|
||||
if let Some(id) = auth.directory_id {
|
||||
if let Some(directory) = directories.get(&id) {
|
||||
default_directory = Some(directory.clone());
|
||||
} else {
|
||||
bp.build_error(
|
||||
Object::Authentication.singleton(),
|
||||
format!("Default directory with id {} not found", id),
|
||||
);
|
||||
}
|
||||
}
|
||||
let default_directory = match bp.setting_infallible::<DefaultDirectory>().await {
|
||||
DefaultDirectory::Internal => Ok(None),
|
||||
DefaultDirectory::Ldap(directory) => LdapDirectory::open(directory).map(Some),
|
||||
DefaultDirectory::Sql(directory) => SqlDirectory::open(directory, &bp.data_store)
|
||||
.await
|
||||
.map(Some),
|
||||
DefaultDirectory::Oidc(directory) => OpenIdDirectory::open(directory).map(Some),
|
||||
};
|
||||
|
||||
Directories {
|
||||
default_directory,
|
||||
default_directory: match default_directory {
|
||||
Ok(default_directory) => default_directory.map(Arc::new),
|
||||
Err(err) => {
|
||||
bp.build_error(Object::DefaultDirectory.singleton(), err);
|
||||
None
|
||||
}
|
||||
},
|
||||
directories,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user