Authentication library for IIT Madras campus network
npm module to authenticate against the IIT Madras campus network using openLDAP credentials
npm install iitm-network-auth --save
var IITMNetworkAuth = require('iitm-network-auth');
nfw
: For the new firewall login (through https://nfw.iitm.ac.in
)netaccess
: For the existing netaccess login (through https://netaccess.iitm.ac.in
)var auth = new IITMNetworkAuth('<username>', '<password>', '<mode>');
auth.login();
auth.logout();
The module can keep an authentication session alive by sending request to keepalive url.
The current inteval is set to 9 minutes
as the firewall keeps a session for 10 minutes.
auth.start_refresh();
auth.stop_refresh();
auth.refresh()
var logged_in = auth.is_logged_in();
The module emits events to denote certain actions as they happen. Any client code can subscribe to these events and take necessary actions
var emitter = auth.get_emitter();
// do something when an error happens
emitter.on('error', function (e) {
console.log(e.data); // log error details to the console
});
// do something when a login happens
emitter.on('log_in', function (e) {
console.log(e.data); // log details to the console
});
// do something when a logout happens
emitter.on('log_out', function (e) {
console.log(e.data); // log details to the console
});
// do something when a session is refreshed
emitter.on('session_refresh', function (e) {
console.log(e.data); // log details to the console
});
// do something when a refresh timer is started/stopped
emitter.on('refresh_timer', function (e) {
console.log(e.data.running); // log status to the consle (true/false)
});
auth.set_credentials('<username>', '<password>');
netaccess
modePull requests are welcome