Skip to content

Commit 64562b3

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

1 file changed

Lines changed: 44 additions & 2 deletions

File tree

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Create SAML assertions. Supports SAML 1.1 and SAML 2.0 tokens.
66

77
### Usage
88

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

@@ -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+
var saml = require('saml').Saml20; // or Saml11
46+
47+
var 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': 'foo@bar.com',
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)