
Security News
Google’s OSV Fix Just Added 500+ New Advisories — All Thanks to One Small Policy Change
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.
@ryanburnette/authorization
Advanced tools
An excruciatingly simple authorization strategy for Node.js http apps.
A stupid simple authorization strategy for APIs.
npm install --save @ryanburnette/authorization
This strategy makes a couple assumptions.
req.user
is an object that describes this userreq.user.roles
is an array of strings that describes the roles this user hasA basic implementation looks something like this.
import Authorization from '@ryanburnette/authorization';
// use it on a group of endpoints
app.use(
'/api/widgets',
Authorization.middleware({ methods: ['GET', 'POST'], roles: ['user', 'admin'] }),
Authorization.middleware({ methods: ['DELETE'], roles: ['admin'] }),
function (req, res) {
res.statusCode = 200;
res.end();
return;
}
);
// use it on a single endpoint
app.get(
'/api/employees',
Authorization.middleware({ roles: ['user', 'admin'] }),
function (req, res) {
res.statusCode = 200;
res.end();
return;
}
);
app.use(function (err, req, res, next) {
// catch errors from this strategy
if (err.code === 'E_FORBIDDEN') {
res.statusCode = 403;
res.end();
return;
}
console.error(err);
res.statusCode = 500;
res.end();
});
npm install --no-save express
npm test
FAQs
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
A data handling bug in OSV.dev caused disputed CVEs to disappear from vulnerability feeds until a recent fix restored over 500 advisories.
Research
/Security News
175 malicious npm packages (26k+ downloads) used unpkg CDN to host redirect scripts for a credential-phishing campaign targeting 135+ organizations worldwide.
Security News
Python 3.14 adds template strings, deferred annotations, and subinterpreters, plus free-threaded mode, an experimental JIT, and Sigstore verification.