@byu-oit/windrunner-authorization-gro
v0.3.1
Published
Authorize requests by checking if the caller is in the specified GRO group
Downloads
4
Maintainers
Keywords
Readme
@byu-oit/windrunner-authorization-gro
Authorize requests by checking if the caller is in the specified GRO group
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 { GroAuthorizationProvider } from '@byu-oit/windrunner-authorization-gro'
/** Define options */
const prefix = '/example/v1'
const groupId = 'example'
/** Server setup */
const fastify = Fastify({ logger: ByuLogger() })
fastify.regsiter(ByuJwtProvider, {prefix, issuer: process.env.BYU_OIT_ISSUER, development: process.env.NODE_ENV !== 'production' })
fastify.register(GroAuthorizationProvider, { prefix, groupId })
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)
})