IULogin Helper
Javascript library for supporting CAS and SAML protocols with IU Login
pnpm/yarn install
-
pnpm add @iusca/iulogin-helper@latest
oryarn add @iusca/iulogin-helper@latest
Standalone Setup
- Clone this repo
- Run
npm install
oryarn install
Initialization
const iulogin_helper = require('../iulogin-helper');
var IULogin = new iulogin_helper({
protocol: 'CAS',
mode: 'dev',
ldap: {user: 'username', pwd: 'password'}
})
Options
protocol: Either CAS or SAML (required)
mode: Service deployment type. Either 'dev' or 'prod'
ldap: (optional) {
user: 'username',
pwd: 'passwordhere'
}
Methods
validate
validate = function(token, service, ldap, callback)
token: provided by authentication service
service: endpoint wanting authentication (must match)
ldap: boolean, request ldap lookup after authentication?
callback: function(err, username, profile) {}
The callback function will be called by validate
upon error or completion. If an LDAP result was requested it will be included in the profile object.
get_login_url
get_login_url = function(service)
service: endpoint wanting authentication
ldapLookup
ldapLookup = function(username, callback)
username: valid IU username
callback: function(err, ldapProfile) {}
Example Integration
Node Express
router.get('/verify', function (req, res, next) {
IULogin.validate(req.query.ticket, req.query.service, false, function (err, username, profile) {
if (err) return next(err);
res.json({status: 'success', username: username, profile: profile})
})
});
Command-line script
/bin/iulogin.js
Usage: iulogin.js -t [string] -p [string] -m [string] -s [string] -l
Options:
--version Show version number [boolean]
-t, --ticket, --token Authentication token/ticket [required]
-p, --protocol Defines which protocol to use (Must be one of
["CAS","SAML"]) [required]
-m, --mode Defines which mode to use (Must be one of
["dev","prod"]) [required]
-s, --service Service endpoint requesting authentication [required]
-l Followup successful authentication with LDAP query
[boolean]
-h, --help Show help [boolean]