mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 12:37:00 +01:00
Minor upgrade fixes (#2722)
This commit is contained in:
parent
acc800f00e
commit
58cfc8bdf9
|
@ -186,7 +186,11 @@ impl ServerConfig {
|
|||
} else {
|
||||
eprintln!("📜 No config file found at {:?}", config_path.as_ref());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eprintln!(
|
||||
"WARNING: No configuration path was provided, relying on environment variables."
|
||||
);
|
||||
};
|
||||
|
||||
// build from the environment variables
|
||||
let res = config.try_from_env().map_err(|e| {
|
||||
|
|
|
@ -24,6 +24,7 @@ use sketching::LogLevel;
|
|||
use std::os::unix::fs::MetadataExt;
|
||||
use std::path::PathBuf;
|
||||
use std::process::ExitCode;
|
||||
use std::str::FromStr;
|
||||
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
use futures::{SinkExt, StreamExt};
|
||||
|
@ -319,7 +320,26 @@ async fn kanidm_main() -> ExitCode {
|
|||
let mut config_error: Vec<String> = Vec::new();
|
||||
let mut config = Configuration::new();
|
||||
|
||||
let sconfig = match ServerConfig::new(opt.config_path()) {
|
||||
let Ok(default_config_path) = PathBuf::from_str(env!("KANIDM_DEFAULT_CONFIG_PATH")) else {
|
||||
eprintln!("CRITICAL: Kanidmd was not built correctly and is missing a valid KANIDM_DEFAULT_CONFIG_PATH value");
|
||||
return ExitCode::FAILURE;
|
||||
};
|
||||
|
||||
let maybe_config_path = if let Some(p) = opt.config_path() {
|
||||
Some(p)
|
||||
} else {
|
||||
// The user didn't ask for a file, lets check if the default path exists?
|
||||
if default_config_path.exists() {
|
||||
// It does, lets use it.
|
||||
Some(default_config_path)
|
||||
} else {
|
||||
// No default config, and no config specified, lets assume the user
|
||||
// has selected environment variables.
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
let sconfig = match ServerConfig::new(maybe_config_path) {
|
||||
Ok(c) => Some(c),
|
||||
Err(e) => {
|
||||
config_error.push(format!("Config Parse failure {:?}", e));
|
||||
|
|
|
@ -100,16 +100,20 @@ impl TokenInstance {
|
|||
|
||||
#[derive(Debug, Serialize, Clone, Deserialize, Default)]
|
||||
pub struct TokenStore {
|
||||
instances: BTreeMap<Option<String>, TokenInstance>,
|
||||
instances: BTreeMap<String, TokenInstance>,
|
||||
}
|
||||
|
||||
impl TokenStore {
|
||||
pub fn instances(&self, name: &Option<String>) -> Option<&TokenInstance> {
|
||||
self.instances.get(name)
|
||||
let n_lookup = name.clone().unwrap_or_else(|| "".to_string());
|
||||
|
||||
self.instances.get(&n_lookup)
|
||||
}
|
||||
|
||||
pub fn instances_mut(&mut self, name: &Option<String>) -> Option<&mut TokenInstance> {
|
||||
self.instances.get_mut(name)
|
||||
let n_lookup = name.clone().unwrap_or_else(|| "".to_string());
|
||||
|
||||
self.instances.get_mut(&n_lookup)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,7 +413,8 @@ async fn process_auth_state(
|
|||
let mut tokens = read_tokens(&client.get_token_cache_path()).unwrap_or_default();
|
||||
|
||||
// Select our token instance. Create it if empty.
|
||||
let token_instance = tokens.instances.entry(instance_name.clone()).or_default();
|
||||
let n_lookup = instance_name.clone().unwrap_or_else(|| "".to_string());
|
||||
let token_instance = tokens.instances.entry(n_lookup).or_default();
|
||||
|
||||
// Add our new one
|
||||
let (spn, tonk) = match client.get_token().await {
|
||||
|
@ -480,6 +485,7 @@ async fn process_auth_state(
|
|||
|
||||
// write them out.
|
||||
if write_tokens(&tokens, &client.get_token_cache_path()).is_err() {
|
||||
trace!(?tokens);
|
||||
error!("Error persisting authentication token store");
|
||||
std::process::exit(1);
|
||||
};
|
||||
|
@ -669,7 +675,8 @@ impl LogoutOpt {
|
|||
std::process::exit(1);
|
||||
});
|
||||
|
||||
let Some(token_instance) = tokens.instances.get_mut(instance_name) else {
|
||||
let n_lookup = instance_name.clone().unwrap_or_else(|| "".to_string());
|
||||
let Some(token_instance) = tokens.instances.get_mut(&n_lookup) else {
|
||||
println!("No sessions for {}", spn);
|
||||
return;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue