Higher-order helper function to enforce authentication on a request handler and assert the type of Request that is
passed into your authenticated Express routes.
This function takes an AuthenticatedRequestHandler and returns a new request handler
that verifies that the request has a 'user' property with the correct shape on it before calling the original handler.
If the req.user property isn't the correct shape, it sends a 401 Unauthorized response to the client.
NOTE: This does not verify signatures or any other content -- use getAuthenticateUserExpressHandler to create a
middleware that does those things and ensure that your routes use it.
Higher-order helper function to enforce authentication on a request handler and assert the type of
Request
that is passed into your authenticated Express routes.This function takes an
AuthenticatedRequestHandler
and returns a new request handler that verifies that the request has a 'user' property with the correct shape on it before calling the original handler. If thereq.user
property isn't the correct shape, it sends a401 Unauthorized
response to the client.NOTE: This does not verify signatures or any other content -- use
getAuthenticateUserExpressHandler
to create a middleware that does those things and ensure that your routes use it.See express.js documentation for details on writing your route handler
Example