MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / extract_roles

Method extract_roles

crates/openshell-server/src/auth/oidc.rs:119–133  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 ///

Callers 5

validate_tokenMethod · 0.80
extract_roles_flat_pathFunction · 0.80

Calls 2

getMethod · 0.45
as_strMethod · 0.45

Tested by 4

extract_roles_flat_pathFunction · 0.64