New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hapi-auth-jwt2

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-auth-jwt2 - npm Package Compare versions

Comparing version 5.2.0 to 5.2.1

3

lib/index.js

@@ -74,3 +74,4 @@ var Boom = require('boom'); // error handling https://github.com/hapijs/boom

else {
return reply.continue({ credentials: credentials || decoded });
request.auth.token = token;
return reply.continue({ credentials: credentials || decoded, artifacts: token });
}

@@ -77,0 +78,0 @@ });

{
"name": "hapi-auth-jwt2",
"version": "5.2.0",
"version": "5.2.1",
"description": "Hapi.js Authentication Plugin/Scheme using JSON Web Tokens (JWT)",

@@ -40,3 +40,3 @@ "main": "lib/index.js",

"aguid": "^1.0.3",
"hapi": "^11.0.3",
"hapi": "^11.0.5",
"codeclimate-test-reporter": "^0.1.1",

@@ -43,0 +43,0 @@ "istanbul": "^0.4.0",

@@ -7,5 +7,5 @@ # Hapi Auth with JSON Web Tokens (JWT)

[![Build Status](https://travis-ci.org/dwyl/hapi-auth-jwt2.svg "Build Status = Tests Passing")](https://travis-ci.org/dwyl/hapi-auth-jwt2)
[![Test Coverage](https://codeclimate.com/github/dwyl/hapi-auth-jwt2/badges/coverage.svg "All Lines Tested")](https://codeclimate.com/github/dwyl/hapi-auth-jwt2)
[![codecov.io Code Coverage](https://codecov.io/github/dwyl/hapi-auth-jwt2/coverage.svg?branch=master)](https://codecov.io/github/dwyl/hapi-auth-jwt2?branch=master)
[![Code Climate](https://codeclimate.com/github/dwyl/hapi-auth-jwt2/badges/gpa.svg "No Nasty Code")](https://codeclimate.com/github/dwyl/hapi-auth-jwt2)
[![HAPI 11.0.0](http://img.shields.io/badge/hapi-11.0.0-brightgreen.svg "Latest Hapi.js")](http://hapijs.com)
[![HAPI 11.0.5](http://img.shields.io/badge/hapi-11.0.5-brightgreen.svg "Latest Hapi.js")](http://hapijs.com)
[![Node.js Version](https://img.shields.io/node/v/hapi-auth-jwt2.svg?style=flat "Node.js 10 & 12 and io.js latest both supported")](http://nodejs.org/download/)

@@ -244,2 +244,14 @@ [![npm](https://img.shields.io/npm/v/hapi-auth-jwt2.svg)](https://www.npmjs.com/package/hapi-auth-jwt2)

## Want to access the JWT token after validation?
[@mcortesi](https://github.com/mcortesi) requested the ability to
[access the JWT token](https://github.com/dwyl/hapi-auth-jwt2/issues/55) used for authentication.
We added support for that. You can access the extracted JWT token in your handler or any other function
within the request lifecycle with the `request.auth.token` property.
Take in consideration, that this is the *encoded token*, and it's only useful if you want to use to make
request to other servers using the user's token. For information inside the token, just use the
`request.auth.credentials` property.
## Want to send/store your JWT in a Cookie?

@@ -246,0 +258,0 @@

@@ -32,2 +32,6 @@ var Hapi = require('hapi');

var sendToken = function(req, reply) {
return reply(req.auth.token);
};
server.register(require('../'), function () {

@@ -43,2 +47,3 @@

{ method: 'GET', path: '/', handler: home, config: { auth: false } },
{ method: 'GET', path: '/token', handler: sendToken, config: { auth: 'jwt' } },
{ method: 'POST', path: '/privado', handler: privado, config: { auth: 'jwt' } },

@@ -45,0 +50,0 @@ { method: 'POST', path: '/required', handler: privado, config: { auth: { mode: 'required', strategy: 'jwt' } } },

@@ -331,1 +331,18 @@ var test = require('tape');

});
test("Scheme should set token in request.auth.token", function(t) {
// use the token as the 'authorization' header in requests
var token = JWT.sign({ id: 123, "name": "Charlie" }, secret);
var options = {
method: "GET",
url: "/token",
headers: { authorization: "Bearer " + token }
};
// server.inject lets us similate an http request
server.inject(options, function(response) {
// console.log(" - - - - RESPONSE: ")
// console.log(response.result);
t.equal(response.result, token, 'Token is accesible from handler');
t.end();
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc