2.2.0 • Published 10 months ago

@groupclaes/fastify-authhandler v2.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

fastify-authhandler

Default authentication handler hook for use in fastify backend

set env var ISSUER_ID to validate issuer
set env var CLIENT_ID to validate audience

Designed to be paired with @groupclaes/fastify-elastic fastify wrapper.

Installation:

npm i @groupclaes/fastify-authhandler

Usage:

Add the handler by using the addAuthPreHandler function available on the Fastify instance

...
const fastify = new Fastify(config.wrapper)
// add authhandler to fastify instance
fastify.addAuthPreHandler(handle)
...

Add the requiredPermissions attribute to you route

...
{
  method: 'GET',
  url: '/:id',
  handler: controller.get,
  requiredPermissions: []
}
...

available values for requiredPermissions

  • {undefined}: authorization header will be parsed if present but is not be required
  • {string}: single permission will be verified and token is mandatory
  • {string[]}: all permissions will be verified and token is mandatory
2.1.2

10 months ago

2.2.0

10 months ago

2.1.1

10 months ago

2.1.0

10 months ago

2.0.1

11 months ago

2.0.0

1 year ago

2.0.0-pre.1

1 year ago

2.0.0-pre.0

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.2

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago