Skip to content

Commit cc62493

Browse files
author
Eva Sarafianou
committed
docs(readme): Document createUnsignedAssertion()
1 parent 7ee7984 commit cc62493

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

README.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ Create SAML assertions. Supports SAML 1.1 and SAML 2.0 tokens.
66

77
### Usage
88

9+
#### Signed Assertions
10+
911
```js
10-
var saml = require('saml').Saml20; // or Saml11
12+
const saml = require('saml').Saml20; // or Saml11
1113

12-
var options = {
14+
const options = {
1315
cert: fs.readFileSync(__dirname + '/test-auth0.pem'),
1416
key: fs.readFileSync(__dirname + '/test-auth0.key'),
1517
issuer: 'urn:issuer',
@@ -23,10 +25,50 @@ var options = {
2325
sessionIndex: '_faed468a-15a0-4668-aed6-3d9c478cc8fa'
2426
};
2527

26-
var signedAssertion = saml.create(options);
28+
let samlAssertion = saml.create(options)
29+
30+
// OR with callbacks
31+
32+
saml.create(options, (err, samlAssertion) => {
33+
if (err) { throw new Error(err) }
34+
console.log(samlAssertion)
35+
})
36+
```
37+
38+
All options except of the cert and key are optional. The function can be invoked
39+
either synchronously or with callbacks, however if the `encryptionCert` option
40+
has been passed in, the syncronous invocation is not possible
41+
42+
#### Unsigned Assertions
43+
44+
```js
45+
const saml = require('saml').Saml20; // or Saml11
46+
47+
const options = {
48+
issuer: 'urn:issuer',
49+
lifetimeInSeconds: 600,
50+
audiences: 'urn:myapp',
51+
attributes: {
52+
'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress': '[email protected]',
53+
'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name': 'Foo Bar'
54+
},
55+
nameIdentifier: 'foo',
56+
sessionIndex: '_faed468a-15a0-4668-aed6-3d9c478cc8fa'
57+
};
58+
59+
let samlAssertion = saml.createUnsignedAssertion(options)
60+
61+
// OR with callbacks
62+
63+
saml.createUnsignedAssertion(options, (err, samlAssertion) => {
64+
if (err) { throw new Error(err) }
65+
console.log(samlAssertion)
66+
})
2767
```
2868

29-
Everything except the cert and key is optional.
69+
All options are optional. The function can be invoked
70+
either synchronously or with callbacks, however if the `encryptionCert` option
71+
has been passed in, the syncronous invocation is not possible
3072

3173
## Issue Reporting
3274

0 commit comments

Comments
 (0)