Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
simple-hmac-auth-express
Advanced tools
Readme
Express middleware for creating APIs that implement simple-hmac-auth.
Two parameters are required. secretForKey
must be a function that returns a promise with the secret for a specified API key, and onRejected
must be a function that handles requests that have failed authentication.
const auth = require('simple-hmac-auth-express')
app.use(auth({
// Return a promise that resolves with the secret for the specified API key
secretForKey: async (apiKey) => {
return 'SECRET';
},
// Handle requests that have failed authentication
onRejected: (error, request, response, next) => {
console.log(`"${request.apiKey}" failed authentication: ${request.method} ${request.url}`);
response.status(401).json({
error: {
message: error.message
}
});
},
// Optional
onAccepted: (request, response) => {
console.log(`"${request.apiKey}" authenticated request to ${request.method} ${request.url} with signature "${request.signature}"`);
}
}));
Because the unparsed body of the request must be loaded and hashed to authenticate, the included middleware also handles parsing the request body. If you would like to parse the contents of the request body, use the same parameters as body-parser in the body
node:
const auth = require('simple-hmac-auth-express')
app.use(auth({
// Required
secretForKey: (apiKey, callback) => callback(null, 'secret'),
onRejected: (error, request, response, next) => response.status(401).end('401'),
onAccepted: (request, response) => console.log(`authenticated ${request.method} ${request.url}`)
// Body-parser options. All optional.
body: {
json: { strict: false, limit: '1mb' }
urlencoded: { extended: true, limit: '5mb' },
text: { type: 'application/octet-stream' }
}
}));
MIT © Jesse Youngblood
FAQs
Express middleware that implements simple-hmac-auth
The npm package simple-hmac-auth-express receives a total of 100 weekly downloads. As such, simple-hmac-auth-express popularity was classified as not popular.
We found that simple-hmac-auth-express 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.