File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
services/identity-oidc-auth Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 4
4
export const getValueByDot = (
5
5
obj : Record < string , unknown > | null | undefined ,
6
6
path : string ,
7
- defaultValue ?: string | number | boolean
8
- ) : string | number | boolean | undefined => {
7
+ defaultValue ?: string | number | boolean | string [ ]
8
+ ) : string | number | boolean | string [ ] | undefined => {
9
9
// Handle null or undefined input
10
10
if ( ! obj ) {
11
11
return defaultValue ;
@@ -26,7 +26,12 @@ export const getValueByDot = (
26
26
current = ( current as Record < string , unknown > ) [ part ] ;
27
27
}
28
28
29
- if ( typeof current !== "string" && typeof current !== "number" && typeof current !== "boolean" ) {
29
+ if (
30
+ typeof current !== "string" &&
31
+ typeof current !== "number" &&
32
+ typeof current !== "boolean" &&
33
+ ! Array . isArray ( current )
34
+ ) {
30
35
return defaultValue ;
31
36
}
32
37
Original file line number Diff line number Diff line change 1
1
import picomatch from "picomatch" ;
2
2
3
- export const doesFieldValueMatchOidcPolicy = ( fieldValue : string | number | boolean , policyValue : string ) => {
3
+ export const doesFieldValueMatchOidcPolicy = ( fieldValue : string | number | boolean | string [ ] , policyValue : string ) => {
4
4
if ( typeof fieldValue === "boolean" ) {
5
5
return fieldValue === ( policyValue === "true" ) ;
6
6
}
@@ -9,6 +9,10 @@ export const doesFieldValueMatchOidcPolicy = (fieldValue: string | number | bool
9
9
return fieldValue === parseInt ( policyValue , 10 ) ;
10
10
}
11
11
12
+ if ( Array . isArray ( fieldValue ) ) {
13
+ return fieldValue . some ( ( entry ) => entry === policyValue || picomatch . isMatch ( entry , policyValue ) ) ;
14
+ }
15
+
12
16
return policyValue === fieldValue || picomatch . isMatch ( fieldValue , policyValue ) ;
13
17
} ;
14
18
You can’t perform that action at this time.
0 commit comments