From 3954e1cd4eb1f3a530774b97c742a66f62128864 Mon Sep 17 00:00:00 2001 From: rgould Date: Wed, 13 Mar 2013 11:18:50 -0400 Subject: [PATCH 1/4] Use 'hostname' instead of 'host', which includes port number `url.parse("http://foo.com:444/bar").hostname` returns `"foo.com:444"`, which causes `validate` to make an invalid call to `https`. --- lib/cas.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cas.js b/lib/cas.js index d35152e..3efaf31 100644 --- a/lib/cas.js +++ b/lib/cas.js @@ -35,7 +35,7 @@ var CAS = module.exports = function CAS(options) { } else if (!cas_url.hostname) { throw new Error('Option `base_url` must be a valid url like: https://example.com/cas'); } else { - this.hostname = cas_url.host; + this.hostname = cas_url.hostname; this.port = cas_url.port || 443; this.base_path = cas_url.pathname; } @@ -95,4 +95,4 @@ CAS.prototype.validate = function(ticket, callback) { callback({message: 'Bad response format.'}); }); }); -}; \ No newline at end of file +}; From f70be6a2d643f0a9d537a056280bdea880281065 Mon Sep 17 00:00:00 2001 From: rgould Date: Wed, 13 Mar 2013 11:31:22 -0400 Subject: [PATCH 2/4] Permit using module with node 0.8 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ae9ea4..78b6302 100644 --- a/package.json +++ b/package.json @@ -6,5 +6,5 @@ "author": "Casey Banner ", "dependencies": {}, "main": "index", - "engines": { "node": "0.4 || 0.5 || 0.6" } + "engines": { "node": "0.4 || 0.5 || 0.6 || 0.8" } } From 330c84c77b8052457f0dfd3493cce14f40804478 Mon Sep 17 00:00:00 2001 From: rgould Date: Wed, 20 Mar 2013 15:45:48 -0700 Subject: [PATCH 3/4] Support passing options through to the https module. This permits us to set values like 'rejectUnauthorized' --- lib/cas.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/cas.js b/lib/cas.js index 3efaf31..367b9ac 100644 --- a/lib/cas.js +++ b/lib/cas.js @@ -41,6 +41,7 @@ var CAS = module.exports = function CAS(options) { } this.service = options.service; + this.https_options = options.https; }; /** @@ -59,14 +60,20 @@ CAS.version = '0.0.1'; */ CAS.prototype.validate = function(ticket, callback) { - var req = https.get({ + var options = { host: this.hostname, port: this.port, path: url.format({ pathname: this.base_path+'/validate', query: {ticket: ticket, service: this.service} }) - }, function(res) { + }; + for (var opt in this.https_options) { + if (this.https_options.hasOwnProperty(opt)) { + options[opt] = this.https_options[opt]; + } + } + var req = https.get(options, function(res) { // Handle server errors res.on('error', function(e) { callback(e); From b1cba2007caeb005f84b4b178e967f24ae840807 Mon Sep 17 00:00:00 2001 From: rgould Date: Wed, 20 Mar 2013 15:46:43 -0700 Subject: [PATCH 4/4] Permit use with node 0.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 78b6302..a0ce7d0 100644 --- a/package.json +++ b/package.json @@ -6,5 +6,5 @@ "author": "Casey Banner ", "dependencies": {}, "main": "index", - "engines": { "node": "0.4 || 0.5 || 0.6 || 0.8" } + "engines": { "node": "0.4 || 0.5 || 0.6 || 0.8 || 0.10" } }