Coder Social home page Coder Social logo

jwt_claims's People

Contributors

garyf avatar grempe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

jwt_claims's Issues

Verify with an exp claim throws exception with gem installed from Rubygems

The jwt_claims gem was installed from Rubygems today.

Sample console test:

[2] pry(main)> require 'jwt_claims'
=> true
[3] pry(main)> jwt = JsonWebToken.sign({foo: 'bar', exp: Time.now.to_i}, key: 'gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C')
=> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJleHAiOjE0NzU4MTgzOTN9.gAcGss07BPjPGrhhnX-YDKpaMII69nptcnzzl8Cz00k"
[4] pry(main)> JsonWebToken.verify(jwt, key: 'gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C')
=> {:ok=>{:foo=>"bar", :exp=>1475818393}}
[5] pry(main)> JwtClaims.verify(jwt, key: 'gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C')
NameError: uninitialized constant JwtClaims::Validation::Claim
Did you mean?  JwtClaims
from /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/jwt_claims-0.0.2/lib/jwt_claims/validation.rb:27:in `registered_claim'
[6] pry(main)>

I think the rspec tests are passing since they explicitly require the classes needed. I don't think the lib dir code is doing that properly.

https://github.com/garyf/jwt_claims/blob/master/spec/jwt_claims/claim/exp_spec.rb#L1

I get failing specs with this issue if I run spec files directly. For example:

bundle exec rspec spec/jwt_claims/validation_spec.rb
2) JwtClaims::Validation example data #rejected w all registered claims invalid returns array of failed claims
     Failure/Error:
       when :aud then Claim::Aud
       when :exp then Claim::Exp
       when :iat then Claim::Iat
       when :iss then Claim::Iss
       when :jti then Claim::Jti
       when :nbf then Claim::Nbf
       when :sub then Claim::Sub
       else nil # custom claim

     NameError:
       uninitialized constant JwtClaims::Validation::Claim
       Did you mean?  JwtClaims
     # ./lib/jwt_claims/validation.rb:26:in `registered_claim'
     # ./lib/jwt_claims/validation.rb:20:in `reject'
     # ./lib/jwt_claims/validation.rb:14:in `block in rejected'
     # ./lib/jwt_claims/validation.rb:13:in `each'
     # ./lib/jwt_claims/validation.rb:13:in `each_with_object'
     # ./lib/jwt_claims/validation.rb:13:in `rejected'
     # ./spec/jwt_claims/validation_spec.rb:55:in `block (5 levels) in <module:JwtClaims>'

I am submitting a pull request which I believe resolves these issues. A new release would need to be pushed to Rubygems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.