jwt 2.4.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -2
  3. data/CONTRIBUTING.md +7 -7
  4. data/README.md +135 -31
  5. data/lib/jwt/algos/algo_wrapper.rb +30 -0
  6. data/lib/jwt/algos/ecdsa.rb +2 -4
  7. data/lib/jwt/algos/eddsa.rb +4 -4
  8. data/lib/jwt/algos/hmac.rb +54 -17
  9. data/lib/jwt/algos/hmac_rbnacl.rb +53 -0
  10. data/lib/jwt/algos/hmac_rbnacl_fixed.rb +52 -0
  11. data/lib/jwt/algos/none.rb +3 -1
  12. data/lib/jwt/algos/ps.rb +3 -5
  13. data/lib/jwt/algos/rsa.rb +3 -4
  14. data/lib/jwt/algos.rb +38 -15
  15. data/lib/jwt/base64.rb +19 -0
  16. data/lib/jwt/configuration/container.rb +21 -0
  17. data/lib/jwt/configuration/decode_configuration.rb +46 -0
  18. data/lib/jwt/configuration/jwk_configuration.rb +27 -0
  19. data/lib/jwt/configuration.rb +15 -0
  20. data/lib/jwt/decode.rb +48 -27
  21. data/lib/jwt/encode.rb +30 -20
  22. data/lib/jwt/jwk/ec.rb +131 -62
  23. data/lib/jwt/jwk/hmac.rb +59 -24
  24. data/lib/jwt/jwk/key_base.rb +43 -7
  25. data/lib/jwt/jwk/key_finder.rb +14 -34
  26. data/lib/jwt/jwk/kid_as_key_digest.rb +15 -0
  27. data/lib/jwt/jwk/rsa.rb +128 -53
  28. data/lib/jwt/jwk/set.rb +80 -0
  29. data/lib/jwt/jwk/thumbprint.rb +26 -0
  30. data/lib/jwt/jwk.rb +13 -11
  31. data/lib/jwt/security_utils.rb +0 -27
  32. data/lib/jwt/version.rb +23 -2
  33. data/lib/jwt/x5c_key_finder.rb +1 -1
  34. data/lib/jwt.rb +5 -4
  35. data/ruby-jwt.gemspec +8 -4
  36. metadata +15 -30
  37. data/.codeclimate.yml +0 -8
  38. data/.github/workflows/coverage.yml +0 -27
  39. data/.github/workflows/test.yml +0 -66
  40. data/.gitignore +0 -13
  41. data/.reek.yml +0 -22
  42. data/.rspec +0 -2
  43. data/.rubocop.yml +0 -67
  44. data/.sourcelevel.yml +0 -17
  45. data/Appraisals +0 -13
  46. data/Gemfile +0 -7
  47. data/Rakefile +0 -16
  48. data/lib/jwt/default_options.rb +0 -18
  49. data/lib/jwt/signature.rb +0 -35
@@ -1,66 +0,0 @@
1
- ---
2
- name: test
3
- on:
4
- push:
5
- branches:
6
- - "*"
7
- pull_request:
8
- branches:
9
- - "*"
10
- jobs:
11
- lint:
12
- name: RuboCop
13
- timeout-minutes: 30
14
- runs-on: ubuntu-latest
15
- steps:
16
- - uses: actions/checkout@v2
17
- - name: Set up Ruby
18
- uses: ruby/setup-ruby@v1
19
- with:
20
- ruby-version: "3.0"
21
- bundler-cache: true
22
- - name: Run RuboCop
23
- run: bundle exec rubocop
24
- test:
25
- strategy:
26
- fail-fast: false
27
- matrix:
28
- ruby:
29
- - 2.5
30
- - 2.6
31
- - 2.7
32
- - "3.0"
33
- - 3.1
34
- gemfile:
35
- - gemfiles/standalone.gemfile
36
- - gemfiles/openssl.gemfile
37
- - gemfiles/rbnacl.gemfile
38
- experimental: [false]
39
- include:
40
- - ruby: 2.7
41
- gemfile: 'gemfiles/rbnacl.gemfile'
42
- - ruby: "ruby-head"
43
- experimental: true
44
- - ruby: "truffleruby-head"
45
- experimental: true
46
- runs-on: ubuntu-20.04
47
- continue-on-error: ${{ matrix.experimental }}
48
- env:
49
- BUNDLE_GEMFILE: ${{ matrix.gemfile }}
50
-
51
- steps:
52
- - uses: actions/checkout@v2
53
-
54
- - name: Install libsodium
55
- run: |
56
- sudo apt-get update -q
57
- sudo apt-get install libsodium-dev -y
58
-
59
- - name: Set up Ruby
60
- uses: ruby/setup-ruby@v1
61
- with:
62
- ruby-version: ${{ matrix.ruby }}
63
- bundler-cache: true
64
-
65
- - name: Run tests
66
- run: bundle exec rspec
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- .idea/
2
- jwt.gemspec
3
- pkg
4
- Gemfile.lock
5
- coverage/
6
- .DS_Store
7
- .rbenv-gemsets
8
- .ruby-version
9
- .vscode/
10
- .bundle
11
- *gemfile.lock
12
- .byebug_history
13
- *.gem
data/.reek.yml DELETED
@@ -1,22 +0,0 @@
1
- ---
2
- detectors:
3
- TooManyStatements:
4
- max_statements: 10
5
- UtilityFunction:
6
- enabled: false
7
- LongParameterList:
8
- enabled: false
9
- DuplicateMethodCall:
10
- max_calls: 2
11
- IrresponsibleModule:
12
- enabled: false
13
- NestedIterators:
14
- max_allowed_nesting: 2
15
- UnusedParameters:
16
- enabled: false
17
- FeatureEnvy:
18
- enabled: false
19
- ControlParameter:
20
- enabled: false
21
- UnusedPrivateMethod:
22
- enabled: false
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --require spec_helper
2
- --color
data/.rubocop.yml DELETED
@@ -1,67 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.5
3
- NewCops: enable
4
- SuggestExtensions: false
5
- Exclude:
6
- - 'gemfiles/*.gemfile'
7
- - 'vendor/**/*'
8
-
9
- Style/Documentation:
10
- Enabled: false
11
-
12
- Style/BlockDelimiters:
13
- Exclude:
14
- - spec/**/*_spec.rb
15
-
16
- Style/GuardClause:
17
- Enabled: false
18
-
19
- Style/IfUnlessModifier:
20
- Enabled: false
21
-
22
- Style/Lambda:
23
- Enabled: false
24
-
25
- Style/RaiseArgs:
26
- Enabled: false
27
-
28
- Metrics/AbcSize:
29
- Max: 25
30
-
31
- Metrics/ClassLength:
32
- Max: 105
33
-
34
- Metrics/ModuleLength:
35
- Max: 100
36
-
37
- Metrics/MethodLength:
38
- Max: 20
39
-
40
- Metrics/BlockLength:
41
- Exclude:
42
- - spec/**/*_spec.rb
43
-
44
- Layout/LineLength:
45
- Enabled: false
46
-
47
- Layout/EndAlignment:
48
- EnforcedStyleAlignWith: variable
49
-
50
- Layout/EmptyLineBetweenDefs:
51
- Enabled: true
52
- AllowAdjacentOneLineDefs: true
53
-
54
- Style/FormatString:
55
- Enabled: false
56
-
57
- Layout/MultilineMethodCallIndentation:
58
- EnforcedStyle: indented
59
-
60
- Layout/MultilineOperationIndentation:
61
- EnforcedStyle: indented
62
-
63
- Style/WordArray:
64
- Enabled: false
65
-
66
- Gemspec/RequireMFA:
67
- Enabled: false
data/.sourcelevel.yml DELETED
@@ -1,17 +0,0 @@
1
- engines:
2
- reek:
3
- enabled: true
4
- fixme:
5
- enabled: true
6
- rubocop:
7
- enabled: true
8
- channel: latest
9
- duplication:
10
- config:
11
- languages:
12
- - ruby
13
- enabled: true
14
- remark-lint:
15
- enabled: false
16
- exclude_paths:
17
- - spec
data/Appraisals DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise 'standalone' do
4
- # No additions
5
- end
6
-
7
- appraise 'openssl' do
8
- gem 'openssl', '~> 2.1'
9
- end
10
-
11
- appraise 'rbnacl' do
12
- gem 'rbnacl'
13
- end
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
6
-
7
- gem 'rubocop', '~> 1.23.0' # Keep .codeclimate.yml channel in sync with this one
data/Rakefile DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/setup'
4
- require 'bundler/gem_tasks'
5
-
6
- begin
7
- require 'rspec/core/rake_task'
8
- require 'rubocop/rake_task'
9
-
10
- RSpec::Core::RakeTask.new(:test)
11
- RuboCop::RakeTask.new(:rubocop)
12
-
13
- task default: %i[rubocop test]
14
- rescue LoadError
15
- puts 'RSpec rake tasks not available. Please run "bundle install" to install missing dependencies.'
16
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module JWT
4
- module DefaultOptions
5
- DEFAULT_OPTIONS = {
6
- verify_expiration: true,
7
- verify_not_before: true,
8
- verify_iss: false,
9
- verify_iat: false,
10
- verify_jti: false,
11
- verify_aud: false,
12
- verify_sub: false,
13
- leeway: 0,
14
- algorithms: ['HS256'],
15
- required_claims: []
16
- }.freeze
17
- end
18
- end
data/lib/jwt/signature.rb DELETED
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'jwt/security_utils'
4
- require 'openssl'
5
- require 'jwt/algos'
6
- begin
7
- require 'rbnacl'
8
- rescue LoadError
9
- raise if defined?(RbNaCl)
10
- end
11
-
12
- # JWT::Signature module
13
- module JWT
14
- # Signature logic for JWT
15
- module Signature
16
- module_function
17
-
18
- ToSign = Struct.new(:algorithm, :msg, :key)
19
- ToVerify = Struct.new(:algorithm, :public_key, :signing_input, :signature)
20
-
21
- def sign(algorithm, msg, key)
22
- algo, code = Algos.find(algorithm)
23
- algo.sign ToSign.new(code, msg, key)
24
- end
25
-
26
- def verify(algorithm, key, signing_input, signature)
27
- algo, code = Algos.find(algorithm)
28
- algo.verify(ToVerify.new(code, key, signing_input, signature))
29
- rescue OpenSSL::PKey::PKeyError
30
- raise JWT::VerificationError, 'Signature verification raised'
31
- ensure
32
- OpenSSL.errors.clear
33
- end
34
- end
35
- end