@@ -225,15 +225,16 @@ pub struct AuthenticatorClient {
225225impl AuthenticatorClient {
226226 /// Convert from a set of (verified!) access token claims into a [`ValidatedAccessToken`] struct.
227227 pub fn convert_token ( & self , access_token : AccessTokenClaims ) -> ValidatedAccessToken {
228+ let extra_values = & access_token. extended_claims ;
228229 let mut permissions = Self :: map_items (
229- Self :: extract_scopes ( & access_token . extended_claims , & self . scope_selector ) ,
230+ Self :: extract_scopes ( extra_values , & self . scope_selector ) ,
230231 & self . scope_mappings ,
231232 ) ;
232233 permissions. extend ( self . additional_permissions . clone ( ) ) ;
233234 let groups = self
234235 . group_selector
235236 . as_ref ( )
236- . map ( |selector| Self :: extract_groups ( & access_token . extended_claims , selector) )
237+ . map ( |selector| Self :: extract_groups ( extra_values , selector) )
237238 . unwrap_or_default ( ) ;
238239
239240 permissions. extend ( Self :: map_items ( groups, & self . group_mappings ) ) ;
@@ -246,24 +247,24 @@ impl AuthenticatorClient {
246247
247248 /// Extract scopes from the value/access token
248249 fn extract_scopes ( value : & Value , selector : & JpQuery ) -> Vec < String > {
249- js_path_process ( selector , value )
250- . ok ( )
251- . into_iter ( )
252- . flatten ( )
253- . flat_map ( |qr| match qr . val ( ) {
254- Value :: String ( s ) => s
255- . split_ascii_whitespace ( )
256- . map ( |s| s . to_string ( ) )
257- . collect :: < Vec < _ > > ( ) ,
258- Value :: Array ( arr ) => arr
259- . iter ( )
260- . filter_map ( |v| v . as_str ( ) )
261- . flat_map ( |s| s . split_ascii_whitespace ( ) )
262- . map ( |s| s . to_string ( ) )
263- . collect ( ) ,
264- _ => vec ! [ ] ,
265- } )
266- . collect ( )
250+ let mut result = Vec :: new ( ) ;
251+ for qr in js_path_process ( selector , value ) . ok ( ) . into_iter ( ) . flatten ( ) {
252+ match qr . val ( ) {
253+ Value :: String ( s ) => {
254+ result . extend ( s . split_ascii_whitespace ( ) . map ( str :: to_string ) ) ;
255+ }
256+ Value :: Array ( arr ) => {
257+ result . extend (
258+ arr . iter ( )
259+ . filter_map ( |v| v . as_str ( ) )
260+ . flat_map ( |s| s . split_ascii_whitespace ( ) )
261+ . map ( str :: to_string ) ,
262+ ) ;
263+ }
264+ _ => { }
265+ }
266+ }
267+ result
267268 }
268269
269270 /// Extract the groups from the value/access token
0 commit comments