AuthModule

auth. AuthModule

Adds authentication + authorisation to the server

Constructor

new AuthModule()

Source:

Extends

  • AbstractModule

Members

authentication :Authentication

Source:
The authentication unit
Type:
  • Authentication

isEnabled :Boolean

Source:
Whether auth should be enabled
Type:
  • Boolean

permissions :Permissions

Source:
The permission-checking unit
Type:
  • Permissions

router :Router

Source:
Reference to the Express router
Type:
  • Router

unsecuredRoutes :RouteStore

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

Methods

(async) apiMiddleware(req, res, next)

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

(async) init()

Source:

(async) initAuthData(req)

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

rootMiddleware(req, res, next)

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

secureRoute(route, method, scopes)

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

unsecureRoute(route, method)

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