Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use inclusiveNamespacesPrefixList to generate InclusiveNamespaces #284

Merged
merged 7 commits into from
May 28, 2023

Conversation

shunkica
Copy link
Contributor

@shunkica shunkica commented May 24, 2023

Currently, the inclusiveNamespacesPrefixList property on the Reference interface is only used during loading of references.
This change would allow the use of the same property during the creation of references to add a InclusiveNamespaces element.

Example:

sig.addReference(
    "//*[local-name(.)='Timestamp']",
    ["http://www.w3.org/2001/10/xml-exc-c14n#"],
    'http://www.w3.org/2000/09/xmldsig#sha1',
    '','',
    'wsse soapenc soapenv xsd xsi');

Result:

<ds:Reference URI="#TS-b3f4bfa7-fe3b-4ee1-aa8c-289ee7de442b">
  <ds:Transforms>
    <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
       <InclusiveNamespaces PrefixList="wsse soapenc soapenv xsd xsi"
          xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/>
     </ds:Transform>
   </ds:Transforms>
   <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
   <ds:DigestValue>DGrj1zr8K0OsBojzMSMVowotX60=</ds:DigestValue>
</ds:Reference>

Added inclusiveNamespacesPrefixList property to SignedXML options, which if present generates InclusiveNamespaces element inside CanonicalizationMethod.

Example:

const sig = new SignedXml(null, {idAttribute: 'Id', inclusiveNamespacesPrefixList: 'soapenc soapenv xsd xsi'});

Result:

<ds:Signature Id="SIG-0271048c-6ea7-4e9d-85e2-1819c3ce3848" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
  <ds:SignedInfo>
    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
      <InclusiveNamespaces PrefixList="soapenc soapenv xsd xsi"
        xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/>
      </ds:CanonicalizationMethod>

lib/signed-xml.js Outdated Show resolved Hide resolved
lib/signed-xml.js Outdated Show resolved Hide resolved
@cjbarth cjbarth merged commit c6848e7 into node-saml:master May 28, 2023
@shunkica
Copy link
Contributor Author

This pull request closes #228, #189, #138 and #60

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants