From 9ec26b4ceb5880b3b5e402c04e0e717749219b20 Mon Sep 17 00:00:00 2001 From: "D. Stuart Freeman" Date: Mon, 18 Aug 2014 10:12:22 -0400 Subject: [PATCH 1/2] allow caller to specify serviceURL --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 70ef6da..c83949a 100644 --- a/index.js +++ b/index.js @@ -19,6 +19,7 @@ function Strategy(options, verify) { this.version = options.version || "CAS1.0" this.ssoBase = options.ssoBaseURL; this.serverBaseURL = options.serverBaseURL; + this.serviceURL = options.serviceURL; this.parsed = url.parse(this.ssoBase); if (this.parsed.protocol === 'http:') { this.client = http; @@ -93,7 +94,8 @@ function Strategy(options, verify) { } Strategy.prototype.service = function(req) { - var resolvedURL = url.resolve(this.serverBaseURL, req.originalUrl); + var serviceURL = this.serviceURL || req.originalUrl; + var resolvedURL = url.resolve(this.serverBaseURL, serviceURL); var parsedURL = url.parse(resolvedURL, true); delete parsedURL.query.ticket; delete parsedURL.search; From 5f0348c154f366d228abbe0e99474ab02d3ce7a1 Mon Sep 17 00:00:00 2001 From: "D. Stuart Freeman" Date: Mon, 18 Aug 2014 11:13:21 -0400 Subject: [PATCH 2/2] allow setting validate url --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 70ef6da..2f9a2c0 100644 --- a/index.js +++ b/index.js @@ -19,6 +19,7 @@ function Strategy(options, verify) { this.version = options.version || "CAS1.0" this.ssoBase = options.ssoBaseURL; this.serverBaseURL = options.serverBaseURL; + this.validateURL = options.validateURL; this.parsed = url.parse(this.ssoBase); if (this.parsed.protocol === 'http:') { this.client = http; @@ -57,7 +58,6 @@ function Strategy(options, verify) { case "CAS3.0": this._validateUri = "/p3/serviceValidate"; this._validate = function (req, body, verified) { - console.log(body); parseString(body, { trim: true, normalize: true, @@ -139,11 +139,12 @@ Strategy.prototype.authenticate = function (req, options) { } self.success(user, info); }; + var _validateUri = this.validateURL || this._validateUri; var get = this.client.get({ host: this.parsed.hostname, port: this.parsed.port, path: url.format({ - pathname: this.parsed.pathname + this._validateUri, + pathname: this.parsed.pathname + _validateUri, query: { ticket: ticket, service: service