From d85a5db35ded601b08f27d28567db585932766f7 Mon Sep 17 00:00:00 2001 From: Sam Bostock Date: Mon, 8 Jan 2024 17:47:13 -0500 Subject: [PATCH 1/4] Fix formatting typo --- docs/metadata-distribution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/metadata-distribution.md b/docs/metadata-distribution.md index 78094b37..991ba1c0 100644 --- a/docs/metadata-distribution.md +++ b/docs/metadata-distribution.md @@ -2,7 +2,7 @@ ?> Metadata is used to exchange information between Identity Provider and Service Provider. Simply there are two major ways to exchange Metadata. -**Release in public ** +**Release in public** Display the Metadata in a specific URL. Everyone has the URL can watch the Metadata. Therefore, the Metadata is distributed publicly. We provide an API to do it once you've configure your SP. From 0f731c5f52331a984ce2c2ac96f7624c6cbe4734 Mon Sep 17 00:00:00 2001 From: Sam Bostock Date: Mon, 8 Jan 2024 19:55:26 -0500 Subject: [PATCH 2/4] Add missing attribute to xml --- test/misc/response.xml | 2 +- test/misc/response_signed.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/misc/response.xml b/test/misc/response.xml index fd3436ae..70e996d1 100644 --- a/test/misc/response.xml +++ b/test/misc/response.xml @@ -1 +1 @@ -https://idp.example.com/metadatahttps://idp.example.com/metadata_ce3d2948b4cf20146dee0a0b3dd6f69b6cf86f62d7https://sp.example.com/metadataurn:oasis:names:tc:SAML:2.0:ac:classes:Passwordtesttest@example.comusersexamplerole1 +https://idp.example.com/metadatahttps://idp.example.com/metadata_ce3d2948b4cf20146dee0a0b3dd6f69b6cf86f62d7https://sp.example.com/metadataurn:oasis:names:tc:SAML:2.0:ac:classes:Passwordtesttest@example.comusersexamplerole1 diff --git a/test/misc/response_signed.xml b/test/misc/response_signed.xml index ebaa1d16..a5a06a0c 100644 --- a/test/misc/response_signed.xml +++ b/test/misc/response_signed.xml @@ -1 +1 @@ -https://idp.example.com/metadatahttps://idp.example.com/metadata_ce3d2948b4cf20146dee0a0b3dd6f69b6cf86f62d7https://sp.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RO/khiXoJdbbOj7dHPULxVGbH9IbPK76TCwLbF7ikIMsPovVbTrpyL6vsbVUKeEl/5GKppTwp9DLAOeoSYpCYkkDkYKu9TRQjF02MCAwEAAaNQME4wHQYDVR0OBBYEFP2ut2AQdy6D1dwdwK740IHmbh38MB8GA1UdIwQYMBaAFP2ut2AQdy6D1dwdwK740IHmbh38MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBANMZUoPNmHzgja2PYkbvBYMHmpvUkVoiuvQ9cJPlqGTB2CRfG68BNNs/Clz8P7cIrAdkhCUwi1rSBhDuslGFNrSaIpv6B10FpBuKwef3G7YrPWFNEN6khY7aHNWSTHqKgs1DrGef2B9hvkrnHWbQVSVXrBFKe1wTCqcgGcOpYoSK7L8C6iX6uIA/uZYnVQ4NgBrizJ0azkjdegz3hwO/gt4malEURy8D85/AAVt6PAzhpb9VJUGxSXr/EfntVUEz3L2gUFWWk1CnZFyz0rIOEt/zPmeAY8BLyd/Tjxm4Y+gwNazKq5y9AJS+m858b/nM4QdCnUE4yyoWAJDUHiAmvFA= +https://idp.example.com/metadatahttps://idp.example.com/metadata_ce3d2948b4cf20146dee0a0b3dd6f69b6cf86f62d7https://sp.example.com/metadataurn:oasis:names:tc:SAML:2.0:ac:classes:Passwordtesttest@example.comusersexamplerole1sZOR3aMpVBn1CoSmP674OQfCcyg=h7Dk6GTh4MrNNx8b8Or12SeGsAGBM/ILd7Jgz/RuqR6ixMHrmkRAotou8LvKOzH9I9BfLthqgwcNJGm4hMPHcxoiyVlkqWqnpIMxlWc/vb1E/lXjwo86mZ/hBUJdRhgIfrgIDKCMBf98ftWtUF8I1Hd5qBvY7pTMk3ErQYOtqBfvCCFGwejAfOUKwtY4itQ7AILi4Er2IgALH0zJO7alPugTOwmICd998rafB2wAHWREJkaOfCgCasRkB8tqcWjpLx2oMqiYSTVq2d6PBgAFSmoN9ltO2neTz9pqd0BA1BKIi7PjQYN+F7dB/ffG7V8VjNoPMROrHzq6sY3Ond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/uZYnVQ4NgBrizJ0azkjdegz3hwO/gt4malEURy8D85/AAVt6PAzhpb9VJUGxSXr/EfntVUEz3L2gUFWWk1CnZFyz0rIOEt/zPmeAY8BLyd/Tjxm4Y+gwNazKq5y9AJS+m858b/nM4QdCnUE4yyoWAJDUHiAmvFA= From 98cc61f057d6ffe7dad13463db22058a99723237 Mon Sep 17 00:00:00 2001 From: Sam Bostock Date: Mon, 8 Jan 2024 17:34:47 -0500 Subject: [PATCH 3/4] Add test for valueless attribute Sometimes, the SAML server may not have an attribute value for a particular user: This adds an additional assertion, documenting the existing behavior. --- test/extractor.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/extractor.ts b/test/extractor.ts index 08584ffd..083581b9 100644 --- a/test/extractor.ts +++ b/test/extractor.ts @@ -108,6 +108,7 @@ const _spmeta: string = String(readFileSync('./test/misc/spmeta.xml')); t.is(result.attributes.uid, 'test'); t.is(result.attributes.mail, 'test@example.com'); t.is(result.attributes.eduPersonAffiliation.length, 2); + t.deepEqual(result.attributes.missing, []); }); test('fetch with one attribute as key, another as value', t => { From dc613239c200c57feb7f6fe10bc689b35ccd1e86 Mon Sep 17 00:00:00 2001 From: Sam Bostock Date: Mon, 8 Jan 2024 17:54:46 -0500 Subject: [PATCH 4/4] Return `null` instead of `[]` for valueless attribute Sometimes, the SAML server may not have an attribute value for a particular user: This changes the value returned in this case from `[]` to `null`. --- src/extractor.ts | 3 +++ test/extractor.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/extractor.ts b/src/extractor.ts index 104eaedf..f0cb59ac 100644 --- a/src/extractor.ts +++ b/src/extractor.ts @@ -279,6 +279,9 @@ export function extract(context: string, fields) { if (childValues.length === 1) { return childValues[0]; } + if (childValues.length === 0) { + return null; + } return childValues; } if (attributes.length > 0) { diff --git a/test/extractor.ts b/test/extractor.ts index 083581b9..03fb6188 100644 --- a/test/extractor.ts +++ b/test/extractor.ts @@ -108,7 +108,7 @@ const _spmeta: string = String(readFileSync('./test/misc/spmeta.xml')); t.is(result.attributes.uid, 'test'); t.is(result.attributes.mail, 'test@example.com'); t.is(result.attributes.eduPersonAffiliation.length, 2); - t.deepEqual(result.attributes.missing, []); + t.is(result.attributes.missing, null); }); test('fetch with one attribute as key, another as value', t => {