openstack_keystone_core/config/
identity.rs1use serde::Deserialize;
15use std::collections::HashMap;
16
17use crate::config::common::default_sql_driver;
18
19#[derive(Debug, Deserialize, Clone)]
21pub struct IdentityProvider {
22 #[serde(default)]
24 pub caching: bool,
25
26 #[serde(default = "default_sql_driver")]
28 pub driver: String,
29
30 #[serde(default = "default_max_password_length")]
32 pub max_password_length: usize,
33
34 #[serde(default)]
36 pub password_hashing_algorithm: PasswordHashingAlgo,
37
38 pub password_hash_rounds: Option<usize>,
40
41 #[serde(default = "default_user_options_mapping")]
43 pub user_options_id_name_mapping: HashMap<String, String>,
44}
45
46impl Default for IdentityProvider {
47 fn default() -> Self {
48 Self {
49 caching: false,
50 driver: default_sql_driver(),
51 max_password_length: default_max_password_length(),
52 password_hashing_algorithm: PasswordHashingAlgo::Bcrypt,
53 password_hash_rounds: None,
54 user_options_id_name_mapping: default_user_options_mapping(),
55 }
56 }
57}
58
59#[derive(Debug, Default, Deserialize, Clone)]
61pub enum PasswordHashingAlgo {
62 #[default]
64 Bcrypt,
65 None,
69}
70
71fn default_user_options_mapping() -> HashMap<String, String> {
72 HashMap::from([
73 (
74 "1000".into(),
75 "ignore_change_password_upon_first_use".into(),
76 ),
77 ("1001".into(), "ignore_password_expiry".into()),
78 ("1002".into(), "ignore_lockout_failure_attempts".into()),
79 ("1003".into(), "lock_password".into()),
80 ("1004".into(), "ignore_user_inactivity".into()),
81 ("MFAR".into(), "multi_factor_auth_rules".into()),
82 ("MFAE".into(), "multi_factor_auth_rules".into()),
83 ])
84}
85
86fn default_max_password_length() -> usize {
87 4096
88}