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

extractUserIdFromRequest

Extracts a userID from an Express request object

Parameters

  • req Object An Express.js request object

Examples

var userId = auth.extractUserIdFromRequest (req)
console.log(userId) // myUsername@tymlyjs.io

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


Boots after

server