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
21 changes: 10 additions & 11 deletions lib/cas.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
* Module dependencies
*/

var https = require('https');
var http = require('http');
var url = require('url');

/**
* Initialize CAS with the given `options`.
*
Expand All @@ -30,13 +29,13 @@ var CAS = module.exports = function CAS(options) {
}

var cas_url = url.parse(options.base_url);
if (cas_url.protocol != 'https:') {
throw new Error('Only https CAS servers are supported.');
if (cas_url.protocol != 'http:') {
throw new Error('Only http CAS servers are supported.');
} 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.port = cas_url.port || 443;
this.port = cas_url.port || 80;
this.base_path = cas_url.pathname;
}

Expand All @@ -59,7 +58,7 @@ CAS.version = '0.0.1';
*/

CAS.prototype.validate = function(ticket, callback) {
var req = https.get({
var req = http.get({
host: this.hostname,
port: this.port,
path: url.format({
Expand All @@ -80,13 +79,13 @@ CAS.prototype.validate = function(ticket, callback) {
});

res.on('end', function() {
var sections = response.split('\n');
var sections = response.split('\n');
if (sections.length >= 1) {
if (sections[0] == 'no') {
if (sections[1] == 'no') {
callback(undefined, false);
return;
} else if (sections[0] == 'yes' && sections.length >= 2) {
callback(undefined, true, sections[1]);
} else if (sections[1] == 'yes' && sections.length >= 2) {
callback(undefined, true, sections[2]);
return;
}
}
Expand All @@ -95,4 +94,4 @@ CAS.prototype.validate = function(ticket, callback) {
callback({message: 'Bad response format.'});
});
});
};
};
32 changes: 27 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
{
"name": "cas",
"version": "0.0.3",
"name": "hpu-cas",
"version": "0.0.1",
"description": "Central Authentication Service (CAS) client for Node.js",
"keywords": ["cas", "central authentication service", "auth", "authentication", "central", "service"],
"author": "Casey Banner <kcbanner@gmail.com>",
"keywords": [
"cas",
"central authentication service",
"auth",
"authentication",
"central",
"service"
],
"author": "Truong Hoang Dung <checkraiser11@gmail.com>",
"dependencies": {},
"main": "index",
"engines": { "node": "0.4 || 0.5 || 0.6" }
"engines": {
"node": "0.4 || 0.5 || 0.6 || 0.8"
},
"readmeFilename": "Readme.md",
"gitHead": "ae1074442cc456bb0c7b33a60535891ed8d1a62f",
"directories": {
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/checkraiser/node-cas"
},
"license": "BSD"
}
97 changes: 97 additions & 0 deletions pakmanaged.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
var global = Function("return this;")();
/*!
* Ender: open module JavaScript framework (client-lib)
* copyright Dustin Diaz & Jacob Thornton 2011 (@ded @fat)
* http://ender.no.de
* License MIT
*/
!function (context) {

// a global object for node.js module compatiblity
// ============================================

context['global'] = context

// Implements simple module system
// losely based on CommonJS Modules spec v1.1.1
// ============================================

var modules = {}
, old = context.$

function require (identifier) {
// modules can be required from ender's build system, or found on the window
var module = modules[identifier] || window[identifier]
if (!module) throw new Error("Requested module '" + identifier + "' has not been defined.")
return module
}

function provide (name, what) {
return (modules[name] = what)
}

context['provide'] = provide
context['require'] = require

function aug(o, o2) {
for (var k in o2) k != 'noConflict' && k != '_VERSION' && (o[k] = o2[k])
return o
}

function boosh(s, r, els) {
// string || node || nodelist || window
if (typeof s == 'string' || s.nodeName || (s.length && 'item' in s) || s == window) {
els = ender._select(s, r)
els.selector = s
} else els = isFinite(s.length) ? s : [s]
return aug(els, boosh)
}

function ender(s, r) {
return boosh(s, r)
}

aug(ender, {
_VERSION: '0.3.6'
, fn: boosh // for easy compat to jQuery plugins
, ender: function (o, chain) {
aug(chain ? boosh : ender, o)
}
, _select: function (s, r) {
return (r || document).querySelectorAll(s)
}
})

aug(boosh, {
forEach: function (fn, scope, i) {
// opt out of native forEach so we can intentionally call our own scope
// defaulting to the current item and be able to return self
for (i = 0, l = this.length; i < l; ++i) i in this && fn.call(scope || this[i], this[i], i, this)
// return self for chaining
return this
},
$: ender // handy reference to self
})

ender.noConflict = function () {
context.$ = old
return this
}

if (typeof module !== 'undefined' && module.exports) module.exports = ender
// use subscript notation as extern for Closure compilation
context['ender'] = context['$'] = context['ender'] || ender

}(this);
// pakmanager:hpu-cas
(function (context) {

var module = { exports: {} }, exports = module.exports
, $ = require("ender")
;


module.exports = require('./lib/cas');

provide("hpu-cas", module.exports);
}(global));