redis.auth
A non prescriptive Redis Authentication module for Express
By Chris Cates ⭐️
Installation
npm install redis.auth --save
Configuration
Note that it requires redis.token npm module to work properly
var redis =var auth = redis//Check for which Express header use when authenticating the client"header": "authorization"//The key in the redis session storage you want to check for"key": "grantType"//If return error is true it sends a 403 or 500 status based on the error//Turn this off if you want to do your own error checking"returnError": true
Example Express middleware
var express =var app =var auth =//Example single user permissionapp//Example multi user permissionapp/*** Assuming the following is in the redis token** { grantType: user }** And the header has a valid Redis token...*/
Example status returns:
With returnError = true
return resstatus403
With returnError = false
//Sets these variables in req so you can check for them on your ownreqerror = truereqerrorType = "No "+configheader+" header supplied..."reqerrorCode = 403return