oauth2 1.4.10 → 2.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +220 -88
- data/CONTRIBUTING.md +27 -1
- data/LICENSE +1 -1
- data/README.md +228 -113
- data/SECURITY.md +12 -6
- data/lib/oauth2/access_token.rb +62 -23
- data/lib/oauth2/authenticator.rb +9 -4
- data/lib/oauth2/client.rb +149 -87
- data/lib/oauth2/error.rb +41 -24
- data/lib/oauth2/response.rb +77 -22
- data/lib/oauth2/strategy/assertion.rb +63 -38
- data/lib/oauth2/strategy/auth_code.rb +13 -2
- data/lib/oauth2/strategy/client_credentials.rb +1 -1
- data/lib/oauth2/strategy/implicit.rb +7 -0
- data/lib/oauth2/version.rb +1 -59
- data/lib/oauth2.rb +27 -1
- metadata +87 -61
- data/lib/oauth2/mac_token.rb +0 -130
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
8
8
|
- Erik Michaels-Ober
|
9
9
|
- Michael Bleigh
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-09-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: multi_json
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.3'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.3'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: multi_xml
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,7 +75,7 @@ dependencies:
|
|
89
75
|
version: '1.2'
|
90
76
|
- - "<"
|
91
77
|
- !ruby/object:Gem::Version
|
92
|
-
version: '
|
78
|
+
version: '4'
|
93
79
|
type: :runtime
|
94
80
|
prerelease: false
|
95
81
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -99,77 +85,119 @@ dependencies:
|
|
99
85
|
version: '1.2'
|
100
86
|
- - "<"
|
101
87
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
88
|
+
version: '4'
|
103
89
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
90
|
+
name: snaky_hash
|
105
91
|
requirement: !ruby/object:Gem::Requirement
|
106
92
|
requirements:
|
107
93
|
- - "~>"
|
108
94
|
- !ruby/object:Gem::Version
|
109
|
-
version: '2.
|
110
|
-
type: :
|
95
|
+
version: '2.0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: version_gem
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.1'
|
110
|
+
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
116
|
+
version: '1.1'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: addressable
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '2'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '2'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: backports
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '3'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '3'
|
117
145
|
- !ruby/object:Gem::Dependency
|
118
146
|
name: bundler
|
119
147
|
requirement: !ruby/object:Gem::Requirement
|
120
148
|
requirements:
|
121
149
|
- - ">="
|
122
150
|
- !ruby/object:Gem::Version
|
123
|
-
version: '
|
151
|
+
version: '2'
|
124
152
|
type: :development
|
125
153
|
prerelease: false
|
126
154
|
version_requirements: !ruby/object:Gem::Requirement
|
127
155
|
requirements:
|
128
156
|
- - ">="
|
129
157
|
- !ruby/object:Gem::Version
|
130
|
-
version: '
|
158
|
+
version: '2'
|
131
159
|
- !ruby/object:Gem::Dependency
|
132
160
|
name: rake
|
133
161
|
requirement: !ruby/object:Gem::Requirement
|
134
162
|
requirements:
|
135
163
|
- - ">="
|
136
164
|
- !ruby/object:Gem::Version
|
137
|
-
version: '12
|
165
|
+
version: '12'
|
138
166
|
type: :development
|
139
167
|
prerelease: false
|
140
168
|
version_requirements: !ruby/object:Gem::Requirement
|
141
169
|
requirements:
|
142
170
|
- - ">="
|
143
171
|
- !ruby/object:Gem::Version
|
144
|
-
version: '12
|
172
|
+
version: '12'
|
145
173
|
- !ruby/object:Gem::Dependency
|
146
174
|
name: rexml
|
147
175
|
requirement: !ruby/object:Gem::Requirement
|
148
176
|
requirements:
|
149
|
-
- - "
|
177
|
+
- - ">="
|
150
178
|
- !ruby/object:Gem::Version
|
151
|
-
version: '3
|
179
|
+
version: '3'
|
152
180
|
type: :development
|
153
181
|
prerelease: false
|
154
182
|
version_requirements: !ruby/object:Gem::Requirement
|
155
183
|
requirements:
|
156
|
-
- - "
|
184
|
+
- - ">="
|
157
185
|
- !ruby/object:Gem::Version
|
158
|
-
version: '3
|
186
|
+
version: '3'
|
159
187
|
- !ruby/object:Gem::Dependency
|
160
188
|
name: rspec
|
161
189
|
requirement: !ruby/object:Gem::Requirement
|
162
190
|
requirements:
|
163
|
-
- - "
|
191
|
+
- - ">="
|
164
192
|
- !ruby/object:Gem::Version
|
165
|
-
version: '3
|
193
|
+
version: '3'
|
166
194
|
type: :development
|
167
195
|
prerelease: false
|
168
196
|
version_requirements: !ruby/object:Gem::Requirement
|
169
197
|
requirements:
|
170
|
-
- - "
|
198
|
+
- - ">="
|
171
199
|
- !ruby/object:Gem::Version
|
172
|
-
version: '3
|
200
|
+
version: '3'
|
173
201
|
- !ruby/object:Gem::Dependency
|
174
202
|
name: rspec-block_is_expected
|
175
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -216,22 +244,16 @@ dependencies:
|
|
216
244
|
name: rubocop-lts
|
217
245
|
requirement: !ruby/object:Gem::Requirement
|
218
246
|
requirements:
|
219
|
-
- - ">="
|
220
|
-
- !ruby/object:Gem::Version
|
221
|
-
version: 2.0.3
|
222
247
|
- - "~>"
|
223
248
|
- !ruby/object:Gem::Version
|
224
|
-
version: '
|
249
|
+
version: '8.0'
|
225
250
|
type: :development
|
226
251
|
prerelease: false
|
227
252
|
version_requirements: !ruby/object:Gem::Requirement
|
228
253
|
requirements:
|
229
|
-
- - ">="
|
230
|
-
- !ruby/object:Gem::Version
|
231
|
-
version: 2.0.3
|
232
254
|
- - "~>"
|
233
255
|
- !ruby/object:Gem::Version
|
234
|
-
version: '
|
256
|
+
version: '8.0'
|
235
257
|
- !ruby/object:Gem::Dependency
|
236
258
|
name: silent_stream
|
237
259
|
requirement: !ruby/object:Gem::Requirement
|
@@ -265,7 +287,6 @@ files:
|
|
265
287
|
- lib/oauth2/authenticator.rb
|
266
288
|
- lib/oauth2/client.rb
|
267
289
|
- lib/oauth2/error.rb
|
268
|
-
- lib/oauth2/mac_token.rb
|
269
290
|
- lib/oauth2/response.rb
|
270
291
|
- lib/oauth2/strategy/assertion.rb
|
271
292
|
- lib/oauth2/strategy/auth_code.rb
|
@@ -274,30 +295,34 @@ files:
|
|
274
295
|
- lib/oauth2/strategy/implicit.rb
|
275
296
|
- lib/oauth2/strategy/password.rb
|
276
297
|
- lib/oauth2/version.rb
|
277
|
-
homepage: https://
|
298
|
+
homepage: https://gitlab.com/oauth-xx/oauth2
|
278
299
|
licenses:
|
279
300
|
- MIT
|
280
301
|
metadata:
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
302
|
+
homepage_uri: https://gitlab.com/oauth-xx/oauth2
|
303
|
+
source_code_uri: https://gitlab.com/oauth-xx/oauth2/-/tree/v2.0.9
|
304
|
+
changelog_uri: https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.9/CHANGELOG.md
|
305
|
+
bug_tracker_uri: https://gitlab.com/oauth-xx/oauth2/-/issues
|
306
|
+
documentation_uri: https://www.rubydoc.info/gems/oauth2/2.0.9
|
307
|
+
wiki_uri: https://gitlab.com/oauth-xx/oauth2/-/wiki
|
308
|
+
funding_uri: https://liberapay.com/pboling
|
287
309
|
rubygems_mfa_required: 'true'
|
288
310
|
post_install_message: |2+
|
289
311
|
|
290
|
-
You have installed oauth2 version
|
291
|
-
|
312
|
+
You have installed oauth2 version 2.0.9, congratulations!
|
313
|
+
|
314
|
+
There are BREAKING changes if you are upgrading from < v2, but most will not encounter them, and updating your code should be easy!
|
292
315
|
|
293
|
-
|
294
|
-
|
316
|
+
We have made two other major migrations:
|
317
|
+
1. master branch renamed to main
|
318
|
+
2. Github has been replaced with Gitlab
|
295
319
|
|
296
320
|
Please see:
|
297
|
-
• https://
|
298
|
-
• https://
|
321
|
+
• https://gitlab.com/oauth-xx/oauth2#what-is-new-for-v20
|
322
|
+
• https://gitlab.com/oauth-xx/oauth2/-/blob/main/CHANGELOG.md
|
323
|
+
• https://groups.google.com/g/oauth-ruby/c/QA_dtrXWXaE
|
299
324
|
|
300
|
-
Please
|
325
|
+
Please report issues, and support the project! Thanks, |7eter l-|. l3oling
|
301
326
|
|
302
327
|
rdoc_options: []
|
303
328
|
require_paths:
|
@@ -306,15 +331,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
306
331
|
requirements:
|
307
332
|
- - ">="
|
308
333
|
- !ruby/object:Gem::Version
|
309
|
-
version:
|
334
|
+
version: 2.2.0
|
310
335
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
311
336
|
requirements:
|
312
337
|
- - ">="
|
313
338
|
- !ruby/object:Gem::Version
|
314
339
|
version: '0'
|
315
340
|
requirements: []
|
316
|
-
rubygems_version: 3.3.
|
317
|
-
signing_key:
|
341
|
+
rubygems_version: 3.3.21
|
342
|
+
signing_key:
|
318
343
|
specification_version: 4
|
319
344
|
summary: A Ruby wrapper for the OAuth 2.0 protocol.
|
320
345
|
test_files: []
|
346
|
+
...
|
data/lib/oauth2/mac_token.rb
DELETED
@@ -1,130 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'base64'
|
4
|
-
require 'digest'
|
5
|
-
require 'openssl'
|
6
|
-
require 'securerandom'
|
7
|
-
|
8
|
-
module OAuth2
|
9
|
-
class MACToken < AccessToken
|
10
|
-
# Generates a MACToken from an AccessToken and secret
|
11
|
-
#
|
12
|
-
# @param [AccessToken] token the OAuth2::Token instance
|
13
|
-
# @option [String] secret the secret key value
|
14
|
-
# @param [Hash] opts the options to create the Access Token with
|
15
|
-
# @see MACToken#initialize
|
16
|
-
def self.from_access_token(token, secret, options = {})
|
17
|
-
new(token.client, token.token, secret, token.params.merge(:refresh_token => token.refresh_token, :expires_in => token.expires_in, :expires_at => token.expires_at).merge(options))
|
18
|
-
end
|
19
|
-
|
20
|
-
attr_reader :secret, :algorithm
|
21
|
-
|
22
|
-
# Initalize a MACToken
|
23
|
-
#
|
24
|
-
# @param [Client] client the OAuth2::Client instance
|
25
|
-
# @param [String] token the Access Token value
|
26
|
-
# @option [String] secret the secret key value
|
27
|
-
# @param [Hash] opts the options to create the Access Token with
|
28
|
-
# @option opts [String] :refresh_token (nil) the refresh_token value
|
29
|
-
# @option opts [FixNum, String] :expires_in (nil) the number of seconds in which the AccessToken will expire
|
30
|
-
# @option opts [FixNum, String] :expires_at (nil) the epoch time in seconds in which AccessToken will expire
|
31
|
-
# @option opts [FixNum, String] :algorithm (hmac-sha-256) the algorithm to use for the HMAC digest (one of 'hmac-sha-256', 'hmac-sha-1')
|
32
|
-
def initialize(client, token, secret, opts = {})
|
33
|
-
@secret = secret
|
34
|
-
self.algorithm = opts.delete(:algorithm) || 'hmac-sha-256'
|
35
|
-
|
36
|
-
super(client, token, opts)
|
37
|
-
end
|
38
|
-
|
39
|
-
# Make a request with the MAC Token
|
40
|
-
#
|
41
|
-
# @param [Symbol] verb the HTTP request method
|
42
|
-
# @param [String] path the HTTP URL path of the request
|
43
|
-
# @param [Hash] opts the options to make the request with
|
44
|
-
# @see Client#request
|
45
|
-
def request(verb, path, opts = {}, &block)
|
46
|
-
url = client.connection.build_url(path, opts[:params]).to_s
|
47
|
-
|
48
|
-
opts[:headers] ||= {}
|
49
|
-
opts[:headers]['Authorization'] = header(verb, url)
|
50
|
-
|
51
|
-
@client.request(verb, path, opts, &block)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Get the headers hash (always an empty hash)
|
55
|
-
def headers
|
56
|
-
{}
|
57
|
-
end
|
58
|
-
|
59
|
-
# Generate the MAC header
|
60
|
-
#
|
61
|
-
# @param [Symbol] verb the HTTP request method
|
62
|
-
# @param [String] url the HTTP URL path of the request
|
63
|
-
def header(verb, url)
|
64
|
-
timestamp = Time.now.utc.to_i
|
65
|
-
nonce = Digest::SHA256.hexdigest([timestamp, SecureRandom.hex].join(':'))
|
66
|
-
|
67
|
-
uri = URI.parse(url)
|
68
|
-
|
69
|
-
raise(ArgumentError, "could not parse \"#{url}\" into URI") unless uri.is_a?(URI::HTTP)
|
70
|
-
|
71
|
-
mac = signature(timestamp, nonce, verb, uri)
|
72
|
-
|
73
|
-
"MAC id=\"#{token}\", ts=\"#{timestamp}\", nonce=\"#{nonce}\", mac=\"#{mac}\""
|
74
|
-
end
|
75
|
-
|
76
|
-
# Generate the Base64-encoded HMAC digest signature
|
77
|
-
#
|
78
|
-
# @param [Fixnum] timestamp the timestamp of the request in seconds since epoch
|
79
|
-
# @param [String] nonce the MAC header nonce
|
80
|
-
# @param [Symbol] verb the HTTP request method
|
81
|
-
# @param [String] url the HTTP URL path of the request
|
82
|
-
def signature(timestamp, nonce, verb, uri)
|
83
|
-
signature = [
|
84
|
-
timestamp,
|
85
|
-
nonce,
|
86
|
-
verb.to_s.upcase,
|
87
|
-
uri.request_uri,
|
88
|
-
uri.host,
|
89
|
-
uri.port,
|
90
|
-
'', nil
|
91
|
-
].join("\n")
|
92
|
-
|
93
|
-
strict_encode64(OpenSSL::HMAC.digest(@algorithm, secret, signature))
|
94
|
-
end
|
95
|
-
|
96
|
-
# Set the HMAC algorithm
|
97
|
-
#
|
98
|
-
# @param [String] alg the algorithm to use (one of 'hmac-sha-1', 'hmac-sha-256')
|
99
|
-
def algorithm=(alg)
|
100
|
-
@algorithm = case alg.to_s
|
101
|
-
when 'hmac-sha-1'
|
102
|
-
begin
|
103
|
-
OpenSSL::Digest('SHA1').new
|
104
|
-
rescue StandardError
|
105
|
-
OpenSSL::Digest.new('SHA1')
|
106
|
-
end
|
107
|
-
when 'hmac-sha-256'
|
108
|
-
begin
|
109
|
-
OpenSSL::Digest('SHA256').new
|
110
|
-
rescue StandardError
|
111
|
-
OpenSSL::Digest.new('SHA256')
|
112
|
-
end
|
113
|
-
else
|
114
|
-
raise(ArgumentError, 'Unsupported algorithm')
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
private
|
119
|
-
|
120
|
-
# No-op since we need the verb and path
|
121
|
-
# and the MAC always goes in a header
|
122
|
-
def token=(_noop)
|
123
|
-
end
|
124
|
-
|
125
|
-
# Base64.strict_encode64 is not available on Ruby 1.8.7
|
126
|
-
def strict_encode64(str)
|
127
|
-
Base64.encode64(str).delete("\n")
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|