jwtk / njwt

Node.js JWT support
Apache License 2.0
432 stars 49 forks source link

Add NBF clock tolerance #63

Open davidbonting opened 5 years ago

davidbonting commented 5 years ago

Sometimes the server clock time differs between machines. That's why we needed some tolerance within the NBF. So I looked at node-jsonwebtoken and implemented the same kind of functionality.

This fork fits our needs, but if we want to release this we probably want to change this part:

    if(args.length===4){
      verifier.setNbfTolerance(args[3]);

      if(args[2]==null){
        verifier.setSigningAlgorithm('none');
      }else{
        verifier.setSigningAlgorithm(args[2]);
      }

      if(args[1]==null){
        verifier.setSigningKey('');
      }else{
        verifier.setSigningKey(args[1]);
      }
    }

and

nJwt.verify(token,null,null,1000,function(err){

It's kind of ugly. Yet I don't know how to solve it without completely changing that function (without creating a breaking change).

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.7%) to 99.288% when pulling 5c4fb61574723af2e795fa8c5ff56090f011d056 on davidbonting:feature/nbf-clocktolerance into c334bf3d57a43a2e6c0c8758b3faed7071460539 on jwtk:master.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.7%) to 99.288% when pulling 5c4fb61574723af2e795fa8c5ff56090f011d056 on davidbonting:feature/nbf-clocktolerance into c334bf3d57a43a2e6c0c8758b3faed7071460539 on jwtk:master.