cas
Central Authentication Service (CAS) client for Node.js
This module handles CAS authentication (with support for proxies and extended attributes), and can also transparently redirect a web page if needed. The ticket validation step is available as its own function for those who wish to handle things manually. Single sign out is also supported with Express/Connect.
To start the login process manually, send your users to: https://cas_base_url/login?service=url_to_handle_ticket_validation
. In the University of Waterloo example below, this url would be: https://cas.uwaterloo.ca/cas/login?service='my_service'
.
Or if you are using standard HTTP req/res objects for a web page, you may use the provided authenticate()
function to handle the redirection automatically.
It is also possible to use this as a standalone CAS PGT callback server that other CAS clients can use.
Installation
Clone this project into node_modules/cas
and then run npm install
inside it.
Usage
Setup:
var CAS = ; var cas = base_url: 'https://cas.uwaterloo.ca/cas' service: 'my_service' version: 20 ;
Using it in a login route:
exports { var ticket = req; if ticket cas; else res; };
Using the auto redirect authentication:
exports { cas; }
Longer example with CAS proxy (also see the wiki):
var fs = ; var http = ; // Initialize CAS var CAS = ; var cas = base_url: 'https://cas.uwaterloo.ca/cas' version: 20 // CAS server will connect to this. It must be accessible on the // public internet. pgt_server: true ssl_key: fs ssl_cert: fs pgt_host: 'my-public-domain.example.com' pgt_port: 8989 ; // Main web server var server = http; server; server;
License
(The MIT License)
Copyright (c) 2011 Casey Banner <kcbanner@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.