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 #283

Closed
wants to merge 1 commit into from

Conversation

shunkica
Copy link
Contributor

@shunkica shunkica commented May 24, 2023

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>

@shunkica shunkica closed this May 24, 2023
@shunkica
Copy link
Contributor Author

Closed because I set the wrong source branch.
New PR: #285

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

Successfully merging this pull request may close these issues.

1 participant