express-kaskadi-verify
v1.0.4
Published
![](https://img.shields.io/github/package-json/v/kaskadi/express-kaskadi-verify) ![](https://img.shields.io/badge/code--style-standard-blue) ![](https://img.shields.io/github/license/kaskadi/express-kaskadi-verify?color=blue)
Downloads
11
Readme
GitHub Actions workflows 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. |