Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions lib/cas.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ 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;
}

this.service = options.service;
this.https_options = options.https;
};

/**
Expand All @@ -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);
Expand Down Expand Up @@ -95,4 +102,4 @@ CAS.prototype.validate = function(ticket, callback) {
callback({message: 'Bad response format.'});
});
});
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"author": "Casey Banner <kcbanner@gmail.com>",
"dependencies": {},
"main": "index",
"engines": { "node": "0.4 || 0.5 || 0.6" }
"engines": { "node": "0.4 || 0.5 || 0.6 || 0.8 || 0.10" }
}