auth service

Provides JWT-based authentication capabilities. This service is provided via the express plugin and isn't offered by any of the other core plugins.

Boot config

  "auth": {
    "secret": "Shhh!",
    "audience": "myPeople!"
Property Type Description Required
secret string Used to sign/validate JSON Web Tokens (JWT) Yes
audience string The audience of a token is the intended recipient of the token - typically, the base address of the resource being accessed Yes

Service methods/properties


Extracts a userID from an Express request object


  • req Object An Express.js request object


var userId = auth.extractUserIdFromRequest (req)
console.log(userId) //

Returns String A userId extracted from the request (derived via the user property added via express-jwt middleware)

Boots after