Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate issuer on logout requests/responses if configured #314

Merged
merged 1 commit into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ type Profile = {
* `validateInResponseTo`: if truthy, then InResponseTo will be validated from incoming SAML responses
* `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.
* `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.
* **Issuer Validation**
* `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`
* **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,
Expand Down
14 changes: 8 additions & 6 deletions lib/passport-saml/saml.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,12 +845,14 @@ SAML.prototype.verifyLogoutResponse = function (doc) {
};

SAML.prototype.verifyIssuer = function (samlMessage) {
var issuer = samlMessage.Issuer;
if (issuer && this.options.samlIssuer) {
if (issuer[0] !== this.options.samlIssuer && issuer[0]._ !== this.options.samlIssuer)
throw 'Unknown SAML issuer. Expected: ' + this.options.samlIssuer + ' Received: ' + issuer[0];
} else {
throw 'Missing SAML issuer';
if(this.options.idpIssuer) {
var issuer = samlMessage.Issuer;
if (issuer) {
if (issuer[0] !== this.options.idpIssuer && issuer[0]._ !== this.options.idpIssuer)
throw 'Unknown SAML issuer. Expected: ' + this.options.idpIssuer + ' Received: ' + issuer[0];
} else {
throw 'Missing SAML issuer';
}
}
};

Expand Down
12 changes: 6 additions & 6 deletions test/tests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.