Skip to content

kaskadi/express-kaskadi-verify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Actions workflows status

Build workflow status Publish workflow status

CodeClimate


Installation

npm i express-kaskadi-verify

API documentation

Modules

Module Description
verifier Configure a new verifier instance.

Functions

Name Description
verify(options) Verification function.

verifier

Configure a new verifier instance.

Returns: verify - Verification function

Param Type Description
url string URL to the verification server used for verifying incoming requests.

Example

const verify = require('express-kaskadi-verify')('http://localhost:3000') // instanciate a new verifier
const express = require('express')
const app = express()
const port = 4000

app.get('/issuer-example', verify({ issuer: ['my-issuer'] }), (req, res) => {
  res.json(req.user)
}) // verify against the JWT issuer

app.get('/admin', verify({ audience: ['admin'] }), (req, res) => {
  res.json(req.user)
}) // verify against the JWT audience

app.get('/some/subject', verify({ subject: ['some'] }), (req, res) => {
  res.json(req.user)
}) // verify against the JWT subject

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})

verify(options)

Verification function.

Provided a set of options, this will return an Express middleware usable inside an Express app. When using this middleware for an endpoint, the decoded JWT will be attached to the request object from Express so that it can be used in your code.

Kind: global function
Returns: function - Express middleware

Param Type Description
options Object Options sent for request verification. This can contain the usual JWT claims (audience, issuer, subject) as well as their expected values.

About

an Express middleware to verify JWT tokens through a verification server

Resources

License

Stars

Watchers

Forks