Load a local identity by name, falling back to a case-insensitive match. Tenant slugs are lowercase (e.g. `aaron`), but locally stored identities are free-form and frequently mixed-case (e.g. `Aaron`). A subdomain-inferred name would therefore never match the local identity on a strict comparison. An exact match always wins; otherwise the first identity whose name matches case-insensitively is re
(store: &IdentityStore, name: &str)
| 228 | /// An exact match always wins; otherwise the first identity whose name matches |
| 229 | /// case-insensitively is returned. |
| 230 | fn load_identity_lenient(store: &IdentityStore, name: &str) -> Option<Identity> { |
| 231 | if let Ok(identity) = store.load_by_name(name) { |
| 232 | return Some(identity); |
| 233 | } |
| 234 | |
| 235 | let wanted = name.to_lowercase(); |
| 236 | store |
| 237 | .list() |
| 238 | .ok()? |
| 239 | .into_iter() |
| 240 | .find(|identity| identity.name.to_lowercase() == wanted) |
| 241 | } |
| 242 | |
| 243 | /// Resolve a concrete identity for a remote operation, falling back to the |
| 244 | /// default identity when the inferred name doesn't match any local identity. |
no test coverage detected