AuthModule

auth. AuthModule

Adds authentication + authorisation to the server

Constructor

new AuthModule()

Source:

Extends

  • AbstractModule

Members

authentication :Authentication

Description:
  • The authentication unit
Source:
The authentication unit
Type:
  • Authentication

isEnabled :Boolean

Description:
  • Whether auth should be enabled
Source:
Whether auth should be enabled
Type:
  • Boolean

permissions :Permissions

Description:
  • The permission-checking unit
Source:
The permission-checking unit
Type:
  • Permissions

router :Router

Description:
  • Reference to the Express router
Source:
Reference to the Express router
Type:
  • Router

unsecuredRoutes :RouteStore

Description:
  • All routes to ignore auth
Source:
All routes to ignore auth
Type:
  • RouteStore
Example
{
  post: { "/api/test": true }
}

Methods

(async) apiMiddleware(req, res, next)

Description:
  • Initialises auth data for root requests
Source:
Parameters:
Name Type Description
req external:ExpressRequest
res external:ExpressResponse
next function

(async) init()

Source:

(async) initAuthData(req)

Description:
  • Processes and parses incoming auth data
Source:
Parameters:
Name Type Description
req external:ExpressRequest

rootMiddleware(req, res, next)

Description:
  • Initialises auth data for root requests
Source:
Parameters:
Name Type Description
req external:ExpressRequest
res external:ExpressResponse
next function

secureRoute(route, method, scopes)

Description:
  • Locks a route to only users with the passed permissions scopes
Source:
Parameters:
Name Type Description
route String The route
method String The HTTP method
scopes Array.<String> Permissions scopes

unsecureRoute(route, method)

Description:
  • Allows unconditional access to a specific route
Source:
Parameters:
Name Type Description
route String The route/endpoint
method String HTTP method to allow