Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redis.auth

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis.auth - npm Package Compare versions

Comparing version 0.1.5 to 0.2.0

6

index.js

@@ -67,3 +67,3 @@ //Global variables

if (p == response[config.key]) {
return next()
valid = true
} else {

@@ -73,2 +73,6 @@ return false

})
//The user is authorized
if (valid === true) {
return next()
}
} else {

@@ -75,0 +79,0 @@ if (permissions === response[config.key]) {

2

package.json
{
"name": "redis.auth",
"version": "0.1.5",
"version": "0.2.0",
"description": "A non prescriptive Redis Authentication module for Express",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -33,2 +33,26 @@ [![Build Status](https://travis-ci.org/ChrisCates/redis.auth.svg?branch=master)](https://travis-ci.org/ChrisCates/redis.auth)

### Example Express middleware
```
var express = require("express")
var app = express()
var auth = require("redis.auth")()
//Example single user permission
app.get("/user", auth("user"), function(req,res) {
return res.status(200).send("Only users can access this...")
})
//Example multi user permission
app.get("/user", auth(["user", "admin"]), function(req,res) {
return res.status(200).send("Admins and users can access this...")
})
/*
** Assuming the following is in the redis token
** { grantType: user }
** And the header has a valid Redis token...
*/
```
### Example status returns:

@@ -35,0 +59,0 @@ #### With returnError = true

@@ -78,2 +78,6 @@ //Uncache the auth module

app.get("/auth_multi", auth(["user", "admin"]), function(req,res) {
return res.status(200).send("Authorized :)")
})
app.get("/auth_admin", auth("admin"), function(req,res) {

@@ -137,2 +141,11 @@ return res.status(200).send("Authorized :)")

it('Authenticate with middleware - multi user', function (done) {
request(app)
.get("/auth_multi")
.set("Authorization", token)
.expect(200, "Authorized :)", done)
})
it('Authenticate with middleware for admin', function (done) {

@@ -147,2 +160,11 @@

it('Authenticate with middleware for admin - multi user', function (done) {
request(app)
.get("/auth_multi")
.set("Authorization", token2)
.expect(200, "Authorized :)", done)
})
it('Should return a 403 - No header supplied', function (done) {

@@ -180,2 +202,7 @@

app.get("/auth2_multi", auth2(["user", "admin"]), function(req,res) {
if (req.errorCode == 403) return res.status(req.errorCode).send("Unauthorized...")
return res.status(200).send("Authorized :)")
})
app.get("/auth2_admin", auth2("admin"), function(req,res) {

@@ -195,2 +222,11 @@ if (req.errorCode == 403) return res.status(req.errorCode).send("Unauthorized...")

it('Authenticate with middleware - multi user', function (done) {
request(app)
.get("/auth2_multi")
.set("Authorization", token)
.expect(200, "Authorized :)", done)
})
it('Authenticate with middleware for admin', function (done) {

@@ -205,2 +241,11 @@

it('Authenticate with middleware for admin - multi user', function (done) {
request(app)
.get("/auth2_multi")
.set("Authorization", token2)
.expect(200, "Authorized :)", done)
})
it('Should return a 403 - No header supplied', function (done) {

@@ -207,0 +252,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc