oauth2 2.0.16 → 2.0.18
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +194 -7
- data/CONTRIBUTING.md +17 -25
- data/FUNDING.md +7 -10
- data/IRP.md +107 -0
- data/OIDC.md +10 -1
- data/README.md +158 -301
- data/SECURITY.md +3 -0
- data/THREAT_MODEL.md +85 -0
- data/lib/oauth2/access_token.rb +19 -3
- data/lib/oauth2/strategy/assertion.rb +2 -2
- data/lib/oauth2/version.rb +1 -1
- data/sig/oauth2/access_token.rbs +1 -1
- data.tar.gz.sig +0 -0
- metadata +15 -59
- metadata.gz.sig +0 -0
data/SECURITY.md
CHANGED
|
@@ -12,6 +12,8 @@ To report a security vulnerability, please use the
|
|
|
12
12
|
[Tidelift security contact](https://tidelift.com/security).
|
|
13
13
|
Tidelift will coordinate the fix and disclosure.
|
|
14
14
|
|
|
15
|
+
More detailed explanation of the process is in [IRP.md][IRP]
|
|
16
|
+
|
|
15
17
|
## Additional Support
|
|
16
18
|
|
|
17
19
|
If you are interested in support for versions older than the latest release,
|
|
@@ -19,3 +21,4 @@ please consider sponsoring the project / maintainer @ https://liberapay.com/pbol
|
|
|
19
21
|
or find other sponsorship links in the [README].
|
|
20
22
|
|
|
21
23
|
[README]: README.md
|
|
24
|
+
[IRP]: IRP.md
|
data/THREAT_MODEL.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Threat Model Outline for oauth2 Ruby Gem
|
|
2
|
+
|
|
3
|
+
## 1. Overview
|
|
4
|
+
This document outlines the threat model for the `oauth2` Ruby gem, which implements OAuth 2.0, 2.1, and OIDC Core protocols. The gem is used to facilitate secure authorization and authentication in Ruby applications.
|
|
5
|
+
|
|
6
|
+
## 2. Assets to Protect
|
|
7
|
+
- OAuth access tokens, refresh tokens, and ID tokens
|
|
8
|
+
- User credentials (if handled)
|
|
9
|
+
- Client secrets and application credentials
|
|
10
|
+
- Sensitive user data accessed via OAuth
|
|
11
|
+
- Private keys and certificates (for signing/verifying tokens)
|
|
12
|
+
|
|
13
|
+
## 3. Potential Threat Actors
|
|
14
|
+
- External attackers (internet-based)
|
|
15
|
+
- Malicious OAuth clients or resource servers
|
|
16
|
+
- Insiders (developers, maintainers)
|
|
17
|
+
- Compromised dependencies
|
|
18
|
+
|
|
19
|
+
## 4. Attack Surfaces
|
|
20
|
+
- OAuth endpoints (authorization, token, revocation, introspection)
|
|
21
|
+
- HTTP request/response handling
|
|
22
|
+
- Token storage and management
|
|
23
|
+
- Configuration files and environment variables
|
|
24
|
+
- Dependency supply chain
|
|
25
|
+
|
|
26
|
+
## 5. Threats and Mitigations
|
|
27
|
+
|
|
28
|
+
### 5.1 Token Leakage
|
|
29
|
+
- **Threat:** Tokens exposed via logs, URLs, or insecure storage
|
|
30
|
+
- **Mitigations:**
|
|
31
|
+
- Avoid logging sensitive tokens
|
|
32
|
+
- Use secure storage mechanisms
|
|
33
|
+
- Never expose tokens in URLs
|
|
34
|
+
|
|
35
|
+
### 5.2 Token Replay and Forgery
|
|
36
|
+
- **Threat:** Attackers reuse or forge tokens
|
|
37
|
+
- **Mitigations:**
|
|
38
|
+
- Validate token signatures and claims
|
|
39
|
+
- Use short-lived tokens and refresh tokens
|
|
40
|
+
- Implement token revocation
|
|
41
|
+
|
|
42
|
+
### 5.3 Insecure Communication
|
|
43
|
+
- **Threat:** Data intercepted via MITM attacks
|
|
44
|
+
- **Mitigations:**
|
|
45
|
+
- Enforce HTTPS for all communications
|
|
46
|
+
- Validate SSL/TLS certificates
|
|
47
|
+
|
|
48
|
+
### 5.4 Client Secret Exposure
|
|
49
|
+
- **Threat:** Client secrets leaked in code or version control
|
|
50
|
+
- **Mitigations:**
|
|
51
|
+
- Store secrets in environment variables or secure vaults
|
|
52
|
+
- Never commit secrets to source control
|
|
53
|
+
|
|
54
|
+
### 5.5 Dependency Vulnerabilities
|
|
55
|
+
- **Threat:** Vulnerabilities in third-party libraries
|
|
56
|
+
- **Mitigations:**
|
|
57
|
+
- Regularly update dependencies
|
|
58
|
+
- Use tools like `bundler-audit` for vulnerability scanning
|
|
59
|
+
|
|
60
|
+
### 5.6 Improper Input Validation
|
|
61
|
+
- **Threat:** Injection attacks via untrusted input
|
|
62
|
+
- **Mitigations:**
|
|
63
|
+
- Validate and sanitize all inputs
|
|
64
|
+
- Use parameterized queries and safe APIs
|
|
65
|
+
|
|
66
|
+
### 5.7 Insufficient Logging and Monitoring
|
|
67
|
+
- **Threat:** Attacks go undetected
|
|
68
|
+
- **Mitigations:**
|
|
69
|
+
- Log security-relevant events (without sensitive data)
|
|
70
|
+
- Monitor for suspicious activity
|
|
71
|
+
|
|
72
|
+
## 6. Assumptions
|
|
73
|
+
- The gem is used in a secure environment with up-to-date Ruby and dependencies
|
|
74
|
+
- End-users are responsible for secure configuration and deployment
|
|
75
|
+
|
|
76
|
+
## 7. Out of Scope
|
|
77
|
+
- Security of external OAuth providers
|
|
78
|
+
- Application-level business logic
|
|
79
|
+
|
|
80
|
+
## 8. References
|
|
81
|
+
- [OAuth 2.0 Threat Model and Security Considerations (RFC 6819)](https://tools.ietf.org/html/rfc6819)
|
|
82
|
+
- [OWASP Top Ten](https://owasp.org/www-project-top-ten/)
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
This outline should be reviewed and updated regularly as the project evolves.
|
data/lib/oauth2/access_token.rb
CHANGED
|
@@ -132,10 +132,15 @@ You may need to set `snaky: false`. See inline documentation for more info.
|
|
|
132
132
|
# @option opts [FixNum, String] :expires_in (nil) the number of seconds in which the AccessToken will expire
|
|
133
133
|
# @option opts [FixNum, String] :expires_at (nil) the epoch time in seconds in which AccessToken will expire
|
|
134
134
|
# @option opts [FixNum, String] :expires_latency (nil) the number of seconds by which AccessToken validity will be reduced to offset latency, @version 2.0+
|
|
135
|
-
# @option opts [Symbol or callable] :mode (:header) the transmission mode of the Access Token parameter value:
|
|
136
|
-
# either one of :header, :body or :query
|
|
135
|
+
# @option opts [Symbol, Hash, or callable] :mode (:header) the transmission mode of the Access Token parameter value:
|
|
136
|
+
# either one of :header, :body or :query; or a Hash with verb symbols as keys mapping to one of these symbols
|
|
137
|
+
# (e.g., `{get: :query, post: :header, delete: :header}`); or a callable that accepts a request-verb parameter
|
|
137
138
|
# and returns one of these three symbols.
|
|
138
139
|
# @option opts [String] :header_format ('Bearer %s') the string format to use for the Authorization header
|
|
140
|
+
#
|
|
141
|
+
# @example Verb-dependent Hash mode
|
|
142
|
+
# # Send token in query for GET, in header for POST/DELETE, in body for PUT/PATCH
|
|
143
|
+
# OAuth2::AccessToken.new(client, token, mode: {get: :query, post: :header, delete: :header, put: :body, patch: :body})
|
|
139
144
|
# @option opts [String] :param_name ('access_token') the parameter name to use for transmission of the
|
|
140
145
|
# Access Token value in :body or :query transmission mode
|
|
141
146
|
# @option opts [String] :token_name (nil) the name of the response parameter that identifies the access token
|
|
@@ -372,7 +377,18 @@ You may need to set `snaky: false`. See inline documentation for more info.
|
|
|
372
377
|
private
|
|
373
378
|
|
|
374
379
|
def configure_authentication!(opts, verb)
|
|
375
|
-
|
|
380
|
+
mode_opt = options[:mode]
|
|
381
|
+
mode =
|
|
382
|
+
if mode_opt.respond_to?(:call)
|
|
383
|
+
mode_opt.call(verb)
|
|
384
|
+
elsif mode_opt.is_a?(Hash)
|
|
385
|
+
key = verb.to_sym
|
|
386
|
+
# Try symbol key first, then string key; default to :header when missing
|
|
387
|
+
mode_opt[key] || mode_opt[key.to_s] || :header
|
|
388
|
+
else
|
|
389
|
+
mode_opt
|
|
390
|
+
end
|
|
391
|
+
|
|
376
392
|
case mode
|
|
377
393
|
when :header
|
|
378
394
|
opts[:headers] ||= {}
|
|
@@ -66,8 +66,8 @@ module OAuth2
|
|
|
66
66
|
# @see https://datatracker.ietf.org/doc/html/rfc7518#section-3.1
|
|
67
67
|
#
|
|
68
68
|
# The object type of `:key` may depend on the value of `:algorithm`. Sample arguments:
|
|
69
|
-
# get_token(claim_set, {:algorithm => 'HS256', :key => 'secret_key'})
|
|
70
|
-
# get_token(claim_set, {:algorithm => 'RS256', :key => OpenSSL::PKCS12.new(File.read('my_key.p12'), 'not_secret')})
|
|
69
|
+
# `get_token(claim_set, {:algorithm => 'HS256', :key => 'secret_key'})`
|
|
70
|
+
# `get_token(claim_set, {:algorithm => 'RS256', :key => OpenSSL::PKCS12.new(File.read('my_key.p12'), 'not_secret')})`
|
|
71
71
|
#
|
|
72
72
|
# @param [Hash] request_opts options that will be used to assemble the request
|
|
73
73
|
# @option request_opts [String] :scope the url parameter `scope` that may be required by some endpoints
|
data/lib/oauth2/version.rb
CHANGED
data/sig/oauth2/access_token.rbs
CHANGED
|
@@ -17,7 +17,7 @@ module OAuth2
|
|
|
17
17
|
def patch: (String, ?Hash[Symbol, untyped]) { (untyped) -> void } -> OAuth2::Response
|
|
18
18
|
def delete: (String, ?Hash[Symbol, untyped]) { (untyped) -> void } -> OAuth2::Response
|
|
19
19
|
def headers: () -> Hash[String, String]
|
|
20
|
-
def configure_authentication!: (Hash[Symbol, untyped]) -> void
|
|
20
|
+
def configure_authentication!: (Hash[Symbol, untyped], Symbol) -> void
|
|
21
21
|
def convert_expires_at: (untyped) -> (Time | Integer | nil)
|
|
22
22
|
|
|
23
23
|
attr_accessor response: OAuth2::Response
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oauth2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.18
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Boling
|
|
@@ -156,7 +156,7 @@ dependencies:
|
|
|
156
156
|
version: '1.1'
|
|
157
157
|
- - ">="
|
|
158
158
|
- !ruby/object:Gem::Version
|
|
159
|
-
version: 1.1.
|
|
159
|
+
version: 1.1.9
|
|
160
160
|
type: :runtime
|
|
161
161
|
prerelease: false
|
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -166,7 +166,7 @@ dependencies:
|
|
|
166
166
|
version: '1.1'
|
|
167
167
|
- - ">="
|
|
168
168
|
- !ruby/object:Gem::Version
|
|
169
|
-
version: 1.1.
|
|
169
|
+
version: 1.1.9
|
|
170
170
|
- !ruby/object:Gem::Dependency
|
|
171
171
|
name: addressable
|
|
172
172
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -228,9 +228,6 @@ dependencies:
|
|
|
228
228
|
- - "~>"
|
|
229
229
|
- !ruby/object:Gem::Version
|
|
230
230
|
version: '1.1'
|
|
231
|
-
- - ">="
|
|
232
|
-
- !ruby/object:Gem::Version
|
|
233
|
-
version: 1.1.9
|
|
234
231
|
type: :development
|
|
235
232
|
prerelease: false
|
|
236
233
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -238,9 +235,6 @@ dependencies:
|
|
|
238
235
|
- - "~>"
|
|
239
236
|
- !ruby/object:Gem::Version
|
|
240
237
|
version: '1.1'
|
|
241
|
-
- - ">="
|
|
242
|
-
- !ruby/object:Gem::Version
|
|
243
|
-
version: 1.1.9
|
|
244
238
|
- !ruby/object:Gem::Dependency
|
|
245
239
|
name: bundler-audit
|
|
246
240
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -310,33 +304,19 @@ dependencies:
|
|
|
310
304
|
- - "~>"
|
|
311
305
|
- !ruby/object:Gem::Version
|
|
312
306
|
version: '1.0'
|
|
313
|
-
type: :development
|
|
314
|
-
prerelease: false
|
|
315
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
316
|
-
requirements:
|
|
317
|
-
- - "~>"
|
|
318
|
-
- !ruby/object:Gem::Version
|
|
319
|
-
version: '1.0'
|
|
320
|
-
- !ruby/object:Gem::Dependency
|
|
321
|
-
name: rspec-pending_for
|
|
322
|
-
requirement: !ruby/object:Gem::Requirement
|
|
323
|
-
requirements:
|
|
324
|
-
- - "~>"
|
|
325
|
-
- !ruby/object:Gem::Version
|
|
326
|
-
version: '0.0'
|
|
327
307
|
- - ">="
|
|
328
308
|
- !ruby/object:Gem::Version
|
|
329
|
-
version:
|
|
309
|
+
version: 1.0.6
|
|
330
310
|
type: :development
|
|
331
311
|
prerelease: false
|
|
332
312
|
version_requirements: !ruby/object:Gem::Requirement
|
|
333
313
|
requirements:
|
|
334
314
|
- - "~>"
|
|
335
315
|
- !ruby/object:Gem::Version
|
|
336
|
-
version: '
|
|
316
|
+
version: '1.0'
|
|
337
317
|
- - ">="
|
|
338
318
|
- !ruby/object:Gem::Version
|
|
339
|
-
version:
|
|
319
|
+
version: 1.0.6
|
|
340
320
|
- !ruby/object:Gem::Dependency
|
|
341
321
|
name: ruby-progressbar
|
|
342
322
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -411,34 +391,6 @@ dependencies:
|
|
|
411
391
|
- - ">="
|
|
412
392
|
- !ruby/object:Gem::Version
|
|
413
393
|
version: 3.25.1
|
|
414
|
-
- !ruby/object:Gem::Dependency
|
|
415
|
-
name: vcr
|
|
416
|
-
requirement: !ruby/object:Gem::Requirement
|
|
417
|
-
requirements:
|
|
418
|
-
- - ">="
|
|
419
|
-
- !ruby/object:Gem::Version
|
|
420
|
-
version: '4'
|
|
421
|
-
type: :development
|
|
422
|
-
prerelease: false
|
|
423
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
424
|
-
requirements:
|
|
425
|
-
- - ">="
|
|
426
|
-
- !ruby/object:Gem::Version
|
|
427
|
-
version: '4'
|
|
428
|
-
- !ruby/object:Gem::Dependency
|
|
429
|
-
name: webmock
|
|
430
|
-
requirement: !ruby/object:Gem::Requirement
|
|
431
|
-
requirements:
|
|
432
|
-
- - ">="
|
|
433
|
-
- !ruby/object:Gem::Version
|
|
434
|
-
version: '3'
|
|
435
|
-
type: :development
|
|
436
|
-
prerelease: false
|
|
437
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
438
|
-
requirements:
|
|
439
|
-
- - ">="
|
|
440
|
-
- !ruby/object:Gem::Version
|
|
441
|
-
version: '3'
|
|
442
394
|
description: "\U0001F510 A Ruby wrapper for the OAuth 2.0 Authorization Framework,
|
|
443
395
|
including the OAuth 2.1 draft spec, and OpenID Connect (OIDC)"
|
|
444
396
|
email:
|
|
@@ -452,24 +404,28 @@ extra_rdoc_files:
|
|
|
452
404
|
- CODE_OF_CONDUCT.md
|
|
453
405
|
- CONTRIBUTING.md
|
|
454
406
|
- FUNDING.md
|
|
407
|
+
- IRP.md
|
|
455
408
|
- LICENSE.txt
|
|
456
409
|
- OIDC.md
|
|
457
410
|
- README.md
|
|
458
411
|
- REEK
|
|
459
412
|
- RUBOCOP.md
|
|
460
413
|
- SECURITY.md
|
|
414
|
+
- THREAT_MODEL.md
|
|
461
415
|
files:
|
|
462
416
|
- CHANGELOG.md
|
|
463
417
|
- CITATION.cff
|
|
464
418
|
- CODE_OF_CONDUCT.md
|
|
465
419
|
- CONTRIBUTING.md
|
|
466
420
|
- FUNDING.md
|
|
421
|
+
- IRP.md
|
|
467
422
|
- LICENSE.txt
|
|
468
423
|
- OIDC.md
|
|
469
424
|
- README.md
|
|
470
425
|
- REEK
|
|
471
426
|
- RUBOCOP.md
|
|
472
427
|
- SECURITY.md
|
|
428
|
+
- THREAT_MODEL.md
|
|
473
429
|
- lib/oauth2.rb
|
|
474
430
|
- lib/oauth2/access_token.rb
|
|
475
431
|
- lib/oauth2/authenticator.rb
|
|
@@ -498,10 +454,10 @@ licenses:
|
|
|
498
454
|
- MIT
|
|
499
455
|
metadata:
|
|
500
456
|
homepage_uri: https://oauth2.galtzo.com/
|
|
501
|
-
source_code_uri: https://github.com/ruby-oauth/oauth2/tree/v2.0.
|
|
502
|
-
changelog_uri: https://github.com/ruby-oauth/oauth2/blob/v2.0.
|
|
457
|
+
source_code_uri: https://github.com/ruby-oauth/oauth2/tree/v2.0.18
|
|
458
|
+
changelog_uri: https://github.com/ruby-oauth/oauth2/blob/v2.0.18/CHANGELOG.md
|
|
503
459
|
bug_tracker_uri: https://github.com/ruby-oauth/oauth2/issues
|
|
504
|
-
documentation_uri: https://www.rubydoc.info/gems/oauth2/2.0.
|
|
460
|
+
documentation_uri: https://www.rubydoc.info/gems/oauth2/2.0.18
|
|
505
461
|
mailing_list_uri: https://groups.google.com/g/oauth-ruby
|
|
506
462
|
funding_uri: https://github.com/sponsors/pboling
|
|
507
463
|
wiki_uri: https://gitlab.com/ruby-oauth/oauth2/-/wiki
|
|
@@ -510,11 +466,11 @@ metadata:
|
|
|
510
466
|
rubygems_mfa_required: 'true'
|
|
511
467
|
post_install_message: |2
|
|
512
468
|
|
|
513
|
-
---+++--- oauth2 v2.0.
|
|
469
|
+
---+++--- oauth2 v2.0.18 ---+++---
|
|
514
470
|
|
|
515
471
|
(minor) ⚠️ BREAKING CHANGES ⚠️ when upgrading from < v2
|
|
516
472
|
• Summary of breaking changes: https://gitlab.com/ruby-oauth/oauth2#what-is-new-for-v20
|
|
517
|
-
• Changes in this patch: https://gitlab.com/ruby-oauth/oauth2/-/blob/v2.0.
|
|
473
|
+
• Changes in this patch: https://gitlab.com/ruby-oauth/oauth2/-/blob/v2.0.18/CHANGELOG.md#2015-2025-09-08
|
|
518
474
|
|
|
519
475
|
News:
|
|
520
476
|
1. New documentation website, including for OAuth 2.1 and OIDC: https://oauth2.galtzo.com
|
metadata.gz.sig
CHANGED
|
Binary file
|