@iusca/iulogin-helper

0.1.4 • Public • Published

IULogin Helper

Javascript library for supporting CAS and SAML protocols with IU Login

pnpm/yarn install

  1. pnpm add @iusca/iulogin-helper@latest or yarn add @iusca/iulogin-helper@latest

Standalone Setup

  1. Clone this repo
  2. Run npm install or yarn 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]

Readme

Keywords

Package Sidebar

Install

npm i @iusca/iulogin-helper

Weekly Downloads

12

Version

0.1.4

License

MIT

Unpacked Size

55.2 kB

Total Files

9

Last publish

Collaborators

  • deduggi
  • agopu
  • ccbrandt
  • youngmd
  • rperigo
  • aiavenak