Skip to content

Commit d3d6e8f

Browse files
committed
Allow array values in claim checks
1 parent a3c6b11 commit d3d6e8f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

backend/src/lib/template/dot-access.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
export const getValueByDot = (
55
obj: Record<string, unknown> | null | undefined,
66
path: string,
7-
defaultValue?: string | number | boolean
8-
): string | number | boolean | undefined => {
7+
defaultValue?: string | number | boolean | string[]
8+
): string | number | boolean | string[] | undefined => {
99
// Handle null or undefined input
1010
if (!obj) {
1111
return defaultValue;
@@ -26,7 +26,12 @@ export const getValueByDot = (
2626
current = (current as Record<string, unknown>)[part];
2727
}
2828

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+
) {
3035
return defaultValue;
3136
}
3237

backend/src/services/identity-oidc-auth/identity-oidc-auth-fns.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import picomatch from "picomatch";
22

3-
export const doesFieldValueMatchOidcPolicy = (fieldValue: string | number | boolean, policyValue: string) => {
3+
export const doesFieldValueMatchOidcPolicy = (fieldValue: string | number | boolean | string[], policyValue: string) => {
44
if (typeof fieldValue === "boolean") {
55
return fieldValue === (policyValue === "true");
66
}
@@ -9,6 +9,10 @@ export const doesFieldValueMatchOidcPolicy = (fieldValue: string | number | bool
99
return fieldValue === parseInt(policyValue, 10);
1010
}
1111

12+
if (Array.isArray(fieldValue)) {
13+
return fieldValue.some((entry) => entry === policyValue || picomatch.isMatch(entry, policyValue));
14+
}
15+
1216
return policyValue === fieldValue || picomatch.isMatch(fieldValue, policyValue);
1317
};
1418

0 commit comments

Comments
 (0)