redis.auth
A non prescriptive Redis Authentication module for Express
By Chris Cates :star:
Installation
npm install redis.auth --save
Configuration
Note that it requires redis.token npm module to work properly
var redis = require("redis.token")()
var auth = require("redis.auth")(redis, {
"header": "authorization",
"key": "grantType",
"returnError": true
})
Example Express middleware
var express = require("express")
var app = express()
var auth = require("redis.auth")()
app.get("/user", auth("user"), function(req,res) {
return res.status(200).send("Only users can access this...")
})
app.get("/user", auth(["user", "admin"]), function(req,res) {
return res.status(200).send("Admins and users can access this...")
})
Example status returns:
With returnError = true
return res.status(403).send({
"error": true,
"status": 403,
"message": "No "+config.header+" header supplied..."
})
With returnError = false
req.error = true
req.errorType = "No "+config.header+" header supplied..."
req.errorCode = 403
return next()