GitHub Actions workflows status
CodeClimate
npm i express-kaskadi-verify
Module | Description |
---|---|
verifier | Configure a new verifier instance. |
Name | Description |
---|---|
verify(options) | Verification function. |
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}`)
})
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. |