express-biscuit
Express authorization middleware using Biscuit tokens and policies
Example usage:
const express = require('express')
const express_biscuit = require('@biscuit-auth/express-biscuit')
const {fact} = require('@biscuit-auth/express-biscuit')
const app = express()
const pubKey = "dfd559075dcf56c8c6777fbd3c553827dd51645bb8ee87a975a172980f8f16e5"
app.get('/user/:user_id',
express_biscuit({
publicKey: pubKey,
policies: "check if user(1); allow if true;",
extractor: function(req, authorizer) {
authorizer.add_fact(
fact`user(${parseInt(req.params.user_id)})`
)
}
}),
function (req, res) {
res.send('Hello '+req.params.user_id+"\n")
})