Skip to content

Commit

Permalink
New Feature: allow customizing the name of the strategy.
Browse files Browse the repository at this point in the history
Using this option, you instantiate the strategy multiple times with
different configurations.
  • Loading branch information
markstos committed Feb 14, 2018
1 parent 3165135 commit 594eed3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ passport.use(new SamlStrategy(
* `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.
* **Passport**
* `passReqToCallback`: if truthy, `req` will be passed as the first argument to the verify callback (default: `false`)
* `name`: Optionally, provide a custom name. (default: `saml`). Useful If you want to instantiate the strategy multiple times with different configurations,
allowing users to authenticate against multiple different SAML targets from the same site. You'll need to use a unique set of URLs
for each target, and use this custom name when calling `passport.authenticate()` as well.
* **Logout**
* `logoutUrl`: base address to call with logout requests (default: `entryPoint`)
* `additionalLogoutParams`: dictionary of additional query params to add to 'logout' requests
Expand Down
10 changes: 9 additions & 1 deletion lib/passport-saml/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ function Strategy (options, verify) {
throw new Error('SAML authentication strategy requires a verify function');
}

this.name = 'saml';
// Customizing the name can be useful to support multiple SAML configurations at the same time.
// Unlike other options, this one gets deleted instead of passed along.
if (options.name) {
this.name = options.name;
delete options.name;
}
else {
this.name = 'saml';
}

passport.Strategy.call(this);

Expand Down

0 comments on commit 594eed3

Please sign in to comment.