garyf / jwt_claims Goto Github PK
View Code? Open in Web Editor NEWA Ruby implementation of the JSON Web Token (JWT) registered claims, RFC 7519
License: MIT License
A Ruby implementation of the JSON Web Token (JWT) registered claims, RFC 7519
License: MIT License
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.