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.
This commit is contained in:
Ulysse Carion 2025-01-10 10:30:49 -08:00 committed by GitHub
parent b0f1e44617
commit 683d9222cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

2
.nvmrc
View File

@ -1 +1 @@
v16.20.2
v20.17.0

View File

@ -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;
}