From cc6249392e6cc2508307454540ed75d89100bc2f Mon Sep 17 00:00:00 2001 From: Eva Sarafianou Date: Thu, 13 May 2021 13:16:26 +0200 Subject: [PATCH] docs(readme): Document createUnsignedAssertion() --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ec066d6..2fef29e 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,12 @@ Create SAML assertions. Supports SAML 1.1 and SAML 2.0 tokens. ### Usage +#### Signed Assertions + ```js -var saml = require('saml').Saml20; // or Saml11 +const saml = require('saml').Saml20; // or Saml11 -var options = { +const options = { cert: fs.readFileSync(__dirname + '/test-auth0.pem'), key: fs.readFileSync(__dirname + '/test-auth0.key'), issuer: 'urn:issuer', @@ -23,10 +25,50 @@ var options = { sessionIndex: '_faed468a-15a0-4668-aed6-3d9c478cc8fa' }; -var signedAssertion = saml.create(options); +let samlAssertion = saml.create(options) + +// OR with callbacks + +saml.create(options, (err, samlAssertion) => { + if (err) { throw new Error(err) } + console.log(samlAssertion) +}) +``` + +All options except of the cert and key are optional. The function can be invoked +either synchronously or with callbacks, however if the `encryptionCert` option +has been passed in, the syncronous invocation is not possible + +#### Unsigned Assertions + +```js +const saml = require('saml').Saml20; // or Saml11 + +const options = { + issuer: 'urn:issuer', + lifetimeInSeconds: 600, + audiences: 'urn:myapp', + attributes: { + 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress': 'foo@bar.com', + 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name': 'Foo Bar' + }, + nameIdentifier: 'foo', + sessionIndex: '_faed468a-15a0-4668-aed6-3d9c478cc8fa' +}; + +let samlAssertion = saml.createUnsignedAssertion(options) + +// OR with callbacks + +saml.createUnsignedAssertion(options, (err, samlAssertion) => { + if (err) { throw new Error(err) } + console.log(samlAssertion) +}) ``` -Everything except the cert and key is optional. +All options are optional. The function can be invoked +either synchronously or with callbacks, however if the `encryptionCert` option +has been passed in, the syncronous invocation is not possible ## Issue Reporting