From 683d9222cbb056110dc334ff4347973b3bf34127 Mon Sep 17 00:00:00 2001 From: Ulysse Carion Date: Fri, 10 Jan 2025 10:30:49 -0800 Subject: [PATCH] scim: match /Users results in "Resources" or "resources" (#15) This PR has the SCIM matching logic support results from a SCIM `GET /Users` call being in `Resources` or `resources`. In practice, SCIM servers use both, due to inconsistency in the original specification. Closes #14. --- .nvmrc | 2 +- src/lib/app.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.nvmrc b/.nvmrc index 2ab3d4b..016e34b 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v16.20.2 +v20.17.0 diff --git a/src/lib/app.ts b/src/lib/app.ts index 4e6f989..4159d06 100644 --- a/src/lib/app.ts +++ b/src/lib/app.ts @@ -143,8 +143,12 @@ async function scimUserByEmail( headers: { Authorization: `Bearer ${app.scimBearerToken}` }, }); const listBody = await listResponse.json(); - if (listBody?.Resources?.length > 0) { - return listBody.Resources[0].id; + + // in practice, SCIM servers put the results into either `resources` or + // `Resources` + const resources = listBody?.resources ?? listBody?.Resources ?? [] + if (resources.length > 0) { + return resources[0].id; } return undefined; }