Constructor
new AuthModule()
- Source:
Extends
Members
authentication :Authentication
- Description:
- Source:
The authentication unit
Type:
isEnabled :Boolean
- Description:
- Whether auth should be enabled
- Source:
Whether auth should be enabled
Type:
permissions :Permissions
- Description:
- The permission-checking unit
- Source:
The permission-checking unit
Type:
router :Router
- Description:
- Reference to the Express router
- Source:
Reference to the Express router
Type:
unsecuredRoutes :RouteStore
- Description:
- All routes to ignore auth
- Source:
All routes to ignore auth
Type:
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
|
|
initSessions(mongodb, server)
- Description:
- Initialises session middleware on the Express app
- Source:
Parameters:
| Name |
Type |
Description |
mongodb |
Object
|
The mongodb module instance |
server |
Object
|
The server module instance |
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 |
- Description:
- Stores the session token as an auth header if none present
- Source:
Parameters:
| Name |
Type |
Description |
req |
external:ExpressRequest
|
|
res |
external:ExpressResponse
|
|
next |
function
|
|
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 |