Skip to content

Commit

Permalink
support multiple authnContext
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbarth committed Sep 11, 2018
1 parent f8140aa commit 9820e32
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/passport-saml/saml.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ SAML.prototype.initialize = function (options) {
options.authnContext = "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport";
}

if (!Array.isArray(options.authnContext)) {
options.authnContext = [options.authnContext];
}

if (!options.acceptedClockSkewMs) {
// default to no skew
options.acceptedClockSkewMs = 0;
Expand Down Expand Up @@ -181,13 +185,18 @@ SAML.prototype.generateAuthorizeRequest = function (req, isPassive, callback) {
}

if (!self.options.disableRequestedAuthnContext) {
var authnContextClassRefs = [];
self.options.authnContext.forEach(function(value) {
authnContextClassRefs.push({
'@xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion',
'#text': value
});
});

request['samlp:AuthnRequest']['samlp:RequestedAuthnContext'] = {
'@xmlns:samlp': 'urn:oasis:names:tc:SAML:2.0:protocol',
'@Comparison': 'exact',
'saml:AuthnContextClassRef': {
'@xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion',
'#text': self.options.authnContext
}
'saml:AuthnContextClassRef': authnContextClassRefs
};
}

Expand Down
36 changes: 36 additions & 0 deletions test/tests.js

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

0 comments on commit 9820e32

Please sign in to comment.