New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-auth-rest-server

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-auth-rest-server - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

6

lib/node-auth-rest-server.js

@@ -70,8 +70,4 @@ 'use strict';

function isAuthorizedUrl(url){
return url.indexOf(authorizedUrlPrefix) == 0;
}
function authenticateWithRestToken(req, res, next){
if(isAuthorizedUrl(req.url)){
if(authRestMethods.isAuthorizedUrl(req.url)){
if(!req.headers.authorization || !req.headers.authorization.split('=')[1]){

@@ -78,0 +74,0 @@ res.status(401).set({'Content-Type': 'text/plain', 'Content-Length': '0', 'WWW-Authenticate': 'Token realm="Application"'}).end();

2

package.json

@@ -5,3 +5,3 @@ {

"description": "Provides a basic token authentication, and auto generation of authentication token",
"version": "0.1.6",
"version": "0.1.7",
"repository": {

@@ -8,0 +8,0 @@ "url": ""

@@ -47,2 +47,6 @@ # AuthRestServer

callback(err, authToken);
},
isAuthorizedUrl: function(url){
// e.g.
// return url.indexOf('/api/secret/') == 0;
}

@@ -59,5 +63,5 @@ };

var authRest = require('node-auth-rest-server');
app.use(authRest(app, authRestMethods, '/api/secret/'));
app.use(authRest(app, authRestMethods));
```
* if the url doesn't start with the prefix, then the middleware doesn't performs the following steps and just calls `next`
* if the `authRestMethods.isAuthorizedUrl(url)` returns false, then the middleware doesn't perform the following steps and just calls `next`
* if the header doeasn't contain any token then the request ends with respond 401

@@ -64,0 +68,0 @@ * calls `authRestMethods.getValidTokenByKey` with the token from the header and in it's callback checks the value

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