1.0.4 • Published 3 years ago

express-kaskadi-verify v1.0.4

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

npm.io npm.io npm.io

GitHub Actions workflows status

Build workflow status Publish workflow status

CodeClimate

npm.io npm.io npm.io


Installation

npm i express-kaskadi-verify

API documentation

Modules

ModuleDescription
verifierConfigure a new verifier instance.

Functions

NameDescription
verify(options)Verification function.

verifier

Configure a new verifier instance.

Returns: verify - Verification function

ParamTypeDescription
urlstringURL 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

ParamTypeDescription
optionsObjectOptions sent for request verification. This can contain the usual JWT claims (audience, issuer, subject) as well as their expected values.
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago