Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1, add additional requires to avoid raised exceptions #2

Merged
merged 3 commits into from
Oct 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
--color
--require spec_helper
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: ruby
rvm:
- 2.2.2
- 2.1.6
- 2.0.0
# uncomment this line if your project needs to run something other than `rake`:
script: bundle exec rspec spec
- 2.0.0-p648
- 2.1.10
- 2.2.5
- 2.3.1
before_install: gem install bundler -v 1.13.2
5 changes: 1 addition & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in jwt_claims.gemspec
gemspec

gem 'pry-byebug', '~> 3.1', require: false
gem 'simplecov', '~> 0.10', require: false
gem 'yard', '~> 0.8', require: false
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ Please refer to the [JSON Web Token][json_web_token] gem for additional guidance
Example

```ruby

secure_jwt_example = 'eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt.cGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'

# verify with default algorithm, HMAC SHA256
{:ok, verified_claims} = JwtClaims.verify(secure_jwt_example, key: 'gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C')

# An example using the 'Expires' `exp` claim (10 years for this example).
> jwt = JsonWebToken.sign({foo: 'bar', exp: Time.now.to_i + 315360000}, key: 'gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C')
#=> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJleHAiOjE3OTEyMjc1MTl9.7cT7PzsT8Jv0VQIxokjk3sUqzJCxBR4h3W2uACQ-tW0"

# Verify with default algorithm, HMAC SHA256
# Returns a hash of `{:ok, verified_claims}`
> JwtClaims.verify(jwt, key: 'gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C')
#=> {:ok=>{:foo=>"bar", :exp=>1475870843}}
```

### Supported registered claims
Expand Down
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'yard'
require 'wwtd/tasks'

RSpec::Core::RakeTask.new(:spec)

YARD::Rake::YardocTask.new

task default: :spec
10 changes: 10 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby

require 'bundler/setup'
require 'jwt_claims'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

require 'pry'
Pry.start
8 changes: 8 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here
45 changes: 30 additions & 15 deletions jwt_claims.gemspec
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'jwt_claims/version'

Gem::Specification.new do |s|
s.author = 'Gary Fleshman'
s.email = 'gfleshman@newforge-tech.com'
s.files = `git ls-files`.split("\n")
s.homepage = 'https://github.com/garyf/jwt_claims'
s.name = 'jwt_claims'
s.name = 'jwt_claims'
s.version = JwtClaims::VERSION
s.authors = ['Gary Fleshman']
s.email = ['gfleshman@newforge-tech.com']

s.summary = 'JSON Web Token (JWT) Claims for Ruby'
s.description = 'Modular implementation of JSON Web Token (JWT) Claims'
s.homepage = 'https://github.com/garyf/jwt_claims'
s.license = 'MIT'

s.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end

s.require_paths = ['lib']

s.platform = Gem::Platform::RUBY
s.summary = 'JSON Web Token (JWT) Claims for Ruby'
s.version = JwtClaims::VERSION
# recommended
s.license = 'MIT'
# optional
s.add_runtime_dependency('json_web_token', '~> 0.3')
s.add_development_dependency('rspec', '~> 3.3')
s.description = 'Modular implementation of JSON Web Token (JWT) Claims'
s.required_ruby_version = '>= 2.0.0'

s.add_runtime_dependency('json_web_token', '~> 0.3')

s.add_development_dependency 'bundler', '~> 1.13'
s.add_development_dependency 'rake', '~> 10.0'
s.add_development_dependency 'rspec', '~> 3.0'
s.add_development_dependency 'pry', '~> 0.10'
s.add_development_dependency 'pry-byebug', '~> 3.4'
s.add_development_dependency 'simplecov', '~> 0.12'
s.add_development_dependency 'yard', '~> 0.9'
s.add_development_dependency 'wwtd', '~> 1.3'
end
2 changes: 2 additions & 0 deletions lib/jwt_claims/claim/exp.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'jwt_claims/util'

module JwtClaims
module Claim
# Expiration time
Expand Down
2 changes: 2 additions & 0 deletions lib/jwt_claims/claim/nbf.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'jwt_claims/util'

module JwtClaims
module Claim
# Not before
Expand Down
8 changes: 8 additions & 0 deletions lib/jwt_claims/validation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
require 'jwt_claims/claim/aud'
require 'jwt_claims/claim/exp'
require 'jwt_claims/claim/iat'
require 'jwt_claims/claim/iss'
require 'jwt_claims/claim/jti'
require 'jwt_claims/claim/nbf'
require 'jwt_claims/claim/sub'

module JwtClaims
# Validate registered claims
# @see http://tools.ietf.org/html/rfc7519#section-4.1
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# Allows RSpec to persist some state between runs in order to support the
# `--only-failures` and `--next-failure` CLI options. We recommend you
# configure your source control system to ignore this file.
config.example_status_persistence_file_path = "spec/examples.txt"
config.example_status_persistence_file_path = 'spec/examples.txt'

# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
Expand Down