Skip to content

Commit 6eb1eb3

Browse files
authored
Update README formatting and to provide clearer explanation of examples (#812)
1 parent 43ed346 commit 6eb1eb3

File tree

1 file changed

+38
-47
lines changed

1 file changed

+38
-47
lines changed

README.md

+38-47
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,13 @@ passport.use(
104104
);
105105
```
106106

107-
The options passed when the `MultiSamlStrategy` is initialized are also passed as default values to each provider.
108-
e.g. If you provide an `issuer` on `MultiSamlStrategy`, this will be also a default value for every provider.
109-
You can override these defaults by passing a new value through the `getSamlOptions` function.
107+
The options passed when the `MultiSamlStrategy` is initialized are also passed as default values to each provider. e.g. If you provide an `issuer` on `MultiSamlStrategy`, this will be also a default value for every provider. You can override these defaults by passing a new value through the `getSamlOptions` function.
110108

111109
Using multiple providers supports `validateInResponseTo`, but all the `InResponse` values are stored on the same Cache. This means, if you're using the default `InMemoryCache`, that all providers have access to it and a provider might get its response validated against another's request. [Issue Report](!https://github.com/node-saml/passport-saml/issues/334). To amend this you should provide a different cache provider per SAML provider, through the `getSamlOptions` function.
112110

113-
> :warning: **There's a race condition [bug](https://github.com/node-saml/passport-saml/issues/425) in versions < 1.3.3 which makes it vulnerable to DOS attacks**: Please use > 1.3.3 if you want to use this issue
111+
Please note that in the above examples, `findProvider()`, `findByNameId()`, and `findByEmail()` are an examples of functions you need to implement yourself. These are just examples. You can implement this functionality any way you see fit. Please note that calling `getSamlOptions()` should result in `done()` being called with a proper SAML Configuration (see the TypeScript typings for more information) and the `done()` callbacks for the second and third arguments should be called with an object that represents the user.
114112

115-
#### The profile object:
113+
#### The profile object
116114

117115
The profile object referenced above contains the following:
118116

@@ -135,9 +133,9 @@ export interface Profile {
135133
}
136134
```
137135

138-
#### Config parameter details:
136+
#### Config parameter details
139137

140-
**Core**
138+
##### **Core**
141139

142140
- `callbackUrl`: full callbackUrl (overrides path/protocol if supplied)
143141
- `path`: path to callback; will be combined with protocol and server host information to construct callback url if `callbackUrl` is not specified (default: `/saml/consume`)
@@ -153,7 +151,7 @@ export interface Profile {
153151
- `digestAlgorithm`: optionally set the digest algorithm used to provide a digest for the signed data object, valid values are 'sha1' (default), 'sha256', or 'sha512'
154152
- `xmlSignatureTransforms`: optionally set an array of signature transforms to be used in HTTP-POST signatures. By default this is `[ 'http://www.w3.org/2000/09/xmldsig#enveloped-signature', 'http://www.w3.org/2001/10/xml-exc-c14n#' ]`
155153

156-
**Additional SAML behaviors**
154+
##### **Additional SAML behaviors**
157155

158156
- `additionalParams`: dictionary of additional query params to add to all requests; if an object with this key is passed to `authenticate`, the dictionary of additional query params will be appended to those present on the returned URL, overriding any specified by initialization options' additional parameters (`additionalParams`, `additionalAuthorizeParams`, and `additionalLogoutParams`)
159157
- `additionalAuthorizeParams`: dictionary of additional query params to add to 'authorize' requests
@@ -174,7 +172,7 @@ export interface Profile {
174172
- `skipRequestCompression`: if set to true, the SAML request from the service provider won't be compressed.
175173
- `authnRequestBinding`: if set to `HTTP-POST`, will request authentication from IDP via HTTP POST binding, otherwise defaults to HTTP Redirect
176174
- `disableRequestAcsUrl`: if truthy, SAML AuthnRequest from the service provider will not include the optional AssertionConsumerServiceURL. Default is falsy so it is automatically included.
177-
- `scoping`: An optional configuration which implements the functionality [explained in the SAML spec paragraph "3.4.1.2 Element <Scoping>"](https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf). The config object is structured as following:
175+
- `scoping`: An optional configuration which implements the functionality [explained in the SAML spec paragraph "3.4.1.2 Element \<Scoping\>"](https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf). The config object is structured as following:
178176

179177
```javascript
180178
{
@@ -195,24 +193,24 @@ export interface Profile {
195193
};
196194
```
197195

198-
**InResponseTo Validation**
196+
##### **InResponseTo Validation**
199197

200198
- `validateInResponseTo`: if truthy, then InResponseTo will be validated from incoming SAML responses
201199
- `requestIdExpirationPeriodMs`: Defines the expiration time when a Request ID generated for a SAML request will not be valid if seen in a SAML response in the `InResponseTo` field. Default is 8 hours.
202200
- `cacheProvider`: Defines the implementation for a cache provider used to store request Ids generated in SAML requests as part of `InResponseTo` validation. Default is a built-in in-memory cache provider. For details see the 'Cache Provider' section.
203201

204-
**Issuer Validation**
202+
##### **Issuer Validation**
205203

206204
- `idpIssuer`: if provided, then the IdP issuer will be validated for incoming Logout Requests/Responses. For ADFS this looks like `https://acme_tools.windows.net/deadbeef`
207205

208-
**Passport**
206+
##### **Passport**
209207

210208
- `passReqToCallback`: if truthy, `req` will be passed as the first argument to the verify callback (default: `false`)
211209
- `name`: Optionally, provide a custom name. (default: `saml`). Useful If you want to instantiate the strategy multiple times with different configurations,
212210
allowing users to authenticate against multiple different SAML targets from the same site. You'll need to use a unique set of URLs
213211
for each target, and use this custom name when calling `passport.authenticate()` as well.
214212

215-
**Logout**
213+
##### **Logout**
216214

217215
- `logoutUrl`: base address to call with logout requests (default: `entryPoint`)
218216
- `additionalLogoutParams`: dictionary of additional query params to add to 'logout' requests
@@ -300,26 +298,26 @@ Formats supported for `privateKey` field are,
300298

301299
1. Well formatted PEM:
302300

303-
```text
304-
-----BEGIN PRIVATE KEY-----
305-
<private key contents here delimited at 64 characters per row>
306-
-----END PRIVATE KEY-----
301+
```text
302+
-----BEGIN PRIVATE KEY-----
303+
<private key contents here delimited at 64 characters per row>
304+
-----END PRIVATE KEY-----
307305
308-
```
306+
```
309307

310-
```text
311-
-----BEGIN RSA PRIVATE KEY-----
312-
<private key contents here delimited at 64 characters per row>
313-
-----END RSA PRIVATE KEY-----
308+
```text
309+
-----BEGIN RSA PRIVATE KEY-----
310+
<private key contents here delimited at 64 characters per row>
311+
-----END RSA PRIVATE KEY-----
314312
315-
```
313+
```
316314

317-
(both versions work)
318-
See example from tests of the first version of [well formatted private key](test/static/acme_tools_com.key).
315+
(both versions work)
316+
See example from tests of the first version of [well formatted private key](test/static/acme_tools_com.key).
319317

320-
2. Alternativelly a single line private key without start/end lines where all rows are joined into single line:
318+
1. Alternativelly a single line private key without start/end lines where all rows are joined into single line:
321319

322-
See example from tests of [singleline private key](test/static/singleline_acme_tools_com.key).
320+
See example from tests of [singleline private key](test/static/singleline_acme_tools_com.key).
323321

324322
Add it to strategy options like this:
325323

@@ -372,33 +370,23 @@ For more detailed instructions, see [ADFS documentation](docs/adfs/README.md).
372370

373371
## SAML Response Validation - NotBefore and NotOnOrAfter
374372

375-
If the `NotBefore` or the `NotOnOrAfter` attributes are returned in the SAML response, Passport-SAML will validate them
376-
against the current time +/- a configurable clock skew value. The default for the skew is 0s. This is to account for
377-
differences between the clock time on the client (Node server with Passport-SAML) and the server (Identity provider).
373+
If the `NotBefore` or the `NotOnOrAfter` attributes are returned in the SAML response, Passport-SAML will validate them against the current time +/- a configurable clock skew value. The default for the skew is 0s. This is to account for differences between the clock time on the client (Node server with Passport-SAML) and the server (Identity provider).
378374

379-
`NotBefore` and `NotOnOrAfter` can be part of either the `SubjectConfirmation` element, or within in the `Assertion/Conditions` element
380-
in the SAML response.
375+
`NotBefore` and `NotOnOrAfter` can be part of either the `SubjectConfirmation` element, or within in the `Assertion/Conditions` element in the SAML response.
381376

382377
## Subject confirmation validation
383378

384-
When configured (turn `validateInResponseTo` to `true` in the Passport-SAML config), the `InResponseTo` attribute will be validated.
385-
Validation will succeed if Passport-SAML previously generated a SAML request with an id that matches the value of `InResponseTo`.
379+
When configured (turn `validateInResponseTo` to `true` in the Passport-SAML config), the `InResponseTo` attribute will be validated. Validation will succeed if Passport-SAML previously generated a SAML request with an id that matches the value of `InResponseTo`.
386380

387-
Also note that `InResponseTo` is validated as an attribute of the top level `Response` element in the SAML response, as well
388-
as part of the `SubjectConfirmation` element.
381+
Also note that `InResponseTo` is validated as an attribute of the top level `Response` element in the SAML response, as well as part of the `SubjectConfirmation` element.
389382

390-
Previous request id's generated for SAML requests will eventually expire. This is controlled with the `requestIdExpirationPeriodMs` option
391-
passed into the Passport-SAML config. The default is 28,800,000 ms (8 hours). Once expired, a subsequent SAML response
392-
received with an `InResponseTo` equal to the expired id will not validate and an error will be returned.
383+
Previous request id's generated for SAML requests will eventually expire. This is controlled with the `requestIdExpirationPeriodMs` option passed into the Passport-SAML config. The default is 28,800,000 ms (8 hours). Once expired, a subsequent SAML response received with an `InResponseTo` equal to the expired id will not validate and an error will be returned.
393384

394385
## Cache Provider
395386

396-
When `InResponseTo` validation is turned on, Passport-SAML will store generated request ids used in SAML requests to the IdP. The implementation
397-
of how things are stored, checked to see if they exist, and eventually removed is from the Cache Provider used by Passport-SAML.
387+
When `InResponseTo` validation is turned on, Passport-SAML will store generated request ids used in SAML requests to the IdP. The implementation of how things are stored, checked to see if they exist, and eventually removed is from the Cache Provider used by Passport-SAML.
398388

399-
The default implementation is a simple in-memory cache provider. For multiple server/process scenarios, this will not be sufficient as
400-
the server/process that generated the request id and stored in memory could be different than the server/process handling the
401-
SAML response. The `InResponseTo` could fail in this case erroneously.
389+
The default implementation is a simple in-memory cache provider. For multiple server/process scenarios, this will not be sufficient as the server/process that generated the request id and stored in memory could be different than the server/process handling the SAML response. The `InResponseTo` could fail in this case erroneously.
402390

403391
To support this scenario you can provide an implementation for a cache provider by providing an object with following functions:
404392

@@ -436,7 +424,7 @@ See [Releases](https://github.com/node-saml/passport-saml/releases) to find the
436424

437425
### Is there an example I can look at?
438426

439-
Gerard Braad has provided an example app at https://github.com/gbraad/passport-saml-example/
427+
Gerard Braad has provided an example app at <https://github.com/gbraad/passport-saml-example/>
440428

441429
## Node Support Policy
442430

@@ -452,9 +440,12 @@ We will accept code that allows this package to run on newer, non-LTS, versions
452440

453441
## Project History
454442

455-
The project was started by @bergie in 2012 based on Michael Bosworth's [express-saml](https://github.com/bozzltron/express-saml) library. From 2014 - 2016, @ploer served as primary maintainer.
456-
@markstos served the primary maintainer from 2017 till 2020 when he created the node-saml organization. With a goal to create a team of maintainers, invitations were sent to major contributors and fork authors to work together to maintain all the improvements in one place.
443+
The project was started by @bergie in 2012 based on Michael Bosworth's [express-saml](https://github.com/bozzltron/express-saml) library. From 2014 - 2016, @ploer served as primary maintainer. @markstos served the primary maintainer from 2017 till 2020 when he created the node-saml organization. With a goal to create a team of maintainers, invitations were sent to major contributors and fork authors to work together to maintain all the improvements in one place.
457444

458445
Since 2020, @cjbath emerged as the primary maintainer, with major contributions from @gugu and @zoellner. Major updates from the team included rewriting the project in TypeScript and splitting off a `node-saml` module which can be used without Passport. Almost 100 other developers have contributed improvements to the project.
459446

460447
The project continues to be maintained by volunteers. Contributions small and large are welcome.
448+
449+
## Copyright Notices
450+
451+
[OASIS](http://www.oasis-open.org/)”, “SAML”, and “Security Assertion Markup Language” are trademarks of OASIS, the open standards consortium where the SAML specification is owned and developed. SAML is a copyrighted © work of OASIS Open. All rights reserved.

0 commit comments

Comments
 (0)