src/auth.js

Method auth

Determines what authentication is valid (if any), and applies it to the request

Parameters:

  • req must be an Object.
    (Request Object)

  • res must be an Object.
    (Response Object)

  • host must be a String.
    (Virtual host)

  • next must be a Function.
    (Function to execute after applying optional authenication wrapper)

Returns an Object
(TurtleIO instance)

TurtleIO.prototype.auth = function ( req, res, host, next ) {

No authentication

if ( !this.config.auth || ( this.config.auth && !this.config.auth[host] ) ) { next(); }

Basic

else if ( this.config.auth && this.config.auth[host] ) { if ( !this.config.auth[host].auth ) { this.config.auth[host].auth = http_auth( this.config.auth[host] ); } this.config.auth[host].auth.apply( req, res, next ); } return this; };