Skip to content
fastify-jwt / 0.1.7-beta.3

fastify-jwt 0.1.7-beta.3

Install from the command line:
Learn more about npm packages
$ npm install @byu-oit/fastify-jwt@0.1.7-beta.3
Install via package.json:
"@byu-oit/fastify-jwt": "0.1.7-beta.3"

About this version

@byu-oit/fastify-jwt

Provides a fastify plugin for verifying JWTs at BYU OIT

Usage

import Fastify from 'fastify'
import { ByuLogger } from '@byu-oit/logger'
import { ByuJwtProvider } from '@byu-oit/fastify-jwt'

const logger = ByuLogger()
const fastify = Fastify({ logger })

fastify.register(ByuJwtProvider, {
  /** Only authenticate routes matching this prefix */
  prefix: '/example/v1', 
  development: process.env.NODE_ENV === 'development',
  /** May pass in ByuJwt options from @byu-oit/jwt */
  issuer: 'https://api.byu.edu', 
  additionalValidations: [(jwt) => {
    if(false) throw new Error('This will never happen')
  }]
})

await fastify.listen({ port: 3000 }).catch(console.error)

Options

In addition to the three properties below, you can also pass in any options that are defined in BYU JWT documentation as well.

property type default description
prefix string undefined Will only authenticate routes matching this prefix.
development boolean false skips JWT verification for development purposes but will throw an error if NODE_ENV is set to production.
basePath string undefined will validate that the audience starts with the provided basePath in production.

Details


Assets

  • fastify-jwt-0.1.7-beta.3.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0