
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
hapi-auth-jsonwebtoken
Advanced tools
JSON Web Token (JWT) authentication plugin for Hapi 6.0
Based on original version of hapi-auth-jwt by ryanfitz, modified to work with Hapi 6.0, and return some additional data for validateFunc (original token). The original token can be used for extra validation, i.e. check against redis to make sure token is valid.
JSON Web Token authentication requires verifying a signed token. The 'jwt' scheme takes the following options:
key - (required) The private key the token was signed with.validateFunc - (optional) validation and user lookup function with the signature function(token, decodedToken, callback) where:
token - original token from the requestdecodedToken - the verified and decoded jwt tokencallback - a callback function with the signature function(err, isValid, credentials) where:
err - an internal error.isValid - true if the token was valid otherwise false.credentials - a credentials object passed back to the application in request.auth.credentials. Typically, credentials are only
included when isValid is true, but there are cases when the application needs to know who tried to authenticate even when it fails
(e.g. with authentication mode 'try').See the example for usage example. To run example:
cd example
npm install
node .
var privateKey = 'BbZJjyoXAdr8BUZuiKKARWimKfrSmQ6fv8kZ7OFfc',
accounts = {
123: {
id: 123,
user: 'john',
name: 'John Doe',
scope: ['a', 'b']
}
};
// validation function
var validate = function(token, decodedToken, cb) {
/**
* Here we can check if token is valid, i.e. if we're storing token in redis after user logged in:
*
* var isValid = false;
* redis.get(token, function(err, val) {
* if (val) {
* isValid = true;
* }
* });
*/
var account = accounts[decodedToken.accountID];
if (!account || !isValid) {
return cb(null, false);
}
cb(err, isValid, account);
};
server.pack.register(require('hapi-auth-jsonwebtoken'), function (err) {
server.auth.strategy('jwt', 'jwt', { key: privatekey, validateFunc: validate });
server.route({ method: 'GET', path: '/', config: { auth: 'jwt' } });
});
FAQs
JSON Web Token (JWT) authentication plugin
The npm package hapi-auth-jsonwebtoken receives a total of 4 weekly downloads. As such, hapi-auth-jsonwebtoken popularity was classified as not popular.
We found that hapi-auth-jsonwebtoken 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.