simple_oauth 0.5.0 → 0.5.1
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
- data/CHANGELOG.md +7 -0
- data/lib/simple_oauth/header/class_methods.rb +16 -1
- data/lib/simple_oauth/header/params.rb +5 -1
- data/lib/simple_oauth/header.rb +3 -1
- data/lib/simple_oauth/version.rb +1 -1
- data/sig/simple_oauth/header/class_methods.rbs +3 -0
- metadata +1 -2
- data/sig/uri_ext.rbs +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 680161f3f3fc8cf54f78c5111c1f0c4bcd6380b0d29022fb9ac5fd407805d8b7
|
|
4
|
+
data.tar.gz: 6951095c0b1b04b7755e8857a977946825053a141e3fd4c1c3b7e10cade061fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f852606e3aa48e70a5856f0cfccbfafe4c9235a6a701faca692446186b5bf8f30781b316577b7ac15a164b07293f9b550ad5cdfe0db58df6e57be396de380cf6
|
|
7
|
+
data.tar.gz: d938005d0ad30817b294e0e8143b272be0dafb794dfa4a57ee012fc8f162c7d895d85a5a2ae0a57f4bc3b9e50c372fde93ac22b31bc01579ead3deec968f2d2a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [0.5.1] - 2026-09-12
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
|
|
5
|
+
* Build the signature base string with a String conversion that every supported Ruby offers; `Header#url` called `URI::Generic#to_str`, which arrived in `uri` 0.13, so it raised `NoMethodError` on a stock Ruby 3.2, the oldest version the gem claims to support
|
|
6
|
+
* Sign a parameter that carries no value, such as a bare `?flag` in the query string or the `c2` of the RFC 5849 Section 3.4.1.3.1 example, as `name=` rather than dropping it from the signature base string; a request carrying one signed differently than the server computes, so it was rejected
|
|
7
|
+
|
|
1
8
|
## [0.5.0] - 2026-09-12
|
|
2
9
|
|
|
3
10
|
### Added
|
|
@@ -71,7 +71,7 @@ module SimpleOAuth
|
|
|
71
71
|
def from_request(request, oauth = {})
|
|
72
72
|
uri = request.uri || raise(ArgumentError, "The request has no URI")
|
|
73
73
|
body = request.body
|
|
74
|
-
return new(request.method, uri,
|
|
74
|
+
return new(request.method, uri, form_params(body), oauth) if form_encoded?(request)
|
|
75
75
|
|
|
76
76
|
no_params = {} #: Header::request_params
|
|
77
77
|
new(request.method, uri, no_params, oauth, body)
|
|
@@ -117,6 +117,21 @@ module SimpleOAuth
|
|
|
117
117
|
|
|
118
118
|
private
|
|
119
119
|
|
|
120
|
+
# Parses a form-encoded body into the parameter pairs to sign
|
|
121
|
+
#
|
|
122
|
+
# A parameter with no value, such as the "c2" of the RFC 5849 Section 3.4.1.3.1
|
|
123
|
+
# example, is signed with an empty value rather than dropped.
|
|
124
|
+
#
|
|
125
|
+
# @api private
|
|
126
|
+
# @param body [String, nil] the form-encoded body
|
|
127
|
+
# @return [Array<Array(String, String)>] the parameter pairs
|
|
128
|
+
def form_params(body)
|
|
129
|
+
CGI.parse(body.to_s).flat_map do |key, values|
|
|
130
|
+
# A parameter with no value still makes one pair, carrying an empty value
|
|
131
|
+
(values.empty? ? [""] : values).map { |value| [key, value] }
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
120
135
|
# Checks whether a request carries a form-encoded body
|
|
121
136
|
#
|
|
122
137
|
# @api private
|
|
@@ -33,11 +33,15 @@ module SimpleOAuth
|
|
|
33
33
|
|
|
34
34
|
# Extracts query parameters from the request URL
|
|
35
35
|
#
|
|
36
|
+
# A parameter with no value, such as the "c2" of the RFC 5849 Section 3.4.1.3.1
|
|
37
|
+
# example, is signed with an empty value rather than dropped.
|
|
38
|
+
#
|
|
36
39
|
# @api private
|
|
37
40
|
# @return [Array<Array>] URL query parameters as key-value pairs
|
|
38
41
|
def url_params
|
|
39
42
|
CGI.parse(@uri.query || "").flat_map do |key, values|
|
|
40
|
-
|
|
43
|
+
# A parameter with no value still makes one pair, carrying an empty value
|
|
44
|
+
(values.empty? ? [""] : values.sort).map { |value| [key, value] }
|
|
41
45
|
end
|
|
42
46
|
end
|
|
43
47
|
|
data/lib/simple_oauth/header.rb
CHANGED
|
@@ -102,7 +102,9 @@ module SimpleOAuth
|
|
|
102
102
|
# header.url
|
|
103
103
|
# # => "https://api.example.com/path"
|
|
104
104
|
def url
|
|
105
|
-
|
|
105
|
+
# String() takes whichever conversion the installed uri defines: it gained to_str in
|
|
106
|
+
# 0.13, and the uri that ships with Ruby 3.2 offers only to_s
|
|
107
|
+
String(@uri.dup.tap { |uri| uri.query = nil })
|
|
106
108
|
end
|
|
107
109
|
|
|
108
110
|
# Returns the OAuth Authorization header string
|
data/lib/simple_oauth/version.rb
CHANGED
|
@@ -28,6 +28,9 @@ module SimpleOAuth
|
|
|
28
28
|
|
|
29
29
|
private
|
|
30
30
|
|
|
31
|
+
# Parses a form-encoded body into the parameter pairs to sign
|
|
32
|
+
def form_params: (String? body) -> Array[[String, String]]
|
|
33
|
+
|
|
31
34
|
# Checks whether a request carries a form-encoded body
|
|
32
35
|
def form_encoded?: (Header::_Request request) -> bool
|
|
33
36
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_oauth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steve Richert
|
|
@@ -72,7 +72,6 @@ files:
|
|
|
72
72
|
- sig/simple_oauth/parser.rbs
|
|
73
73
|
- sig/simple_oauth/signature.rbs
|
|
74
74
|
- sig/strscan.rbs
|
|
75
|
-
- sig/uri_ext.rbs
|
|
76
75
|
homepage: https://github.com/laserlemon/simple_oauth
|
|
77
76
|
licenses:
|
|
78
77
|
- MIT
|