passport-jwt
Advanced tools
Comparing version 1.1.1 to 1.2.1
@@ -23,2 +23,4 @@ var passport = require('passport-strategy') | ||
* authScheme: Expected scheme when JWT can be found in HTTP Authorize header. Default is JWT. | ||
* algorithms: List of strings with the names of the allowed algorithms. For instance, ["HS256", "HS384"]. | ||
* ignoreExpiration: if true do not validate the expiration of the token. | ||
* passReqToCallback: If true the, the verify callback will be called with args (request, jwt_payload, done_callback). | ||
@@ -57,2 +59,10 @@ * @param verify - Verify callback with args (jwt_payload, done_callback) if passReqToCallback is false, | ||
if (options.algorithms) { | ||
this._verifOpts.algorithms = options.algorithms; | ||
} | ||
if (options.ignoreExpiration != null) { | ||
this._verifOpts.ignoreExpiration = options.ignoreExpiration; | ||
} | ||
}; | ||
@@ -108,3 +118,3 @@ util.inherits(JwtStrategy, passport.Strategy); | ||
} | ||
// Verify the JWT | ||
@@ -111,0 +121,0 @@ JwtStrategy.JwtVerifier(token, this._secretOrKey, this._verifOpts, function(jwt_err, payload) { |
{ | ||
"name": "passport-jwt", | ||
"version": "1.1.1", | ||
"version": "1.2.1", | ||
"description": "Passport authentication strategy using JSON Web Tokens", | ||
@@ -5,0 +5,0 @@ "main": "./lib", |
@@ -31,2 +31,5 @@ # passport-jwt | ||
this value. | ||
* `algorithms`: List of strings with the names of the allowed algorithms. For instance, ["HS256", "HS384"]. | ||
* `ignoreExpiration`: if true do not validate the expiration of the token. | ||
* `tokenBodyField`: Field in a request body to search for the jwt. | ||
@@ -33,0 +36,0 @@ Default is auth_token. |
@@ -9,3 +9,3 @@ var Strategy = require('../lib/strategy') | ||
describe('calling JWT validation function', function() { | ||
var strategy; | ||
var strategy; | ||
@@ -19,2 +19,4 @@ before(function(done) { | ||
options.secretOrKey = 'secret'; | ||
options.algorithms = ["HS256", "HS384"]; | ||
options.ignoreExpiration = false; | ||
strategy = new Strategy(options, verifyStub); | ||
@@ -52,3 +54,12 @@ | ||
it('should call with the right algorithms option', function() { | ||
expect(Strategy.JwtVerifier.args[0][2]).to.be.an.object; | ||
expect(Strategy.JwtVerifier.args[0][2].algorithms).to.eql(["HS256", "HS384"]); | ||
}); | ||
it('should call with the right ignoreExpiration option', function() { | ||
expect(Strategy.JwtVerifier.args[0][2]).to.be.an.object; | ||
expect(Strategy.JwtVerifier.args[0][2].ignoreExpiration).to.be.false; | ||
}); | ||
}); | ||
@@ -90,3 +101,3 @@ | ||
describe('handling failing jwt', function() { | ||
var strategy, info; | ||
var strategy, info; | ||
var verify_spy = sinon.spy(); | ||
@@ -128,3 +139,3 @@ | ||
describe('handling an invalid authentication header', function() { | ||
var strategy, info; | ||
var strategy, info; | ||
var verify_spy = sinon.spy(); | ||
@@ -160,2 +171,2 @@ | ||
}); | ||
}); |
@@ -111,3 +111,3 @@ var chai = require('chai') | ||
describe('hanlding a request with a valid jwt and an exception during verification', function() { | ||
describe('handling a request with a valid jwt and an exception during verification', function() { | ||
var strategy, err; | ||
@@ -141,3 +141,3 @@ | ||
describe('handing a request with a valid jwt and option passReqToCallback is true', function() { | ||
describe('handling a request with a valid jwt and option passReqToCallback is true', function() { | ||
@@ -144,0 +144,0 @@ var strategy, expected_request, request_arg; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30838
615
111