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)
| 194 | /// An exact match always wins; otherwise the first identity whose name matches |
| 195 | /// case-insensitively is returned. |
| 196 | fn load_identity_lenient(store: &IdentityStore, name: &str) -> Option<Identity> { |
| 197 | if let Ok(identity) = store.load_by_name(name) { |
| 198 | return Some(identity); |
| 199 | } |
| 200 | |
| 201 | let wanted = name.to_lowercase(); |
| 202 | store |
| 203 | .list() |
| 204 | .ok()? |
| 205 | .into_iter() |
| 206 | .find(|identity| identity.name.to_lowercase() == wanted) |
| 207 | } |
| 208 | |
| 209 | /// Resolve a concrete identity for a remote operation, falling back to the |
| 210 | /// default identity when the inferred name doesn't match any local identity. |
no test coverage detected