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

Add support for appending attributes to KeyInfo element #285

Merged
merged 3 commits into from
May 29, 2023

Conversation

shunkica
Copy link
Contributor

Added a new optional property, attrs, to the KeyInfo interface.
The attrs property is an object that holds key-value pairs representing the attributes and their corresponding values.
When present, these attributes will be appended to the KeyInfo element during XML generation.

Example:

sig.keyInfoProvider = {
    getKeyInfo: () => {
        return `<wsse:SecurityTokenReference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="STR-${securityTokenReferenceGuid}">`
            + `<wsse:Reference URI="#X509-${randomUUID()}" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>`
            + `</wsse:SecurityTokenReference>`
    },
    getKey: () => Buffer.from(privateKey),
    attrs: {
        Id: `KI-${randomUUID()}`,
    }
};

Result:

<ds:KeyInfo Id="KI-a8bb2a1a-32dd-449e-9bf0-187dd8ea4ee6">
  <wsse:SecurityTokenReference wsu:Id="STR-0096ce19-3fbf-414f-94e9-f7a0d601b3f4">
    <wsse:Reference URI="#X509-8cc9b13b-ee21-426e-b8d1-75cddddbe6e5"
      ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
  </wsse:SecurityTokenReference>
</ds:KeyInfo>

@cjbarth cjbarth merged commit 8960954 into node-saml:master May 29, 2023
@shunkica shunkica deleted the keyinfo-attributes branch May 29, 2023 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants