omniauth-jwt2 0.1.0 → 1.0.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 (54) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +81 -0
  4. data/CITATION.cff +20 -0
  5. data/CODE_OF_CONDUCT.md +134 -0
  6. data/CONTRIBUTING.md +272 -0
  7. data/FUNDING.md +74 -0
  8. data/LICENSE.md +16 -0
  9. data/README.md +499 -58
  10. data/RUBOCOP.md +71 -0
  11. data/SECURITY.md +21 -0
  12. data/certs/pboling.pem +27 -0
  13. data/lib/omniauth/jwt/version.rb +6 -3
  14. data/lib/omniauth/jwt.rb +2 -1
  15. data/lib/omniauth/jwt2/version.rb +10 -0
  16. data/lib/omniauth/jwt2.rb +10 -0
  17. data/lib/omniauth/strategies/jwt.rb +31 -9
  18. data/lib/omniauth-jwt2.rb +3 -0
  19. data/sig/omniauth/jwt/version.rbs +8 -0
  20. data/sig/omniauth/jwt2/version.rbs +8 -0
  21. data.tar.gz.sig +1 -0
  22. metadata +269 -61
  23. metadata.gz.sig +0 -0
  24. data/.github/FUNDING.yml +0 -11
  25. data/.github/dependabot.yml +0 -2
  26. data/.github/workflows/ancient.yml +0 -53
  27. data/.github/workflows/ci.yml +0 -59
  28. data/.github/workflows/coverage.yml +0 -91
  29. data/.github/workflows/legacy.yml +0 -54
  30. data/.github/workflows/style.yml +0 -43
  31. data/.gitignore +0 -18
  32. data/.rspec +0 -2
  33. data/.rubocop.yml +0 -2
  34. data/.rubocop_gradual.lock +0 -39
  35. data/.simplecov +0 -2
  36. data/.tool-versions +0 -1
  37. data/Gemfile +0 -17
  38. data/Guardfile +0 -8
  39. data/LICENSE.txt +0 -23
  40. data/Rakefile +0 -23
  41. data/gemfiles/ancient.gemfile +0 -20
  42. data/gemfiles/contexts/coverage.gemfile +0 -2
  43. data/gemfiles/contexts/debug.gemfile +0 -6
  44. data/gemfiles/contexts/style.gemfile +0 -5
  45. data/gemfiles/contexts/testing.gemfile +0 -8
  46. data/gemfiles/coverage.gemfile +0 -20
  47. data/gemfiles/legacy.gemfile +0 -26
  48. data/gemfiles/style.gemfile +0 -20
  49. data/gemfiles/vanilla.gemfile +0 -20
  50. data/omniauth-jwt2.gemspec +0 -41
  51. data/spec/lib/omniauth/strategies/jwt_spec.rb +0 -213
  52. data/spec/spec_helper.rb +0 -64
  53. data/spec/support/hash.rb +0 -9
  54. data/spec/support/next_instance_of.rb +0 -43
data/RUBOCOP.md ADDED
@@ -0,0 +1,71 @@
1
+ # RuboCop Usage Guide
2
+
3
+ ## Overview
4
+
5
+ A tale of two RuboCop plugin gems.
6
+
7
+ ### RuboCop Gradual
8
+
9
+ This project uses `rubocop_gradual` instead of vanilla RuboCop for code style checking. The `rubocop_gradual` tool allows for gradual adoption of RuboCop rules by tracking violations in a lock file.
10
+
11
+ ### RuboCop LTS
12
+
13
+ This project uses `rubocop-lts` to ensure, on a best-effort basis, compatibility with Ruby >= 1.9.2.
14
+ RuboCop rules are meticulously configured by the `rubocop-lts` family of gems to ensure that a project is compatible with a specific version of Ruby. See: https://rubocop-lts.gitlab.io for more.
15
+
16
+ ## Checking RuboCop Violations
17
+
18
+ To check for RuboCop violations in this project, always use:
19
+
20
+ ```bash
21
+ bundle exec rake rubocop_gradual:check
22
+ ```
23
+
24
+ **Do not use** the standard RuboCop commands like:
25
+ - `bundle exec rubocop`
26
+ - `rubocop`
27
+
28
+ ## Understanding the Lock File
29
+
30
+ The `.rubocop_gradual.lock` file tracks all current RuboCop violations in the project. This allows the team to:
31
+
32
+ 1. Prevent new violations while gradually fixing existing ones
33
+ 2. Track progress on code style improvements
34
+ 3. Ensure CI builds don't fail due to pre-existing violations
35
+
36
+ ## Common Commands
37
+
38
+ - **Check violations**
39
+ - `bundle exec rake rubocop_gradual`
40
+ - `bundle exec rake rubocop_gradual:check`
41
+ - **(Safe) Autocorrect violations, and update lockfile if no new violations**
42
+ - `bundle exec rake rubocop_gradual:autocorrect`
43
+ - **Force update the lock file (w/o autocorrect) to match violations present in code**
44
+ - `bundle exec rake rubocop_gradual:force_update`
45
+
46
+ ## Workflow
47
+
48
+ 1. Before submitting a PR, run `bundle exec rake rubocop_gradual:autocorrect`
49
+ a. or just the default `bundle exec rake`, as autocorrection is a pre-requisite of the default task.
50
+ 2. If there are new violations, either:
51
+ - Fix them in your code
52
+ - Run `bundle exec rake rubocop_gradual:force_update` to update the lock file (only for violations you can't fix immediately)
53
+ 3. Commit the updated `.rubocop_gradual.lock` file along with your changes
54
+
55
+ ## Never add inline RuboCop disables
56
+
57
+ Do not add inline `rubocop:disable` / `rubocop:enable` comments anywhere in the codebase (including specs, except when following the few existing `rubocop:disable` patterns for a rule already being disabled elsewhere in the code). We handle exceptions in two supported ways:
58
+
59
+ - Permanent/structural exceptions: prefer adjusting the RuboCop configuration (e.g., in `.rubocop.yml`) to exclude a rule for a path or file pattern when it makes sense project-wide.
60
+ - Temporary exceptions while improving code: record the current violations in `.rubocop_gradual.lock` via the gradual workflow:
61
+ - `bundle exec rake rubocop_gradual:autocorrect` (preferred; will autocorrect what it can and update the lock only if no new violations were introduced)
62
+ - If needed, `bundle exec rake rubocop_gradual:force_update` (as a last resort when you cannot fix the newly reported violations immediately)
63
+
64
+ In general, treat the rules as guidance to follow; fix violations rather than ignore them. For example, RSpec conventions in this project expect `described_class` to be used in specs that target a specific class under test.
65
+
66
+ ## Benefits of rubocop_gradual
67
+
68
+ - Allows incremental adoption of code style rules
69
+ - Prevents CI failures due to pre-existing violations
70
+ - Provides a clear record of code style debt
71
+ - Enables focused efforts on improving code quality over time
data/SECURITY.md ADDED
@@ -0,0 +1,21 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ |----------|-----------|
7
+ | 0.latest | ✅ |
8
+
9
+ ## Security contact information
10
+
11
+ To report a security vulnerability, please use the
12
+ [Tidelift security contact](https://tidelift.com/security).
13
+ Tidelift will coordinate the fix and disclosure.
14
+
15
+ ## Additional Support
16
+
17
+ If you are interested in support for versions older than the latest release,
18
+ please consider sponsoring the project / maintainer @ https://liberapay.com/pboling/donate,
19
+ or find other sponsorship links in the [README].
20
+
21
+ [README]: README.md
data/certs/pboling.pem ADDED
@@ -0,0 +1,27 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEgDCCAuigAwIBAgIBATANBgkqhkiG9w0BAQsFADBDMRUwEwYDVQQDDAxwZXRl
3
+ ci5ib2xpbmcxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW
4
+ A2NvbTAeFw0yNTA1MDQxNTMzMDlaFw00NTA0MjkxNTMzMDlaMEMxFTATBgNVBAMM
5
+ DHBldGVyLmJvbGluZzEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy
6
+ LGQBGRYDY29tMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAruUoo0WA
7
+ uoNuq6puKWYeRYiZekz/nsDeK5x/0IEirzcCEvaHr3Bmz7rjo1I6On3gGKmiZs61
8
+ LRmQ3oxy77ydmkGTXBjruJB+pQEn7UfLSgQ0xa1/X3kdBZt6RmabFlBxnHkoaGY5
9
+ mZuZ5+Z7walmv6sFD9ajhzj+oIgwWfnEHkXYTR8I6VLN7MRRKGMPoZ/yvOmxb2DN
10
+ coEEHWKO9CvgYpW7asIihl/9GMpKiRkcYPm9dGQzZc6uTwom1COfW0+ZOFrDVBuV
11
+ FMQRPswZcY4Wlq0uEBLPU7hxnCL9nKK6Y9IhdDcz1mY6HZ91WImNslOSI0S8hRpj
12
+ yGOWxQIhBT3fqCBlRIqFQBudrnD9jSNpSGsFvbEijd5ns7Z9ZMehXkXDycpGAUj1
13
+ to/5cuTWWw1JqUWrKJYoifnVhtE1o1DZ+LkPtWxHtz5kjDG/zR3MG0Ula0UOavlD
14
+ qbnbcXPBnwXtTFeZ3C+yrWpE4pGnl3yGkZj9SMTlo9qnTMiPmuWKQDatAgMBAAGj
15
+ fzB9MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQE8uWvNbPVNRXZ
16
+ HlgPbc2PCzC4bjAhBgNVHREEGjAYgRZwZXRlci5ib2xpbmdAZ21haWwuY29tMCEG
17
+ A1UdEgQaMBiBFnBldGVyLmJvbGluZ0BnbWFpbC5jb20wDQYJKoZIhvcNAQELBQAD
18
+ ggGBAJbnUwfJQFPkBgH9cL7hoBfRtmWiCvdqdjeTmi04u8zVNCUox0A4gT982DE9
19
+ wmuN12LpdajxZONqbXuzZvc+nb0StFwmFYZG6iDwaf4BPywm2e/Vmq0YG45vZXGR
20
+ L8yMDSK1cQXjmA+ZBKOHKWavxP6Vp7lWvjAhz8RFwqF9GuNIdhv9NpnCAWcMZtpm
21
+ GUPyIWw/Cw/2wZp74QzZj6Npx+LdXoLTF1HMSJXZ7/pkxLCsB8m4EFVdb/IrW/0k
22
+ kNSfjtAfBHO8nLGuqQZVH9IBD1i9K6aSs7pT6TW8itXUIlkIUI2tg5YzW6OFfPzq
23
+ QekSkX3lZfY+HTSp/o+YvKkqWLUV7PQ7xh1ZYDtocpaHwgxe/j3bBqHE+CUPH2vA
24
+ 0V/FwdTRWcwsjVoOJTrYcff8pBZ8r2MvtAc54xfnnhGFzeRHfcltobgFxkAXdE6p
25
+ DVjBtqT23eugOqQ73umLcYDZkc36vnqGxUBSsXrzY9pzV5gGr2I8YUxMqf6ATrZt
26
+ L9nRqA==
27
+ -----END CERTIFICATE-----
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../jwt2/version"
4
+
1
5
  module Omniauth
2
6
  module JWT
3
- module Version
4
- VERSION = "0.1.0"
5
- end
7
+ Version = JWT2::Version unless const_defined?(:Version, false)
8
+ VERSION = JWT2::VERSION unless const_defined?(:VERSION, false)
6
9
  end
7
10
  end
data/lib/omniauth/jwt.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  # External gems
2
2
  require "version_gem"
3
+ require_relative "jwt/version"
3
4
 
4
5
  # This gem
5
6
  require "omniauth/jwt/version"
6
7
  require "omniauth/strategies/jwt"
7
8
 
8
- Omniauth::JWT::Version.class_eval do
9
+ Omniauth::JWT2::Version.class_eval do
9
10
  extend VersionGem::Basic
10
11
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Omniauth
4
+ module JWT2
5
+ module Version
6
+ VERSION = "1.0.0"
7
+ end
8
+ VERSION = Version::VERSION # Traditional Constant Location
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "version_gem"
4
+ require_relative "jwt2/version"
5
+
6
+ require_relative "jwt"
7
+
8
+ Omniauth::JWT2::Version.class_eval do
9
+ extend VersionGem::Basic
10
+ end
@@ -5,7 +5,6 @@ module OmniAuth
5
5
  module Strategies
6
6
  class JWT
7
7
  class ClaimInvalid < StandardError; end
8
-
9
8
  class BadJwt < StandardError; end
10
9
 
11
10
  include OmniAuth::Strategy
@@ -18,13 +17,13 @@ module OmniAuth
18
17
  option :algorithm, "HS256" # overridden by options.decode_options[:algorithms]
19
18
  option :decode_options, {}
20
19
  option :uid_claim, "email"
21
- option :required_claims, %w(name email)
20
+ option :required_claims, %w[name email]
22
21
  option :info_map, {name: "name", email: "email"}
23
22
  option :auth_url, nil
24
23
  option :valid_within, nil
25
24
 
26
25
  def request_phase
27
- redirect(options.auth_url)
26
+ redirect options.auth_url
28
27
  end
29
28
 
30
29
  def decoded
@@ -34,7 +33,7 @@ module OmniAuth
34
33
  when "RS256", "RS384", "RS512"
35
34
  OpenSSL::PKey::RSA.new(options.secret).public_key
36
35
  when "ES256", "ES384", "ES512"
37
- OpenSSL::PKey::EC.new(options.secret)
36
+ ec_key(options.secret)
38
37
  when "HS256", "HS384", "HS512"
39
38
  options.secret
40
39
  else
@@ -53,9 +52,9 @@ module OmniAuth
53
52
  options.decode_options.merge(
54
53
  {
55
54
  algorithms: default_algos,
56
- jwks: options.jwks_loader,
57
- }.delete_if { |_, v| v.nil? },
58
- ),
55
+ jwks: options.jwks_loader
56
+ }.delete_if { |_, v| v.nil? }
57
+ )
59
58
  )[0]
60
59
  rescue Exception => e
61
60
  raise BadJwt.new("#{e.class}: #{e.message}")
@@ -71,12 +70,35 @@ module OmniAuth
71
70
  @decoded
72
71
  end
73
72
 
73
+ def ec_key(secret)
74
+ key = if secret.is_a?(OpenSSL::PKey::EC)
75
+ secret
76
+ elsif OpenSSL::PKey.respond_to?(:read)
77
+ OpenSSL::PKey.read(secret)
78
+ else
79
+ OpenSSL::PKey::EC.new(secret)
80
+ end
81
+
82
+ ec_public_key(key)
83
+ end
84
+
85
+ def ec_public_key(key)
86
+ return key unless key.respond_to?(:private?)
87
+ return key unless key.private?
88
+
89
+ public_key = OpenSSL::PKey::EC.new(key.group)
90
+ public_key.public_key = key.public_key
91
+ public_key
92
+ rescue OpenSSL::PKey::PKeyError
93
+ key
94
+ end
95
+
74
96
  def callback_phase
75
97
  super
76
98
  rescue BadJwt => e
77
- fail!("bad_jwt", e)
99
+ fail! "bad_jwt", e
78
100
  rescue ClaimInvalid => e
79
- fail!(:claim_invalid, e)
101
+ fail! :claim_invalid, e
80
102
  end
81
103
 
82
104
  uid { decoded[options.uid_claim] }
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "omniauth/jwt2"
@@ -0,0 +1,8 @@
1
+ module Omniauth
2
+ module JWT
3
+ module Version
4
+ VERSION: String
5
+ end
6
+ VERSION: String
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Omniauth
2
+ module JWT2
3
+ module Version
4
+ VERSION: String
5
+ end
6
+ VERSION: String
7
+ end
8
+ end
data.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+ g*�s�M����-}��s�鲁ll6e4m{K�<�jA$"�