json_web_token 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53e92d6fa2738b3d32a6cb7ab7d1a6ac0b4da985
4
- data.tar.gz: 18518b039fe8009cb69d73f7a1bb0a7b1e49e520
3
+ metadata.gz: 1f2f2e9c05d1aa0624ecb4c80542779a4947440d
4
+ data.tar.gz: a743b29a91a80f888ef14cff51a31692e007955d
5
5
  SHA512:
6
- metadata.gz: d871623ab5168a3749e59c0c8a249262136517899d3d875cb7401b99a7f80d33134245e5b66b51673327b3e6e90362a8a75d2ae6082d6f2060404363e7408911
7
- data.tar.gz: 769622487b7bfc6df0013f4c977e39a17f1f0975328ecb26f7c7c1718e9c96bc66e170321c749beaabebd83c55061bfcdf90b7fa7d927322ffcf8b9032d342e0
6
+ metadata.gz: 33a0ad974222c5dc8773f9640f90e07e70b5afaa6986476341c6a2cbafd114e392810f33be973d85cc91c29e366fe7e6c1d2815870563310b648ef7dc29e8fc6
7
+ data.tar.gz: df28c9e985c1fd29e09cc13ae48c4b486b00f350f5d37cb92d876f9c0a3df152bba6c71432f5bd924d9a4e52c15c9d6501aa115e7040dc0d3568c590069faa13
data/.rspec CHANGED
@@ -1,2 +1 @@
1
1
  --color
2
- --require spec_helper
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- - 2.1.6
5
- - 2.0.0
6
- # uncomment this line if your project needs to run something other than `rake`:
7
- script: bundle exec rspec spec
3
+ - 2.0.0-p648
4
+ - 2.1.10
5
+ - 2.2.5
6
+ - 2.3.1
7
+ before_install: gem install bundler -v 1.13.2
@@ -1,51 +1,58 @@
1
1
  ## Changelog
2
2
 
3
+ ### v0.3.2 (2016-10-09)
4
+
5
+ * Enhancements
6
+ * Modernized the dev environment
7
+ * Added a `Support for JWT Registered Claims` section to the README, along with a link to the companion `jwt_claims` gem
8
+ * Fixed the README examples by using working tokens
9
+
3
10
  ### v0.3.1 (2015-08-25)
4
11
 
5
- * bug fix
12
+ * Bug fixes
6
13
  * README escaping removed
7
14
 
8
15
  ### v0.3.0 (2015-08-25)
9
16
 
10
- * backward incompatible changes
17
+ * Backward incompatible changes
11
18
  * JsonWebToken, Jwt, and Jws #verify return values
12
19
 
13
20
  ### v0.2.2 (2015-08-06)
14
21
 
15
- * enhancements
22
+ * Enhancements
16
23
  * RsaUtil to read keys from pem files
17
24
 
18
25
  ### v0.2.1 (2015-08-03)
19
26
 
20
- * enhancements
27
+ * Enhancements
21
28
  * Rsa#validate\_message\_size
22
29
 
23
30
  ### v0.2.0 (2015-08-02)
24
31
 
25
- * backward incompatible changes
32
+ * Backward incompatible changes
26
33
  * Top level API now #sign and #verify
27
34
 
28
35
  ### v0.1.2 (2015-08-02)
29
36
 
30
- * enhancements
37
+ * Enhancements
31
38
  * Jws#verify returns false (rather than 'Invalid') unless the signature is verified
32
39
 
33
40
  ### v0.1.1 (2015-07-13)
34
41
 
35
- * bug fix
42
+ * Bug fixes
36
43
  * #symbolize_keys spec failing on < ruby-2.2.0
37
44
 
38
45
  ### v0.1.0 (2015-07-12)
39
46
 
40
- * enhancements
47
+ * Enhancements
41
48
  * support ECDSA algorithm
42
49
 
43
50
  ### v0.0.2 (2015-07-11)
44
51
 
45
- * enhancements
52
+ * Enhancements
46
53
  * support RSASSA-PKCS-v1_5 algorithm
47
54
 
48
55
  ### v0.0.1 (2015-07-09)
49
56
 
50
- * initial
57
+ * Initial
51
58
  * support HMAC algorithm
data/Gemfile CHANGED
@@ -1,7 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ # Specify your gem's dependencies in json_web_token.gemspec
3
4
  gemspec
4
-
5
- gem 'pry-byebug', '~> 3.1', require: false
6
- gem 'simplecov', '~> 0.10', require: false
7
- gem 'yard', '~> 0.8', require: false
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Gary Fleshman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -28,6 +28,16 @@ Token authentication of API requests to Rails via these prominent gems:
28
28
 
29
29
  Secure Cross-Origin Resource Sharing ([CORS][cors]) using the [rack-cors][rack-cors] gem
30
30
 
31
+ ### Support for JWT Registered Claims
32
+
33
+ Support for the standard registered claims documented
34
+ in [RFC 7519][rfc7519] can be found in the companion gem [jwt_claims](https://github.com/garyf/jwt_claims).
35
+
36
+ `jwt_claims` is a wrapper around `json_web_token` and provides support
37
+ for the full set of registered claims.
38
+
39
+ [https://github.com/garyf/jwt_claims](https://github.com/garyf/jwt_claims)
40
+
31
41
  ## Usage
32
42
 
33
43
  ### JsonWebToken.sign(claims, options)
@@ -46,10 +56,11 @@ Example
46
56
  ```ruby
47
57
  require 'json_web_token'
48
58
 
49
- # sign with default algorithm, HMAC SHA256
59
+ # Sign with the default algorithm, HMAC SHA256
50
60
  jwt = JsonWebToken.sign({foo: 'bar'}, key: 'gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C')
61
+ #=> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIifQ.vpaYTGkypBmxDi3KZYcvpqLx9xqhRD-DSXONGrUbf5Q"
51
62
 
52
- # sign with RSA SHA256 algorithm
63
+ # Sign with RSA SHA256 algorithm
53
64
  opts = {
54
65
  alg: 'RSA256',
55
66
  key: < RSA private key >
@@ -57,7 +68,7 @@ opts = {
57
68
 
58
69
  jwt = JsonWebToken.sign({foo: 'bar'}, opts)
59
70
 
60
- # unsecured token (algorithm is 'none')
71
+ # Create an unsecured token (algorithm is 'none')
61
72
  jwt = JsonWebToken.sign({foo: 'bar'}, alg: 'none')
62
73
 
63
74
  ```
@@ -80,10 +91,13 @@ Example
80
91
  ```ruby
81
92
  require 'json_web_token'
82
93
 
83
- secure_jwt_example = 'eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt.cGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'
94
+ jwt = JsonWebToken.sign({foo: 'bar'}, key: 'gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C')
95
+ #=> "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIifQ.vpaYTGkypBmxDi3KZYcvpqLx9xqhRD-DSXONGrUbf5Q"
84
96
 
85
- # verify with default algorithm, HMAC SHA256
86
- {ok: claims} = JsonWebToken.verify(secure_jwt_example, key: 'gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C')
97
+ # Verify with default algorithm, HMAC SHA256
98
+ # Returns a hash of `{:ok, verified_claims}`
99
+ JsonWebToken.verify(jwt, key: 'gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr9C')
100
+ #=> {:ok=>{:foo=>"bar"}}
87
101
 
88
102
  # verify with RSA SHA256 algorithm
89
103
  opts = {
@@ -93,12 +107,14 @@ opts = {
93
107
 
94
108
  {ok: claims} = JsonWebToken.verify(jwt, opts)
95
109
 
96
- # unsecured token (algorithm is 'none')
97
- unsecured_jwt_example = 'eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt.'
98
-
99
- {ok: claims} = JsonWebToken.verify(unsecured_jwt_example, alg: 'none')
110
+ # Unsecured token (algorithm is 'none')
111
+ jwt = JsonWebToken.sign({foo: 'bar'}, alg: 'none')
112
+ #=> "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJmb28iOiJiYXIifQ."
100
113
 
114
+ JsonWebToken.verify(jwt, alg: 'none')
115
+ #=> {:ok=>{:foo=>"bar"}}
101
116
  ```
117
+
102
118
  ### Supported encryption algorithms
103
119
 
104
120
  alg Param Value | Digital Signature or MAC Algorithm
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'yard'
4
+ require 'wwtd/tasks'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ YARD::Rake::YardocTask.new
9
+
10
+ task default: :spec
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'json_web_token'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require 'pry'
10
+ Pry.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,21 +1,36 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
4
  require 'json_web_token/version'
4
5
 
5
6
  Gem::Specification.new do |s|
6
- s.author = 'Gary Fleshman'
7
- s.email = 'gfleshman@newforge-tech.com'
8
- s.files = `git ls-files`.split("\n")
9
- s.homepage = 'https://github.com/garyf/json_web_token'
10
- s.name = 'json_web_token'
7
+ s.name = 'json_web_token'
8
+ s.version = JsonWebToken::VERSION
9
+ s.authors = ['Gary Fleshman']
10
+ s.email = ['gfleshman@newforge-tech.com']
11
+
12
+ s.summary = 'JSON Web Token (JWT) for Ruby'
13
+ s.description = 'Ruby implementation of the JSON Web Token (JWT) standard, RFC 7519'
14
+ s.homepage = 'https://github.com/garyf/json_web_token'
15
+ s.license = 'MIT'
16
+
17
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+
21
+ s.require_paths = ['lib']
22
+
11
23
  s.platform = Gem::Platform::RUBY
12
- s.summary = 'JSON Web Token (JWT) for Ruby'
13
- s.version = JsonWebToken::VERSION
14
- # recommended
15
- s.license = 'MIT'
16
- # optional
17
- s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
18
- s.add_development_dependency 'rspec', '~> 3.3'
19
- s.description = 'Ruby implementation of the JSON Web Token (JWT) standard, RFC 7519'
20
24
  s.required_ruby_version = '>= 2.0.0'
25
+
26
+ s.add_runtime_dependency 'json', '>= 1.8.3'
27
+
28
+ s.add_development_dependency 'bundler', '~> 1.13'
29
+ s.add_development_dependency 'rake', '~> 10.0'
30
+ s.add_development_dependency 'rspec', '~> 3.0'
31
+ s.add_development_dependency 'pry', '~> 0.10'
32
+ s.add_development_dependency 'pry-byebug', '~> 3.4'
33
+ s.add_development_dependency 'simplecov', '~> 0.12'
34
+ s.add_development_dependency 'yard', '~> 0.9'
35
+ s.add_development_dependency 'wwtd', '~> 1.3'
21
36
  end
@@ -1,3 +1,3 @@
1
1
  module JsonWebToken
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
metadata CHANGED
@@ -1,22 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_web_token
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary Fleshman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-25 00:00:00.000000000 Z
11
+ date: 2016-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.8'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
19
  version: 1.8.3
@@ -24,28 +21,124 @@ dependencies:
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '1.8'
30
24
  - - ">="
31
25
  - !ruby/object:Gem::Version
32
26
  version: 1.8.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
33
55
  - !ruby/object:Gem::Dependency
34
56
  name: rspec
35
57
  requirement: !ruby/object:Gem::Requirement
36
58
  requirements:
37
59
  - - "~>"
38
60
  - !ruby/object:Gem::Version
39
- version: '3.3'
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.12'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.12'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.9'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.9'
125
+ - !ruby/object:Gem::Dependency
126
+ name: wwtd
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.3'
40
132
  type: :development
41
133
  prerelease: false
42
134
  version_requirements: !ruby/object:Gem::Requirement
43
135
  requirements:
44
136
  - - "~>"
45
137
  - !ruby/object:Gem::Version
46
- version: '3.3'
138
+ version: '1.3'
47
139
  description: Ruby implementation of the JSON Web Token (JWT) standard, RFC 7519
48
- email: gfleshman@newforge-tech.com
140
+ email:
141
+ - gfleshman@newforge-tech.com
49
142
  executables: []
50
143
  extensions: []
51
144
  extra_rdoc_files: []
@@ -55,8 +148,11 @@ files:
55
148
  - ".travis.yml"
56
149
  - CHANGELOG.md
57
150
  - Gemfile
58
- - LICENSE
151
+ - LICENSE.md
59
152
  - README.md
153
+ - Rakefile
154
+ - bin/console
155
+ - bin/setup
60
156
  - json_web_token.gemspec
61
157
  - lib/json_web_token.rb
62
158
  - lib/json_web_token/algorithm/common.rb
@@ -71,23 +167,6 @@ files:
71
167
  - lib/json_web_token/jwt.rb
72
168
  - lib/json_web_token/util.rb
73
169
  - lib/json_web_token/version.rb
74
- - spec/fixtures/rsa/private_key.pem
75
- - spec/fixtures/rsa/private_key_weak.pem
76
- - spec/fixtures/rsa/public_key.pem
77
- - spec/fixtures/rsa/public_key_alt.pem
78
- - spec/json_web_token/algorithm/ecdsa_spec.rb
79
- - spec/json_web_token/algorithm/hmac_spec.rb
80
- - spec/json_web_token/algorithm/rsa_spec.rb
81
- - spec/json_web_token/format/asn1_spec.rb
82
- - spec/json_web_token/format/base64_url_spec.rb
83
- - spec/json_web_token/jwa_spec.rb
84
- - spec/json_web_token/jws_spec.rb
85
- - spec/json_web_token/jwt_spec.rb
86
- - spec/json_web_token/util_spec.rb
87
- - spec/json_web_token_spec.rb
88
- - spec/spec_helper.rb
89
- - spec/support/ecdsa_key.rb
90
- - spec/support/plausible_jwt.rb
91
170
  homepage: https://github.com/garyf/json_web_token
92
171
  licenses:
93
172
  - MIT
@@ -108,9 +187,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
187
  version: '0'
109
188
  requirements: []
110
189
  rubyforge_project:
111
- rubygems_version: 2.4.8
190
+ rubygems_version: 2.6.7
112
191
  signing_key:
113
192
  specification_version: 4
114
193
  summary: JSON Web Token (JWT) for Ruby
115
194
  test_files: []
116
- has_rdoc: