omniauth_oidc 0.2.7 → 1.2.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.
@@ -5,6 +5,15 @@ module OmniAuth
5
5
  class Oidc
6
6
  # Token verification phase
7
7
  module Verify # rubocop:disable Metrics/ModuleLength
8
+ HMAC_ALGORITHMS = %w[HS256 HS384 HS512].freeze
9
+
10
+ # Algorithm assumed when neither client_signing_alg nor the discovery document names one
11
+ DEFAULT_SIGNING_ALGORITHM = "RS256"
12
+
13
+ # Minimum seconds between JWKS refreshes triggered by an unknown kid, so tokens with
14
+ # made-up kids cannot be used to hammer the provider's JWKS endpoint.
15
+ JWKS_REFRESH_MIN_INTERVAL = 60
16
+
8
17
  def secret
9
18
  base64_decoded_jwt_secret || client_options.secret
10
19
  end
@@ -27,10 +36,28 @@ module OmniAuth
27
36
  end
28
37
  end
29
38
 
39
+ # Refetch the JWKS, at most once per JWKS_REFRESH_MIN_INTERVAL for each jwks_uri
40
+ def public_key_with_refresh
41
+ return public_key if configured_public_key || config.jwks_uri.nil?
42
+
43
+ OmniauthOidc::Logging.info("Refreshing JWKS", jwks_uri: config.jwks_uri)
44
+ @public_key = fetch_key(force_refresh: true)
45
+ end
46
+
30
47
  private
31
48
 
32
- def fetch_key
33
- @fetch_key ||= parse_jwk_key(::OpenIDConnect.http_client.get(config.jwks_uri).body)
49
+ def fetch_key(force_refresh: false)
50
+ OmniauthOidc::JwksCache.instance.fetch(config.jwks_uri, force_refresh: force_refresh,
51
+ ttl: options.jwks_cache_ttl.to_i,
52
+ min_age: JWKS_REFRESH_MIN_INTERVAL) do
53
+ OmniauthOidc::Logging.instrument("jwks.fetch", jwks_uri: config.jwks_uri) do
54
+ response = OmniauthOidc::HttpClient.get(config.jwks_uri)
55
+ OmniauthOidc::JwkHandler.parse_jwks(response)
56
+ end
57
+ end
58
+ rescue StandardError => e
59
+ OmniauthOidc::Logging.error("Failed to fetch JWKS", error: e.message, jwks_uri: config.jwks_uri)
60
+ raise OmniauthOidc::JwksFetchError, "Failed to fetch JWKS from #{config.jwks_uri}: #{e.message}"
34
61
  end
35
62
 
36
63
  def base64_decoded_jwt_secret
@@ -39,75 +66,168 @@ module OmniAuth
39
66
  Base64.decode64(options.jwt_secret_base64)
40
67
  end
41
68
 
69
+ # An empty key lets anyone forge HS* tokens (CVE-2026-45363), so never verify with one
70
+ def hmac_secret
71
+ key = secret.to_s
72
+ return key unless key.empty?
73
+
74
+ raise OmniauthOidc::ConfigurationError, "HMAC secret for ID token verification is empty"
75
+ end
76
+
42
77
  def verify_id_token!(id_token)
43
78
  return unless id_token
44
79
 
45
- decode_id_token(id_token).verify!(issuer: config.issuer,
46
- client_id: client_options.identifier,
47
- nonce: params["nonce"].presence || stored_nonce)
80
+ OmniauthOidc::Logging.instrument("id_token.verify", provider: name) do
81
+ decoded = decode_id_token(id_token)
82
+ verify_claims!(decoded)
83
+ decoded
84
+ end
48
85
  end
49
86
 
50
- def decode_id_token(id_token)
51
- decoded = JSON::JWT.decode(id_token, :skip_verification)
52
- algorithm = decoded.algorithm.to_sym
87
+ def verify_claims!(decoded_token)
88
+ claims = decoded_token.raw_attributes
53
89
 
54
- validate_client_algorithm!(algorithm)
90
+ # Consume the nonce before any check can fail, so it stays single use
91
+ expected_nonce = stored_nonce
55
92
 
56
- keyset =
57
- case algorithm
58
- when :HS256, :HS384, :HS512
59
- secret
60
- else
61
- public_key
62
- end
93
+ verify_issuer!(claims)
94
+ verify_audience!(claims)
95
+ verify_nonce!(claims, expected_nonce)
96
+ verify_expiration!(claims)
97
+
98
+ decoded_token
99
+ end
63
100
 
64
- decoded.verify!(keyset)
65
- ::OpenIDConnect::ResponseObject::IdToken.new(decoded)
66
- rescue JSON::JWK::Set::KidNotFound
67
- # Workaround for https://github.com/nov/json-jwt/pull/92#issuecomment-824654949
68
- raise if decoded&.header&.key?("kid")
101
+ # The discovery document is validated to always carry an issuer, so this check
102
+ # cannot be skipped by a provider that omits it.
103
+ def verify_issuer!(claims)
104
+ return if claims["iss"] == config.issuer
69
105
 
70
- decoded = decode_with_each_key!(id_token, keyset)
106
+ raise OmniauthOidc::InvalidIssuerError,
107
+ "Issuer mismatch. Expected: #{config.issuer}, Got: #{claims["iss"]}"
108
+ end
71
109
 
72
- raise unless decoded
110
+ def verify_audience!(claims)
111
+ audience = claims["aud"]
112
+ expected_aud = client_options.identifier
113
+ return if audience_matches?(audience, expected_aud)
73
114
 
74
- decoded
115
+ raise OmniauthOidc::InvalidAudienceError,
116
+ "Audience mismatch. Expected: #{expected_aud}, Got: #{audience}"
75
117
  end
76
118
 
77
- # Check for jwt to match defined client_signing_alg
78
- def validate_client_algorithm!(algorithm)
79
- client_signing_alg = options.client_signing_alg&.to_sym
119
+ # The expected nonce comes only from the session. Never read it from request params:
120
+ # the caller controls those. Nonce values are left out of messages because they end
121
+ # up in logs.
122
+ def verify_nonce!(claims, expected_nonce)
123
+ if expected_nonce.nil?
124
+ return unless nonce_required?
80
125
 
81
- return unless client_signing_alg
82
- return if algorithm == client_signing_alg
126
+ raise OmniauthOidc::InvalidNonceError, "No nonce stored in the session for this login"
127
+ end
128
+ return if claims["nonce"] == expected_nonce
83
129
 
84
- reason = "Received JWT is signed with #{algorithm}, but client_singing_alg is \
85
- configured for #{client_signing_alg}"
86
- raise CallbackError, error: :invalid_jwt_algorithm, reason: reason, uri: params["error_uri"]
130
+ raise OmniauthOidc::InvalidNonceError, "ID token nonce does not match the authorization request"
87
131
  end
88
132
 
89
- def decode!(id_token, key)
90
- ::OpenIDConnect::ResponseObject::IdToken.decode(id_token, key)
133
+ # OIDC Core 3.2.2.1 requires a nonce for the implicit (id_token) flow, so it is
134
+ # always used there, regardless of send_nonce.
135
+ def nonce_required?
136
+ options.send_nonce || options.response_type.to_s == "id_token"
91
137
  end
92
138
 
93
- def decode_with_each_key!(id_token, keyset)
94
- return unless keyset.is_a?(JSON::JWK::Set)
139
+ # exp is required by OIDC Core 3.1.3.7 and must be a NumericDate (RFC 7519 2).
140
+ # Clock skew between us and the provider is tolerated up to clock_skew_leeway.
141
+ def verify_expiration!(claims)
142
+ exp = claims["exp"]
143
+ raise OmniauthOidc::TokenVerificationError, "ID token is missing the exp claim" if exp.nil?
144
+ raise OmniauthOidc::TokenVerificationError, "ID token exp claim is not a number" unless exp.is_a?(Numeric)
145
+ return if Time.now.to_i < exp + clock_skew_leeway
95
146
 
96
- keyset.each do |key|
97
- begin
98
- decoded = decode!(id_token, key)
99
- rescue JSON::JWS::VerificationFailed, JSON::JWS::UnexpectedAlgorithm, JSON::JWK::UnknownAlgorithm
100
- next
101
- end
147
+ raise OmniauthOidc::TokenExpiredError, "Token expired at #{Time.at(exp)}"
148
+ end
102
149
 
103
- return decoded if decoded
104
- end
150
+ def audience_matches?(audience, expected)
151
+ return audience == expected if audience.is_a?(String)
152
+ return audience.include?(expected) if audience.is_a?(Array)
105
153
 
106
- nil
154
+ false
107
155
  end
108
156
 
109
- def stored_nonce
110
- session.delete("omniauth.nonce")
157
+ def clock_skew_leeway
158
+ leeway = options.clock_skew_leeway
159
+ return leeway if leeway.is_a?(Integer) && leeway >= 0
160
+
161
+ raise OmniauthOidc::ConfigurationError,
162
+ "clock_skew_leeway must be a non-negative Integer, got #{leeway.inspect}"
163
+ end
164
+
165
+ def decode_id_token(id_token)
166
+ # First decode without verification to get the algorithm and kid
167
+ _unverified_payload, unverified_header = JWT.decode(id_token, nil, false)
168
+ algorithm = unverified_header["alg"].to_s
169
+
170
+ validate_algorithm!(algorithm)
171
+
172
+ # Get the appropriate key/secret for verification
173
+ key = keyset_for_algorithm(algorithm, unverified_header["kid"])
174
+
175
+ # Decode and verify
176
+ verify_signature!(id_token, key, algorithm)
177
+ rescue JWT::DecodeError => e
178
+ raise OmniauthOidc::TokenVerificationError, "Invalid JWT format: #{e.message}"
179
+ end
180
+
181
+ def keyset_for_algorithm(algorithm, kid = nil)
182
+ return hmac_secret if HMAC_ALGORITHMS.include?(algorithm)
183
+
184
+ keys = public_key
185
+ return keys unless keys.is_a?(Array)
186
+
187
+ # The provider may have rotated its signing keys since the JWKS was cached
188
+ keys = public_key_with_refresh if kid && keys.none? { |key| key.kid == kid }
189
+ OmniauthOidc::JwkHandler.find_key(keys, kid)
190
+ end
191
+
192
+ def verify_signature!(id_token, key, algorithm)
193
+ payload, _header = JWT.decode(
194
+ id_token,
195
+ key,
196
+ true, # verify signature
197
+ # exp is verified manually in verify_claims!
198
+ { algorithm: algorithm, verify_expiration: false, nbf_leeway: clock_skew_leeway }
199
+ )
200
+
201
+ # Create our custom IdToken object
202
+ OmniauthOidc::ResponseObjects::IdToken.new(payload.merge("algorithm" => algorithm))
203
+ rescue JWT::VerificationError => e
204
+ raise OmniauthOidc::InvalidSignatureError, "JWT signature verification failed: #{e.message}"
205
+ rescue JWT::IncorrectAlgorithm => e
206
+ raise OmniauthOidc::InvalidAlgorithmError, "Unexpected JWT algorithm: #{e.message}"
207
+ end
208
+
209
+ # The token header is attacker controlled, so the accepted algorithms come from
210
+ # configuration only. "none" is never accepted.
211
+ def validate_algorithm!(algorithm)
212
+ allowed = allowed_signing_algorithms
213
+ return if allowed.include?(algorithm)
214
+
215
+ raise OmniauthOidc::InvalidAlgorithmError,
216
+ "Received JWT is signed with #{algorithm.empty? ? "no algorithm" : algorithm}, " \
217
+ "but only #{allowed.empty? ? "signed tokens" : allowed.join(", ")} are accepted"
218
+ end
219
+
220
+ # client_signing_alg when set, otherwise the algorithms the discovery document
221
+ # advertises for ID tokens, otherwise RS256.
222
+ def allowed_signing_algorithms
223
+ algorithms = if options.client_signing_alg
224
+ [options.client_signing_alg]
225
+ else
226
+ Array(config.id_token_signing_alg_values_supported)
227
+ end
228
+ algorithms = [DEFAULT_SIGNING_ALGORITHM] if algorithms.empty?
229
+
230
+ algorithms.map(&:to_s) - ["none"]
111
231
  end
112
232
 
113
233
  def configured_public_key
@@ -120,31 +240,15 @@ module OmniAuth
120
240
 
121
241
  def parse_x509_key(key)
122
242
  OpenSSL::X509::Certificate.new(key).public_key
243
+ rescue OpenSSL::X509::CertificateError => e
244
+ raise OmniauthOidc::TokenVerificationError, "Invalid X.509 certificate: #{e.message}"
123
245
  end
124
246
 
125
247
  def parse_jwk_key(key)
126
248
  json = key.is_a?(String) ? JSON.parse(key) : key
127
- return JSON::JWK::Set.new(json["keys"]) if json.key?("keys")
128
-
129
- JSON::JWK.new(json)
130
- end
131
-
132
- def decode(str)
133
- UrlSafeBase64.decode64(str).unpack1("B*").to_i(2).to_s
134
- end
135
-
136
- def user_info
137
- return @user_info if @user_info
138
-
139
- if access_token.id_token
140
- decoded = decode_id_token(access_token.id_token).raw_attributes
141
-
142
- @user_info = ::OpenIDConnect::ResponseObject::UserInfo.new(
143
- access_token.userinfo!.raw_attributes.merge(decoded)
144
- )
145
- else
146
- @user_info = access_token.userinfo!
147
- end
249
+ OmniauthOidc::JwkHandler.parse_jwks(json)
250
+ rescue JSON::ParserError => e
251
+ raise OmniauthOidc::TokenVerificationError, "Invalid JWK format: #{e.message}"
148
252
  end
149
253
  end
150
254
  end
@@ -5,21 +5,26 @@ require "timeout"
5
5
  require "net/http"
6
6
  require "open-uri"
7
7
  require "omniauth"
8
- require "openid_connect"
9
- require "openid_config_parser"
10
8
  require "forwardable"
11
- require "httparty"
9
+ require "jwt"
10
+ require "ostruct"
11
+ require "openssl"
12
12
 
13
- Dir[File.join(File.dirname(__FILE__), "oidc", "*.rb")].sort.each { |file| require_relative file }
13
+ # Explicit requires instead of Dir glob for clarity and load order control
14
+ require_relative "oidc/request"
15
+ require_relative "oidc/callback"
16
+ require_relative "oidc/verify"
17
+ require_relative "oidc/redirect_uri"
14
18
 
15
19
  module OmniAuth
16
20
  module Strategies
17
- # OIDC strategy for omniauth
21
+ # OIDC strategy for OmniAuth
18
22
  class Oidc
19
23
  include OmniAuth::Strategy
20
24
  include Request
21
25
  include Callback
22
26
  include Verify
27
+ include RedirectUri
23
28
 
24
29
  extend Forwardable
25
30
 
@@ -28,6 +33,8 @@ module OmniAuth
28
33
  "code" => { exception_class: OmniauthOidc::MissingCodeError, key: :missing_code }.freeze
29
34
  }.freeze
30
35
 
36
+ REQUIRED_OPTIONS = %i[identifier secret config_endpoint].freeze
37
+
31
38
  def_delegator :request, :params
32
39
 
33
40
  option :name, :oidc # to separate each oidc provider available in the app
@@ -43,6 +50,7 @@ module OmniAuth
43
50
  jwks_uri: nil, # optional
44
51
  end_session_endpoint: nil) # optional
45
52
 
53
+ option :redirect_uri
46
54
  option :issuer
47
55
  option :client_signing_alg
48
56
  option :jwt_secret_base64
@@ -67,8 +75,8 @@ module OmniAuth
67
75
  option :post_logout_redirect_uri
68
76
  option :extra_authorize_params, {}
69
77
  option :allow_authorize_params, []
70
- option :uid_field, "sub"
71
- option :pkce, false
78
+ option :uid_field, "sub" # Deprecated: never had an effect, the uid is always `sub`. Removed in 2.0.0
79
+ option :pkce, true
72
80
  option :pkce_verifier, nil
73
81
  option :pkce_options, {
74
82
  code_challenge: proc { |verifier|
@@ -79,8 +87,22 @@ module OmniAuth
79
87
 
80
88
  option :logout_path, "/logout"
81
89
 
90
+ # JWKS and discovery document cache TTLs in seconds
91
+ option :jwks_cache_ttl, OmniauthOidc::JwksCache::DEFAULT_TTL
92
+ option :discovery_cache_ttl, OmniauthOidc::ConfigFetcher::DEFAULT_CACHE_TTL
93
+
94
+ # Seconds of clock drift tolerated when checking ID token exp and nbf
95
+ option :clock_skew_leeway, 60
96
+
97
+ def initialize(app, *args, &block)
98
+ super
99
+ warn_uid_field_deprecation
100
+ warn_redirect_uri_in_extra_authorize_params
101
+ end
102
+
103
+ # Always the subject claim: the only identifier OIDC guarantees to be stable and unique per issuer
82
104
  def uid
83
- user_info.raw_attributes[options.uid_field.to_sym] || user_info.sub
105
+ user_info.sub
84
106
  end
85
107
 
86
108
  info do
@@ -104,27 +126,47 @@ module OmniAuth
104
126
 
105
127
  credentials do
106
128
  {
107
- id_token: access_token.id_token,
108
- token: access_token.access_token,
109
- refresh_token: access_token.refresh_token,
110
- expires_in: access_token.expires_in,
111
- scope: access_token.scope
129
+ id_token: access_token&.id_token,
130
+ token: access_token&.access_token,
131
+ refresh_token: access_token&.refresh_token,
132
+ expires_in: access_token&.expires_in,
133
+ scope: access_token&.scope
112
134
  }
113
135
  end
114
136
 
115
- # Initialize OpenIDConnect Client with options
137
+ # Initialize our custom OIDC Client with options
116
138
  def client
117
- @client ||= ::OpenIDConnect::Client.new(client_options)
139
+ @client ||= begin
140
+ set_client_endpoints
141
+ OmniauthOidc::Client.new(
142
+ identifier: client_options.identifier,
143
+ secret: client_options.secret,
144
+ authorization_endpoint: client_options.authorization_endpoint,
145
+ token_endpoint: client_options.token_endpoint,
146
+ userinfo_endpoint: client_options.userinfo_endpoint,
147
+ redirect_uri: redirect_uri
148
+ )
149
+ end
118
150
  end
119
151
 
120
- # Config is build from the json response from the OIDC config endpoint
152
+ def set_client_endpoints
153
+ client_options.authorization_endpoint ||= config.authorization_endpoint
154
+ client_options.token_endpoint ||= config.token_endpoint
155
+ client_options.userinfo_endpoint ||= config.userinfo_endpoint
156
+ client_options.jwks_uri ||= config.jwks_uri
157
+ client_options.end_session_endpoint ||= config.end_session_endpoint
158
+ end
159
+
160
+ # Config is built from the json response from the OIDC config endpoint.
161
+ # OmniAuth dups the strategy per request, so the process-wide cache is what avoids
162
+ # refetching the discovery document on every request.
121
163
  def config
122
- unless client_options.config_endpoint || params["config_endpoint"]
123
- raise Error,
124
- "Configuration endpoint is missing from options"
125
- end
164
+ validate_configuration!
126
165
 
127
- @config ||= OpenidConfigParser.fetch_openid_configuration(client_options.config_endpoint)
166
+ endpoint = client_options.config_endpoint
167
+ @config ||= OmniauthOidc::Logging.instrument("config.fetch", config_endpoint: endpoint) do
168
+ OmniauthOidc::ConfigFetcher.fetch_cached(endpoint, ttl: options.discovery_cache_ttl.to_i)
169
+ end
128
170
  end
129
171
 
130
172
  # Detects if current request is for the logout url and makes a redirect to end session with OIDC provider
@@ -148,6 +190,25 @@ module OmniAuth
148
190
 
149
191
  private
150
192
 
193
+ def warn_uid_field_deprecation
194
+ return if options.uid_field.to_s == "sub"
195
+
196
+ OmniauthOidc::Logging.warn("The uid_field option is deprecated and has no effect: the uid is always the " \
197
+ "sub claim. Remove it from the #{name} provider; it is removed in 2.0.0.")
198
+ end
199
+
200
+ def validate_configuration!
201
+ missing = []
202
+ missing << :identifier if client_options.identifier.to_s.empty?
203
+ missing << :secret if client_options.secret.to_s.empty?
204
+ missing << :config_endpoint if client_options.config_endpoint.to_s.empty?
205
+
206
+ return if missing.empty?
207
+
208
+ raise OmniauthOidc::MissingConfigurationError,
209
+ "Missing required configuration: #{missing.join(", ")}"
210
+ end
211
+
151
212
  def issuer
152
213
  @issuer ||= config.issuer
153
214
  end
@@ -158,7 +219,8 @@ module OmniAuth
158
219
 
159
220
  # By default Returns all scopes supported by the OIDC provider
160
221
  def scope
161
- options.scope || config.scopes_supported || [:open_id]
222
+ value = options.scope || config.scopes_supported || [:openid]
223
+ value.is_a?(Array) ? value.join(" ") : value
162
224
  end
163
225
 
164
226
  def authorization_code
@@ -169,12 +231,21 @@ module OmniAuth
169
231
  options.client_options
170
232
  end
171
233
 
234
+ # Session key helpers with provider namespacing
235
+ def session_key(suffix)
236
+ "omniauth.#{name}.#{suffix}"
237
+ end
238
+
172
239
  def stored_state
173
- session.delete("omniauth.state")
240
+ session.delete(session_key("state"))
174
241
  end
175
242
 
176
243
  def new_nonce
177
- session["omniauth.nonce"] = SecureRandom.hex(16)
244
+ session[session_key("nonce")] = SecureRandom.hex(16)
245
+ end
246
+
247
+ def stored_nonce
248
+ session.delete(session_key("nonce"))
178
249
  end
179
250
 
180
251
  def script_name
@@ -189,10 +260,6 @@ module OmniAuth
189
260
  super
190
261
  end
191
262
 
192
- def redirect_uri
193
- "#{request.base_url}/auth/#{name}/callback"
194
- end
195
-
196
263
  def encoded_post_logout_redirect_uri
197
264
  return unless options.post_logout_redirect_uri
198
265
 
@@ -210,14 +277,6 @@ module OmniAuth
210
277
  @logout_path_pattern ||= /\A#{Regexp.quote(request.base_url)}#{options.logout_path}/
211
278
  end
212
279
 
213
- # Strips port and host from strings with OIDC endpoints
214
- def resolve_endpoint_from_host(host, endpoint)
215
- start_index = endpoint.index(host) + host.length
216
- endpoint = endpoint[start_index..]
217
- endpoint = "/#{endpoint}" unless endpoint.start_with?("/")
218
- endpoint
219
- end
220
-
221
280
  # Override for the CallbackError class
222
281
  class CallbackError < StandardError
223
282
  attr_accessor :error, :error_reason, :error_uri
@@ -225,8 +284,8 @@ module OmniAuth
225
284
  def initialize(data)
226
285
  super
227
286
  self.error = data[:error]
228
- self.error_reason = data[:reason]
229
- self.error_uri = data[:uri]
287
+ self.error_reason = data[:error_reason] || data[:reason]
288
+ self.error_uri = data[:error_uri] || data[:uri]
230
289
  end
231
290
 
232
291
  def message
data/lib/omniauth_oidc.rb CHANGED
@@ -2,4 +2,12 @@
2
2
 
3
3
  require_relative "omniauth/oidc/version"
4
4
  require_relative "omniauth/oidc/errors"
5
+ require_relative "omniauth/oidc/logging"
6
+ require_relative "omniauth/oidc/ttl_cache"
7
+ require_relative "omniauth/oidc/jwks_cache"
8
+ require_relative "omniauth/oidc/http_client"
9
+ require_relative "omniauth/oidc/response_objects"
10
+ require_relative "omniauth/oidc/client"
11
+ require_relative "omniauth/oidc/config_fetcher"
12
+ require_relative "omniauth/oidc/jwk_handler"
5
13
  require_relative "omniauth/strategies/oidc"
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = "https://github.com/msuliq/omniauth_oidc"
20
20
  spec.metadata["changelog_uri"] = "https://github.com/msuliq/omniauth_oidc/blob/main/CHANGELOG.md"
21
+ spec.metadata["rubygems_mfa_required"] = "true"
21
22
 
22
23
  # Specify which files should be added to the gem when it is released.
23
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -31,11 +32,13 @@ Gem::Specification.new do |spec|
31
32
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
33
  spec.require_paths = ["lib"]
33
34
 
34
- # Uncomment to register a new dependency of your gem
35
- spec.add_dependency "httparty"
36
- spec.add_dependency "omniauth"
37
- spec.add_dependency "openid_config_parser"
38
- spec.add_dependency "openid_connect"
35
+ # Runtime dependencies
36
+ # Excludes releases affected by CVE-2026-45363 (empty-key HMAC bypass): fixed in 2.10.3 and 3.2.0
37
+ spec.add_dependency "jwt", ">= 2.10.3", "!= 3.0.0", "!= 3.1.0", "!= 3.1.1", "!= 3.1.2", "< 4.0"
38
+ spec.add_dependency "omniauth", "~> 2.1"
39
+
40
+ # Ruby 4.0+ compatibility - ostruct no longer in default gems
41
+ # Users on Ruby 4.0+ should add 'gem "ostruct"' to their Gemfile
39
42
 
40
43
  # For more information and examples about making a new gem, check out our
41
44
  # guide at: https://bundler.io/guides/creating_gem.html