From 8713643bc1e2b3aa8d8f44c1322e2b12b76c5dcc Mon Sep 17 00:00:00 2001 From: Sheen Capadngan Date: Fri, 13 Dec 2024 14:02:32 +0800 Subject: [PATCH] misc: add support for number field values --- .../src/services/identity-jwt-auth/identity-jwt-auth-fns.ts | 6 +++++- .../services/identity-jwt-auth/identity-jwt-auth-service.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/services/identity-jwt-auth/identity-jwt-auth-fns.ts b/backend/src/services/identity-jwt-auth/identity-jwt-auth-fns.ts index 40fc87787..57aa933d6 100644 --- a/backend/src/services/identity-jwt-auth/identity-jwt-auth-fns.ts +++ b/backend/src/services/identity-jwt-auth/identity-jwt-auth-fns.ts @@ -1,9 +1,13 @@ import picomatch from "picomatch"; -export const doesFieldValueMatchJwtPolicy = (fieldValue: string | boolean, policyValue: string) => { +export const doesFieldValueMatchJwtPolicy = (fieldValue: string | boolean | number, policyValue: string) => { if (typeof fieldValue === "boolean") { return fieldValue === (policyValue === "true"); } + if (typeof fieldValue === "number") { + return fieldValue === parseInt(policyValue, 10); + } + return policyValue === fieldValue || picomatch.isMatch(fieldValue, policyValue); }; diff --git a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts index 35c40643c..5f8fc5ff6 100644 --- a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts +++ b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts @@ -75,7 +75,7 @@ export const identityJwtAuthServiceFactory = ({ }); } - let tokenData: Record = {}; + let tokenData: Record = {}; if (identityJwtAuth.configurationType === JwtConfigurationType.JWKS) { const decryptedJwksCaCert = orgDataKeyDecryptor({