Extract roles from the JWT claims using a dot-separated path. Supports paths like: - `realm_access.roles` (Keycloak) - `roles` (Entra ID) - `groups` (Okta)
(&mut self, roles_claim: &str)
| 117 | /// - `roles` (Entra ID) |
| 118 | /// - `groups` (Okta) |
| 119 | fn extract_roles(&mut self, roles_claim: &str) { |
| 120 | let mut value = &self.extra; |
| 121 | for segment in roles_claim.split('.') { |
| 122 | match value.get(segment) { |
| 123 | Some(v) => value = v, |
| 124 | None => return, |
| 125 | } |
| 126 | } |
| 127 | if let Some(arr) = value.as_array() { |
| 128 | self.roles = arr |
| 129 | .iter() |
| 130 | .filter_map(|v| v.as_str().map(String::from)) |
| 131 | .collect(); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | /// Extract scopes from the JWT claims using a dot-separated path. |
| 136 | /// |