Skip to content

Commit

Permalink
⭐ feat: add RequestedAuthnContext Comparison Type parameter
Browse files Browse the repository at this point in the history
test: add test for check the option comparisonType
  • Loading branch information
osan15 committed Mar 19, 2019
1 parent b384277 commit 6aee893
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/adfs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ passport.use(new SamlStrategy(
acceptedClockSkewMs: -1,
identifierFormat: null,
// this is configured under the Advanced tab in AD FS relying party
signatureAlgorithm: 'sha256'
signatureAlgorithm: 'sha256',
comparisonType: 'exact', // default to exact RequestedAuthnContext Comparison Type
},
function(profile, done) {
return done(null,
Expand Down
13 changes: 12 additions & 1 deletion lib/passport-saml/saml.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ SAML.prototype.initialize = function (options) {
options.signatureAlgorithm = 'sha1';
}

/**
* List of possible values:
* - exact : Assertion context must exactly match a context in the list
* - minimum: Assertion context must be at least as strong as a context in the list
* - maximum: Assertion context must be no stronger than a context in the list
* - better: Assertion context must be stronger than all contexts in the list
*/
if (!options.comparisonType || ['exact','minimum','maximum','better'].indexOf(options.comparisonType) === -1){
options.comparisonType = 'exact';
}

return options;
};

Expand Down Expand Up @@ -202,7 +213,7 @@ SAML.prototype.generateAuthorizeRequest = function (req, isPassive, callback) {

request['samlp:AuthnRequest']['samlp:RequestedAuthnContext'] = {
'@xmlns:samlp': 'urn:oasis:names:tc:SAML:2.0:protocol',
'@Comparison': 'exact',
'@Comparison': self.options.comparisonType,
'saml:AuthnContextClassRef': authnContextClassRefs
};
}
Expand Down
13 changes: 13 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 6aee893

Please sign in to comment.