Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
node-auth-rest-server
Advanced tools
Provides a basic token authentication, and auto generation of authentication token
Provides a basic token authentication, and auto generation of authentication token
Based on express.
npm install node-auth-rest-server
and then in your application
// use express
var app = express();
// inject authRest middleware
var authRest = require('node-auth-rest-server');
app.use(authRest(app, authRestMethods, '/api/secret/'));
Here authRestMethods
is a javascript object that implements the following method:
authRestMethods = {
userByEmail: function(email, callback) {
// your code here
// e.g. SELECT * FROM auth_users WHERE email = ?
callback(err, user);
},
newAuthToken: function(key, userId, expiresAt, callback){
// your code here
// e.g. INSERT INTO auth_tokens SET ?
// SELECT * FROM auth_tokens where id = insertId
callback(err, authToken);
},
getValidTokenByUser: function(user, callback){
// your code here
// e.g. SELECT * FROM auth_tokens where user_id = ? and expires_at > ?
callback(err, authToken);
},
getValidTokenByKey: function(authTokenKey, callback){
// your code here
// e.g. SELECT * FROM auth_tokens where `key` = ? and expires_at > ?
callback(err, authToken);
},
isAuthorizedUrl: function(url){
// e.g.
// return url.indexOf('/api/secret/') == 0;
}
};
/api/secret/
as in the example:// inject authRest middleware
var authRest = require('node-auth-rest-server');
app.use(authRest(app, authRestMethods));
authRestMethods.isAuthorizedUrl(url)
returns false, then the middleware doesn't perform the following steps and just calls next
authRestMethods.getValidTokenByKey
with the token from the header and in it's callback checks the valuenext
, otherwise the request ends with respond 401If the client gets 401 response it should perform POST
to /api/sessions/get_auth_token
The middleware actually adds POST
/api/sessions/get_auth_token
to the router. When such a request is received by the the server, the middleware performs the authToken generation by calling getAuthToken (check the implementation for more details).
FAQs
Provides a basic token authentication, and auto generation of authentication token
The npm package node-auth-rest-server receives a total of 7 weekly downloads. As such, node-auth-rest-server popularity was classified as not popular.
We found that node-auth-rest-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.