How to use the jwks-rsa.koaJwtSecret function in jwks-rsa

To help you get started, we’ve selected a few jwks-rsa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Levino / mock-jwks / example / api.js View on Github external
const createApp = ({ jwksHost }) => {
  const app = new Koa()

  // We are setting up the jwksRsa client as usual (with production host)
  // We switch off caching to show how things work in ours tests.

  app.use(
    jwt({
      secret: jwksRsa.koaJwtSecret({
        cache: false,
        jwksUri: url.resolve(jwksHost, '/.well-known/jwks.json'),
      }),
      audience: 'private',
      issuer: 'master',
      algorithms: ['RS256'],
    })
  )

  const router = new Router()

  // This route is protected by the authentication middleware
  router.get('/', (ctx) => {
    ctx.body = 'Authenticated!'
  })

jwks-rsa

Library to retrieve RSA public keys from a JWKS endpoint

MIT
Latest version published 1 year ago

Package Health Score

78 / 100
Full package analysis