From e7b86b06cf1b97e3467ed8d3a474b1f79c997ac0 Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Mon, 2 Jan 2017 16:26:23 +0530
Subject: [PATCH 01/17] to support multiple authnContext
---
lib/passport-saml/saml.js | 13 +++++++++----
package.json | 2 +-
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/lib/passport-saml/saml.js b/lib/passport-saml/saml.js
index 2ef65955..1c80d5eb 100644
--- a/lib/passport-saml/saml.js
+++ b/lib/passport-saml/saml.js
@@ -181,13 +181,18 @@ SAML.prototype.generateAuthorizeRequest = function (req, isPassive, callback) {
}
if (!self.options.disableRequestedAuthnContext) {
+ var authnContextInArray = [];
+ Object.keys(self.options.authnContext).forEach(function(k) {
+ authnContextInArray.push({
+ '@xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion',
+ '#text': self.options.authnContext[k]
+ });
+ });
+
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': authnContextInArray
};
}
diff --git a/package.json b/package.json
index 20aa10ef..5f4211b0 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
"xml2js": "0.4.x",
"xml-crypto": "0.8.x",
"xmldom": "0.1.x",
- "xmlbuilder": "2.5.x",
+ "xmlbuilder": "4.1.x",
"xml-encryption": "~0.7"
},
"devDependencies": {
From 03b07cb74f42223ef0e55b5b97b09dd2b7da0818 Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Mon, 2 Jan 2017 17:06:05 +0530
Subject: [PATCH 02/17] to support multiple authnContext: modified array
looping code as per error log
---
lib/passport-saml/saml.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/passport-saml/saml.js b/lib/passport-saml/saml.js
index 1c80d5eb..86624d34 100644
--- a/lib/passport-saml/saml.js
+++ b/lib/passport-saml/saml.js
@@ -182,7 +182,7 @@ SAML.prototype.generateAuthorizeRequest = function (req, isPassive, callback) {
if (!self.options.disableRequestedAuthnContext) {
var authnContextInArray = [];
- Object.keys(self.options.authnContext).forEach(function(k) {
+ self.options.authnContext.forEach(function(k) {
authnContextInArray.push({
'@xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion',
'#text': self.options.authnContext[k]
From 8ce370696c509964b88241e1bbdc9dd1c4a34621 Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 11:15:45 +0530
Subject: [PATCH 03/17] to support multiple authnContext: modified based on the
unit test case
---
lib/passport-saml/saml.js | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/passport-saml/saml.js b/lib/passport-saml/saml.js
index 86624d34..c62feb6f 100644
--- a/lib/passport-saml/saml.js
+++ b/lib/passport-saml/saml.js
@@ -180,15 +180,15 @@ SAML.prototype.generateAuthorizeRequest = function (req, isPassive, callback) {
};
}
- if (!self.options.disableRequestedAuthnContext) {
- var authnContextInArray = [];
- self.options.authnContext.forEach(function(k) {
+ if (!self.options.disableRequestedAuthnContext) {
+ var authnContextInArray = [];
+ self.options.authnContext.split(',').forEach(function(value, index) {
authnContextInArray.push({
- '@xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion',
- '#text': self.options.authnContext[k]
- });
+ '@xmlns:saml': 'urn:oasis:names:tc:SAML:2.0:assertion',
+ '#text': self.options.authnContext.split(',')[index]
+ });
});
-
+
request['samlp:AuthnRequest']['samlp:RequestedAuthnContext'] = {
'@xmlns:samlp': 'urn:oasis:names:tc:SAML:2.0:protocol',
'@Comparison': 'exact',
From ce930199799ecf924088fc20a08bdf17337c42ea Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 11:30:04 +0530
Subject: [PATCH 04/17] to support multiple authnContext: test results are
modified based on the new xml parser
---
test/static/expected metadata.xml | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/test/static/expected metadata.xml b/test/static/expected metadata.xml
index b915723f..47adede8 100644
--- a/test/static/expected metadata.xml
+++ b/test/static/expected metadata.xml
@@ -33,9 +33,15 @@ nwtlCg==
-
-
-
+ <#list>
+ "
+ #list>
+ <#list>
+ "
+ #list>
+ <#list>
+ "
+ #list>
urn:oasis:names:tc:SAML:2.0:nameid-format:transient
From 63ff3b7a41940f38d764eed2a4dcf56715bdd931 Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 11:34:34 +0530
Subject: [PATCH 05/17] to support multiple authnContext: test results are
modified based on the new xml parser: corrected a minor syntax error
---
test/static/expected metadata.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/static/expected metadata.xml b/test/static/expected metadata.xml
index 47adede8..82e86153 100644
--- a/test/static/expected metadata.xml
+++ b/test/static/expected metadata.xml
@@ -34,13 +34,13 @@ nwtlCg==
<#list>
- "
+
#list>
<#list>
- "
+
#list>
<#list>
- "
+
#list>
urn:oasis:names:tc:SAML:2.0:nameid-format:transient
From 67dd725f0751b74d95d6b6b81a0fa2f7bdb38cf0 Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 11:40:06 +0530
Subject: [PATCH 06/17] to support multiple authnContext: test results are
modified based on the new xml parser: corrected a minor syntax error#2
---
test/static/expected metadata.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/static/expected metadata.xml b/test/static/expected metadata.xml
index 82e86153..40a6745a 100644
--- a/test/static/expected metadata.xml
+++ b/test/static/expected metadata.xml
@@ -34,13 +34,13 @@ nwtlCg==
<#list>
-
+
#list>
<#list>
-
+
#list>
<#list>
-
+
#list>
urn:oasis:names:tc:SAML:2.0:nameid-format:transient
From dc0a7bc156cb0612ee4d82ff29a83fb3ac8c1a5e Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 11:47:16 +0530
Subject: [PATCH 07/17] to support multiple authnContext: test results are
modified based on the new xml parser: corrected a minor syntax error#3
---
test/static/expected metadata.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/test/static/expected metadata.xml b/test/static/expected metadata.xml
index 40a6745a..1f8d97e7 100644
--- a/test/static/expected metadata.xml
+++ b/test/static/expected metadata.xml
@@ -34,13 +34,13 @@ nwtlCg==
<#list>
-
- #list>
+
+ #list>
<#list>
-
+
#list>
<#list>
-
+
#list>
urn:oasis:names:tc:SAML:2.0:nameid-format:transient
From 182f774b2666964c4b3b5e30c655f6acf31ae9c4 Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 12:00:16 +0530
Subject: [PATCH 08/17] to support multiple authnContext: test case syntax
modified for statble version of node3
---
test/tests.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/tests.js b/test/tests.js
index 4e520295..119dbc13 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -163,9 +163,9 @@ describe( 'passport-saml /', function() {
response.statusCode.should.equal(check.expectedStatusCode);
if (response.statusCode == 200) {
should.exist(passedRequest);
- passedRequest.url.should.eql('/login');
- passedRequest.method.should.eql('POST');
- passedRequest.body.should.eql(check.samlResponse);
+ passedRequest.url.should.equal('/login');
+ passedRequest.method.should.equal('POST');
+ passedRequest.body.should.equal(check.samlResponse);
} else {
should.not.exist(passedRequest);
}
From bb6af8d4cba5ef1132e9f3ab9544ad9e34e85c13 Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 12:16:01 +0530
Subject: [PATCH 09/17] to support multiple authnContext: test case syntax
modified for statble version of node#1
---
test/tests.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/tests.js b/test/tests.js
index 119dbc13..4e520295 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -163,9 +163,9 @@ describe( 'passport-saml /', function() {
response.statusCode.should.equal(check.expectedStatusCode);
if (response.statusCode == 200) {
should.exist(passedRequest);
- passedRequest.url.should.equal('/login');
- passedRequest.method.should.equal('POST');
- passedRequest.body.should.equal(check.samlResponse);
+ passedRequest.url.should.eql('/login');
+ passedRequest.method.should.eql('POST');
+ passedRequest.body.should.eql(check.samlResponse);
} else {
should.not.exist(passedRequest);
}
From 7378125d8f6dba0a931492fd50d3d0727b50d02a Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 14:30:00 +0530
Subject: [PATCH 10/17] to support multiple authnContext: test case syntax
modified for statble version of node#2
---
test/tests.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/test/tests.js b/test/tests.js
index 4e520295..a87cf7ca 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -161,6 +161,7 @@ describe( 'passport-saml /', function() {
request(requestOpts, function (err, response, body) {
should.not.exist(err);
response.statusCode.should.equal(check.expectedStatusCode);
+ console.log(passedRequest, "passedRequest")
if (response.statusCode == 200) {
should.exist(passedRequest);
passedRequest.url.should.eql('/login');
From 3ec62275f0a61fd1e8ae3b7dcbef076265685c8c Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 14:36:09 +0530
Subject: [PATCH 11/17] to support multiple authnContext: test case syntax
modified for statble version of node#3
---
test/tests.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/test/tests.js b/test/tests.js
index a87cf7ca..eb53e034 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -161,8 +161,10 @@ describe( 'passport-saml /', function() {
request(requestOpts, function (err, response, body) {
should.not.exist(err);
response.statusCode.should.equal(check.expectedStatusCode);
- console.log(passedRequest, "passedRequest")
+
if (response.statusCode == 200) {
+ console.log(passedRequest.body, "passedRequest")
+ console.log(check.samlResponse, "check.samlResponse")
should.exist(passedRequest);
passedRequest.url.should.eql('/login');
passedRequest.method.should.eql('POST');
From 39f13b464ff470272b08394b18edfb5989dc0f1d Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 14:45:18 +0530
Subject: [PATCH 12/17] to support multiple authnContext: test case syntax
modified for statble version of node#4
---
test/tests.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/tests.js b/test/tests.js
index eb53e034..38abddb0 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -163,8 +163,8 @@ describe( 'passport-saml /', function() {
response.statusCode.should.equal(check.expectedStatusCode);
if (response.statusCode == 200) {
- console.log(passedRequest.body, "passedRequest")
- console.log(check.samlResponse, "check.samlResponse")
+ console.log((passedRequest.body === check.samlResponse), "is it same")
+
should.exist(passedRequest);
passedRequest.url.should.eql('/login');
passedRequest.method.should.eql('POST');
From fb82ad89e752042480d6b3669dedfdcd80b4f0e5 Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 14:48:08 +0530
Subject: [PATCH 13/17] to support multiple authnContext: test case syntax
modified for statble version of node#5
---
test/tests.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/tests.js b/test/tests.js
index 38abddb0..ac292865 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -163,7 +163,7 @@ describe( 'passport-saml /', function() {
response.statusCode.should.equal(check.expectedStatusCode);
if (response.statusCode == 200) {
- console.log((passedRequest.body === check.samlResponse), "is it same")
+ console.log((passedRequest.body == check.samlResponse), "is it same")
should.exist(passedRequest);
passedRequest.url.should.eql('/login');
From c0359221dbc75f17670e9db56f1c913e04633c5f Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 15:04:30 +0530
Subject: [PATCH 14/17] to support multiple authnContext: test case syntax
modified for statble version of node#6
---
test/tests.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/tests.js b/test/tests.js
index ac292865..cc02cbe9 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -168,7 +168,7 @@ describe( 'passport-saml /', function() {
should.exist(passedRequest);
passedRequest.url.should.eql('/login');
passedRequest.method.should.eql('POST');
- passedRequest.body.should.eql(check.samlResponse);
+ passedRequest.body.should.eql?(check.samlResponse);
} else {
should.not.exist(passedRequest);
}
From 13110f39f97a2b4a640521e864272d1d9825ac40 Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 15:09:08 +0530
Subject: [PATCH 15/17] to support multiple authnContext: test case syntax
modified for statble version of node#7
---
test/tests.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/tests.js b/test/tests.js
index cc02cbe9..ac292865 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -168,7 +168,7 @@ describe( 'passport-saml /', function() {
should.exist(passedRequest);
passedRequest.url.should.eql('/login');
passedRequest.method.should.eql('POST');
- passedRequest.body.should.eql?(check.samlResponse);
+ passedRequest.body.should.eql(check.samlResponse);
} else {
should.not.exist(passedRequest);
}
From c25e7f277d9f96bffe48d38ffeac58ec5f805de3 Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 15:16:48 +0530
Subject: [PATCH 16/17] to support multiple authnContext: test case syntax
modified for statble version of node#8
---
test/tests.js | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/test/tests.js b/test/tests.js
index ac292865..a5243abc 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -163,6 +163,10 @@ describe( 'passport-saml /', function() {
response.statusCode.should.equal(check.expectedStatusCode);
if (response.statusCode == 200) {
+ console.log(passedRequest.url, "passedRequest.url")
+ console.log(passedRequest.method, "passedRequest.method")
+ console.log(passedRequest.body, "passedRequest.body")
+ console.log(check.samlResponse, "check.samlResponse")
console.log((passedRequest.body == check.samlResponse), "is it same")
should.exist(passedRequest);
From 06a2257e7db2c6fa1d1835925f8ad029a1f32c60 Mon Sep 17 00:00:00 2001
From: DHIVIYA BHARATHI A <584720@India.TCS.com>
Date: Tue, 3 Jan 2017 15:28:39 +0530
Subject: [PATCH 17/17] to support multiple authnContext: test case syntax
modified for statble version of node#9
---
test/samlTests.js | 2 +-
test/tests.js | 8 +-------
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/test/samlTests.js b/test/samlTests.js
index 9a6ae158..98e01b13 100644
--- a/test/samlTests.js
+++ b/test/samlTests.js
@@ -45,7 +45,7 @@ describe('SAML.js', function() {
// NOTE: This test only tests existence of the assertion, not the correctness
it('calls callback with saml request object', function(done) {
saml.getAuthorizeUrl(req, function(err, target) {
- url.parse(target, true).query.should.have.property('SAMLRequest');
+ should(url.parse(target, true).query).have.property('SAMLRequest');
done();
});
});
diff --git a/test/tests.js b/test/tests.js
index a5243abc..bd1addbd 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -163,16 +163,10 @@ describe( 'passport-saml /', function() {
response.statusCode.should.equal(check.expectedStatusCode);
if (response.statusCode == 200) {
- console.log(passedRequest.url, "passedRequest.url")
- console.log(passedRequest.method, "passedRequest.method")
- console.log(passedRequest.body, "passedRequest.body")
- console.log(check.samlResponse, "check.samlResponse")
- console.log((passedRequest.body == check.samlResponse), "is it same")
-
should.exist(passedRequest);
passedRequest.url.should.eql('/login');
passedRequest.method.should.eql('POST');
- passedRequest.body.should.eql(check.samlResponse);
+ should(passedRequest.body).match(check.samlResponse);
} else {
should.not.exist(passedRequest);
}