lib/passport-cas.js
function CasStrategy(options, verify) {
  if (typeof options == 'function') {
    verify = options;
    options = undefined;
  }
  options = options || {};
    
  if (!verify) { throw new TypeError('CasStrategy requires a verify callback'); }
  if (!options.casURL) { throw new TypeError('CasStrategy requires a casURL option'); }
  
  Strategy.call(this);
  this.name = 'cas';
  this._verify = verify;
  this._passReqToCallback = options.passReqToCallback;
  
  this.casBaseUrl = options.casURL;
  this.casPgtUrl = options.pgtURL || undefined;
  this.casPropertyMap = options.propertyMap || {};
  this.casSessionKey = options.sessionKey || 'cas';
  
  this.cas = new CAS({
    base_url: this.casBaseUrl,
    version: 2,
    external_pgt_url: this.casPgtUrl,
    ssl_cert: options.sslCert,
    ssl_key: options.sslKey,
    ssl_ca: options.sslCA
  });
  
}
function CasStrategy(options, verify) {
  if (typeof options == 'function') {
    verify = options;
    options = undefined;
  }
  options = options || {};
    
  if (!verify) { throw new TypeError('CasStrategy requires a verify callback'); }
  if (!options.casURL) { throw new TypeError('CasStrategy requires a casURL option'); }
  
  Strategy.call(this);
  this.name = 'cas';
  this._verify = verify;
  this._passReqToCallback = options.passReqToCallback;
  
  this.casBaseUrl = options.casURL;
  this.casPgtUrl = options.pgtURL || undefined;
  this.casPropertyMap = options.propertyMap || {};
  this.casSessionKey = options.sessionKey || 'cas';
  
  this.cas = new CAS({
    base_url: this.casBaseUrl,
    version: 2,
    external_pgt_url: this.casPgtUrl,
    ssl_cert: options.sslCert,
    ssl_key: options.sslKey,
    ssl_ca: options.sslCA
  });
  
}
function CasStrategy ( options , verify ) { if ( typeof options == 'function' ) { verify = options ; options = undefined ; } options = options || { } ; if ( ! verify ) { throw new TypeError ( 'CasStrategy requires a verify callback' ) ; } if ( ! options . casURL ) { throw new TypeError ( 'CasStrategy requires a casURL option' ) ; } Strategy . call ( this ) ; this . name = 'cas' ; this . _verify = verify ; this . _passReqToCallback = options . passReqToCallback ; this . casBaseUrl = options . casURL ; this . casPgtUrl = options . pgtURL || undefined ; this . casPropertyMap = options . propertyMap || { } ; this . casSessionKey = options . sessionKey || 'cas' ; this . cas = new CAS ( { base_url : this . casBaseUrl , version : 2 , external_pgt_url : this . casPgtUrl , ssl_cert : options . sslCert , ssl_key : options . sslKey , ssl_ca : options . sslCA } ) ; }
Creates an instance of `CasStrategy`.

CAS stands for Central Authentication Service, and is a single sign-on
solution for the web.

Authentication is done by redirecting the user to the CAS login page. The
user will return with a ticket in the querystring. This ticket is then
validated by the application against the CAS server to obtain the username
and profile.

(CAS optionally allows the application to obtain tickets for 3rd party
services on behalf of the user. This requires the use of a PGT callback
server, which can be run with the PgtServer() function also from this
module.)

Applications must supply a `verify` callback, for which the function
signature is:

function(username, profile, done) { ... }

The verify callback is responsible for finding or creating the user, and
invoking `done` with the following arguments:

done(err, user, info);

`user` should be set to `false` to indicate an authentication failure.
Additional `info` can optionally be passed as a third argument, typically
used to display informational messages.  If an exception occured, `err`
should be set.

Options:

- `casURL`            URL of the CAS server (e.g. https://signin.example.com/cas)
- `pgtURL`            Optional. URL of the PGT callback server (e.g. https://callback.example.com)
- `sessionKey`        Optional. The name to use for storing CAS information within the `req.session` object. Default is 'cas'.
- `propertyMap`       Optional. A basic key-value object for mapping extended user attributes from CAS to passport's profile format.
- `passReqToCallback` Optional. When `true`, `req` is the first argument to the verify callback (default: `false`)
- `sslCA`             Optional. SSL CA bundle to use to validate the PGT server.

Example:

var CasStrategy = require('passport-cas2').Strategy;
var cas = new CasStrategy({
casURL: 'https://signin.example.com/cas',
propertyMap: {
id: 'guid',
givenName: 'givenname',
familyName: 'surname',
emails: 'defaultmail'
}
},
function(username, profile, done) {
User.findOrCreate(..., function(err, user) {
done(err, user);
});
});
passport.use(cas);

@constructor
@param {Object} options
@param {Function} verify
@api public
Creates an instance of CasStrategy .