Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
express-user
Advanced tools
Module to expose user management (registration, account deletion, login, logout, etc) in a ressource-oriented way.
The library is in prototype stage at this point. It is untested (beyond basic manual tests) and I'll postpone the writing of automated tests until the API is relatively final.
The API is very likely to change due to:
My eventual desire to decouple the response logic (return codes and content + logging) from the rest of the library in order to allow for specialized response plugins (ex: HTML forms, single-page clients with Ajax, collection+JSON hypermedia, etc)
While I do not foresee that many architectural changes for this, I do not rule them out entirely as I integrate the following features in my web applications: ajax feedback on forms (ex: immediate feedback if username is taken during registration), email verification, csrf tokens, brute force mitigation for login, etc.
I want to implement session consistency (for logged in users) with user profile modifications (for updates and deletions)
Sessions get out of sync when users are updated or deleted.
Express-User relies on 2 components (eventually at least 3):
-secure connection checking (HTTPS or local)
-Access control: privilege check to ensure the admin URLs are accessed by an admin and that the user is logged in when accessing the Self URLs
-Handle accout manipulation
-Provide a routing callback for authentication (to check the user is either logged in or belongs to a given group)
This component implements validation to check that requests contain all the expected information and in the right format.
From there, it constructs the req.locals.ExpressUser.User (usually expected by express-user) and the req.locals.ExpressUser.Update (sometimes expected by Express-User) as needed.
It shouldn't handle traditional database validations (ie, does the username already exist) which should handled by a properly configured user-store.
Express-User passes an Express router to the validator which allows it establish validation routes.
The entire achitecture relies heavily on Express routes to establish ordering of logic and communication between components.
At the database level, user-store provides some optional error-checking for user insertion (uniqueness, not null, hashing of password if present).
Otherwise, the user-store I implemented is using MongoDB which is schema free and I took full advantage of this fact to make my implementation of user-store unbiased.
Similarly, express-user, which provides Express routing and some access control on top of user-store and a user's session, is very flexible and has little bias.
This means that the vast majority of the bias concerning what your user fields should look like and what input various actions expect falls on the validator.
As such, it should ensure that all the fields you expect for various actions (ex: password) are there and that their values follow whichever constraints you wish to place upon them.
You should be as conservative as your application domains allows concerning what you'll accept.
A recent version of Node.js (version 0.10.25 is installed on my machine) [1]
A recent version of Express.js
npm if you want the easy way to install this module.
[1] Later versions should also work. If you find it not to be the case, let me know.
This library expects a user store that outwardly behaves just like the user-store project for the Add/Get/Remove/Update methods.
You can use user-store (which uses MongoDB), or implement your own user store solution (from scratch or by writing a wrapper around an existing solution to conform to the expected API).
Additionally, this library also expects a session management library that behaves like express-session as far as the req.session variable is concerned.
Again, you can use express-session to get a working solution out of the box or implement your own solution (either from scratch or by writing a wrapper around another existing solution such that req.session behaves as expected).
In order to remain flexible, this library leaves the implementation of request validation to you in terms of making sure that the right fields are submitted (plus any sanitation check)
Currently, the traditional email/username/password validation scheme is implemented in this project: express-user-local
This library expects req.body to be populated with the variables in the body of your request. The body-parser project can do this for you.
If you are using HTML forms (which only support the GET and POST methods), you'll need a library like method-override to simulate other kinds of request methods (ie, PUT, PATCH, DELETE)
The dev-dependencies contains a complete stack for an out-of-the-box solution, minus the method handling of html forms.
While keeping in mind that details will probably change in the future, you can play with what is currently there, by running the Example.js server (you'll need the dev dependencies to run it) and going to the following adress in your browser: http://127.0.0.1:8080/
More in-depth details to come once the API is finalized.
Initial prototype
Doc formating fix.
Changed session management URL from /Session/User to /Session/Self/User
Update dev dependencies for express-user-local to version 0.0.1-alpha1
Updated dev dependencies for user-store to version 1.1.1
Modified bad input handling to take into account the more detailed constraint errors of user-store and return 400 rather than a 500 system error for submissions that violate constraints.
FAQs
Ressource Oriented Express Middleware to Manage Users.
The npm package express-user receives a total of 40 weekly downloads. As such, express-user popularity was classified as not popular.
We found that express-user 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.