0.3.1 • Published 3 months ago

@byu-oit/windrunner-authorization-apm v0.3.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 months ago

@byu-oit/windrunner-authorization-apm

Authorize requests by checking if the caller has the appropriate permission

Note To use this package you will need to install and register the @byu-oit/fastify-jwt plugin

Usage

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

/** Define options */
const prefix = '/example/v1'
const permission = 'example'

/** Server setup */
const fastify = Fastify({ logger: ByuLogger() })

await fastify.register(ByuJwtProvider, {prefix, issuer: process.env.BYU_OIT_ISSUER, development: process.env.NODE_ENV !== 'production' })

/**
 * By default, the AppPermissionAuthorizationProvider will pull the 
 * - Application Permission Base URL from APP_PERMISSION_BASE_URL env variable
 * - Application Permission API Key from APP_PERMISSION_API_KEY env variable
 */
await fastify.register(AppPermissionAuthorizationProvider, { prefix, permission })

fastify.get(prefix, async (request, reply) => {
  reply.code(200).send('I find your lack of faith disturbing')
})

await fastify.listen({ port: 3000 }).catch(err => {
  console.error(err)
  process.exit(1)
})
0.3.1

3 months ago

0.3.0

5 months ago

0.2.3

7 months ago

0.2.5

7 months ago

0.2.4

7 months ago

0.2.2

12 months ago

0.2.1

12 months ago

0.2.0

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago