oauth2 1.4.9 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +89 -23
- data/CONTRIBUTING.md +18 -0
- data/README.md +165 -80
- data/SECURITY.md +20 -0
- data/lib/oauth2/access_token.rb +28 -19
- data/lib/oauth2/authenticator.rb +9 -4
- data/lib/oauth2/client.rb +97 -71
- data/lib/oauth2/error.rb +27 -18
- data/lib/oauth2/response.rb +61 -19
- data/lib/oauth2/snaky_hash.rb +8 -0
- data/lib/oauth2/strategy/assertion.rb +63 -38
- data/lib/oauth2/strategy/auth_code.rb +12 -1
- data/lib/oauth2/strategy/implicit.rb +7 -0
- data/lib/oauth2/version.rb +1 -59
- data/lib/oauth2.rb +19 -1
- metadata +96 -77
- data/lib/oauth2/mac_token.rb +0 -130
- data/spec/fixtures/README.md +0 -11
- data/spec/fixtures/RS256/jwtRS256.key +0 -51
- data/spec/fixtures/RS256/jwtRS256.key.pub +0 -14
- data/spec/helper.rb +0 -33
- data/spec/oauth2/access_token_spec.rb +0 -218
- data/spec/oauth2/authenticator_spec.rb +0 -86
- data/spec/oauth2/client_spec.rb +0 -556
- data/spec/oauth2/mac_token_spec.rb +0 -122
- data/spec/oauth2/response_spec.rb +0 -96
- data/spec/oauth2/strategy/assertion_spec.rb +0 -113
- data/spec/oauth2/strategy/auth_code_spec.rb +0 -108
- data/spec/oauth2/strategy/base_spec.rb +0 -7
- data/spec/oauth2/strategy/client_credentials_spec.rb +0 -71
- data/spec/oauth2/strategy/implicit_spec.rb +0 -28
- data/spec/oauth2/strategy/password_spec.rb +0 -58
- data/spec/oauth2/version_spec.rb +0 -23
data/lib/oauth2/version.rb
CHANGED
@@ -2,64 +2,6 @@
|
|
2
2
|
|
3
3
|
module OAuth2
|
4
4
|
module Version
|
5
|
-
VERSION =
|
6
|
-
|
7
|
-
module_function
|
8
|
-
|
9
|
-
# The major version
|
10
|
-
#
|
11
|
-
# @return [Integer]
|
12
|
-
def major
|
13
|
-
1
|
14
|
-
end
|
15
|
-
|
16
|
-
# The minor version
|
17
|
-
#
|
18
|
-
# @return [Integer]
|
19
|
-
def minor
|
20
|
-
4
|
21
|
-
end
|
22
|
-
|
23
|
-
# The patch version
|
24
|
-
#
|
25
|
-
# @return [Integer]
|
26
|
-
def patch
|
27
|
-
9
|
28
|
-
end
|
29
|
-
|
30
|
-
# The pre-release version, if any
|
31
|
-
#
|
32
|
-
# @return [String, NilClass]
|
33
|
-
def pre
|
34
|
-
nil
|
35
|
-
end
|
36
|
-
|
37
|
-
# The version number as a hash
|
38
|
-
#
|
39
|
-
# @return [Hash]
|
40
|
-
def to_h
|
41
|
-
{
|
42
|
-
:major => major,
|
43
|
-
:minor => minor,
|
44
|
-
:patch => patch,
|
45
|
-
:pre => pre,
|
46
|
-
}
|
47
|
-
end
|
48
|
-
|
49
|
-
# The version number as an array
|
50
|
-
#
|
51
|
-
# @return [Array]
|
52
|
-
def to_a
|
53
|
-
[major, minor, patch, pre].compact
|
54
|
-
end
|
55
|
-
|
56
|
-
# The version number as a string
|
57
|
-
#
|
58
|
-
# @return [String]
|
59
|
-
def to_s
|
60
|
-
v = [major, minor, patch].compact.join('.')
|
61
|
-
v += "-#{pre}" if pre
|
62
|
-
v
|
63
|
-
end
|
5
|
+
VERSION = '2.0.2'.freeze
|
64
6
|
end
|
65
7
|
end
|
data/lib/oauth2.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# includes modules from stdlib
|
4
|
+
require 'cgi'
|
5
|
+
require 'time'
|
6
|
+
|
7
|
+
# third party gems
|
8
|
+
require 'rash'
|
9
|
+
require 'version_gem'
|
10
|
+
|
11
|
+
# includes gem files
|
12
|
+
require 'oauth2/version'
|
3
13
|
require 'oauth2/error'
|
14
|
+
require 'oauth2/snaky_hash'
|
4
15
|
require 'oauth2/authenticator'
|
5
16
|
require 'oauth2/client'
|
6
17
|
require 'oauth2/strategy/base'
|
@@ -10,5 +21,12 @@ require 'oauth2/strategy/password'
|
|
10
21
|
require 'oauth2/strategy/client_credentials'
|
11
22
|
require 'oauth2/strategy/assertion'
|
12
23
|
require 'oauth2/access_token'
|
13
|
-
require 'oauth2/mac_token'
|
14
24
|
require 'oauth2/response'
|
25
|
+
|
26
|
+
# The namespace of this library
|
27
|
+
module OAuth2
|
28
|
+
end
|
29
|
+
|
30
|
+
OAuth2::Version.class_eval do
|
31
|
+
extend VersionGem::Basic
|
32
|
+
end
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
8
|
-
- Michael Bleigh
|
9
8
|
- Erik Michaels-Ober
|
10
|
-
|
9
|
+
- Michael Bleigh
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-06-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
@@ -53,123 +53,157 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: multi_xml
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0.5'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0.5'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rack
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.2'
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '3'
|
76
79
|
type: :runtime
|
77
80
|
prerelease: false
|
78
81
|
version_requirements: !ruby/object:Gem::Requirement
|
79
82
|
requirements:
|
80
|
-
- - "
|
83
|
+
- - ">="
|
81
84
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
85
|
+
version: '1.2'
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '3'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
90
|
+
name: rash_alt
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
93
|
- - ">="
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
95
|
+
version: '0.4'
|
90
96
|
- - "<"
|
91
97
|
- !ruby/object:Gem::Version
|
92
|
-
version: '
|
98
|
+
version: '1'
|
93
99
|
type: :runtime
|
94
100
|
prerelease: false
|
95
101
|
version_requirements: !ruby/object:Gem::Requirement
|
96
102
|
requirements:
|
97
103
|
- - ">="
|
98
104
|
- !ruby/object:Gem::Version
|
99
|
-
version: '
|
105
|
+
version: '0.4'
|
100
106
|
- - "<"
|
101
107
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
108
|
+
version: '1'
|
103
109
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
110
|
+
name: version_gem
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|
106
112
|
requirements:
|
107
113
|
- - "~>"
|
108
114
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
110
|
-
type: :
|
115
|
+
version: '1.0'
|
116
|
+
type: :runtime
|
111
117
|
prerelease: false
|
112
118
|
version_requirements: !ruby/object:Gem::Requirement
|
113
119
|
requirements:
|
114
120
|
- - "~>"
|
115
121
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
122
|
+
version: '1.0'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: addressable
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '2'
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '2'
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: backports
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '3'
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '3'
|
117
151
|
- !ruby/object:Gem::Dependency
|
118
152
|
name: bundler
|
119
153
|
requirement: !ruby/object:Gem::Requirement
|
120
154
|
requirements:
|
121
155
|
- - ">="
|
122
156
|
- !ruby/object:Gem::Version
|
123
|
-
version: '
|
157
|
+
version: '2'
|
124
158
|
type: :development
|
125
159
|
prerelease: false
|
126
160
|
version_requirements: !ruby/object:Gem::Requirement
|
127
161
|
requirements:
|
128
162
|
- - ">="
|
129
163
|
- !ruby/object:Gem::Version
|
130
|
-
version: '
|
164
|
+
version: '2'
|
131
165
|
- !ruby/object:Gem::Dependency
|
132
166
|
name: rake
|
133
167
|
requirement: !ruby/object:Gem::Requirement
|
134
168
|
requirements:
|
135
|
-
- - "
|
169
|
+
- - ">="
|
136
170
|
- !ruby/object:Gem::Version
|
137
|
-
version: '12
|
171
|
+
version: '12'
|
138
172
|
type: :development
|
139
173
|
prerelease: false
|
140
174
|
version_requirements: !ruby/object:Gem::Requirement
|
141
175
|
requirements:
|
142
|
-
- - "
|
176
|
+
- - ">="
|
143
177
|
- !ruby/object:Gem::Version
|
144
|
-
version: '12
|
178
|
+
version: '12'
|
145
179
|
- !ruby/object:Gem::Dependency
|
146
180
|
name: rexml
|
147
181
|
requirement: !ruby/object:Gem::Requirement
|
148
182
|
requirements:
|
149
|
-
- - "
|
183
|
+
- - ">="
|
150
184
|
- !ruby/object:Gem::Version
|
151
|
-
version: '3
|
185
|
+
version: '3'
|
152
186
|
type: :development
|
153
187
|
prerelease: false
|
154
188
|
version_requirements: !ruby/object:Gem::Requirement
|
155
189
|
requirements:
|
156
|
-
- - "
|
190
|
+
- - ">="
|
157
191
|
- !ruby/object:Gem::Version
|
158
|
-
version: '3
|
192
|
+
version: '3'
|
159
193
|
- !ruby/object:Gem::Dependency
|
160
194
|
name: rspec
|
161
195
|
requirement: !ruby/object:Gem::Requirement
|
162
196
|
requirements:
|
163
|
-
- - "
|
197
|
+
- - ">="
|
164
198
|
- !ruby/object:Gem::Version
|
165
|
-
version: '3
|
199
|
+
version: '3'
|
166
200
|
type: :development
|
167
201
|
prerelease: false
|
168
202
|
version_requirements: !ruby/object:Gem::Requirement
|
169
203
|
requirements:
|
170
|
-
- - "
|
204
|
+
- - ">="
|
171
205
|
- !ruby/object:Gem::Version
|
172
|
-
version: '3
|
206
|
+
version: '3'
|
173
207
|
- !ruby/object:Gem::Dependency
|
174
208
|
name: rspec-block_is_expected
|
175
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,6 +246,20 @@ dependencies:
|
|
212
246
|
- - ">="
|
213
247
|
- !ruby/object:Gem::Version
|
214
248
|
version: '0'
|
249
|
+
- !ruby/object:Gem::Dependency
|
250
|
+
name: rubocop-lts
|
251
|
+
requirement: !ruby/object:Gem::Requirement
|
252
|
+
requirements:
|
253
|
+
- - "~>"
|
254
|
+
- !ruby/object:Gem::Version
|
255
|
+
version: '8.0'
|
256
|
+
type: :development
|
257
|
+
prerelease: false
|
258
|
+
version_requirements: !ruby/object:Gem::Requirement
|
259
|
+
requirements:
|
260
|
+
- - "~>"
|
261
|
+
- !ruby/object:Gem::Version
|
262
|
+
version: '8.0'
|
215
263
|
- !ruby/object:Gem::Dependency
|
216
264
|
name: silent_stream
|
217
265
|
requirement: !ruby/object:Gem::Requirement
|
@@ -236,15 +284,17 @@ extra_rdoc_files: []
|
|
236
284
|
files:
|
237
285
|
- CHANGELOG.md
|
238
286
|
- CODE_OF_CONDUCT.md
|
287
|
+
- CONTRIBUTING.md
|
239
288
|
- LICENSE
|
240
289
|
- README.md
|
290
|
+
- SECURITY.md
|
241
291
|
- lib/oauth2.rb
|
242
292
|
- lib/oauth2/access_token.rb
|
243
293
|
- lib/oauth2/authenticator.rb
|
244
294
|
- lib/oauth2/client.rb
|
245
295
|
- lib/oauth2/error.rb
|
246
|
-
- lib/oauth2/mac_token.rb
|
247
296
|
- lib/oauth2/response.rb
|
297
|
+
- lib/oauth2/snaky_hash.rb
|
248
298
|
- lib/oauth2/strategy/assertion.rb
|
249
299
|
- lib/oauth2/strategy/auth_code.rb
|
250
300
|
- lib/oauth2/strategy/base.rb
|
@@ -252,33 +302,18 @@ files:
|
|
252
302
|
- lib/oauth2/strategy/implicit.rb
|
253
303
|
- lib/oauth2/strategy/password.rb
|
254
304
|
- lib/oauth2/version.rb
|
255
|
-
- spec/fixtures/README.md
|
256
|
-
- spec/fixtures/RS256/jwtRS256.key
|
257
|
-
- spec/fixtures/RS256/jwtRS256.key.pub
|
258
|
-
- spec/helper.rb
|
259
|
-
- spec/oauth2/access_token_spec.rb
|
260
|
-
- spec/oauth2/authenticator_spec.rb
|
261
|
-
- spec/oauth2/client_spec.rb
|
262
|
-
- spec/oauth2/mac_token_spec.rb
|
263
|
-
- spec/oauth2/response_spec.rb
|
264
|
-
- spec/oauth2/strategy/assertion_spec.rb
|
265
|
-
- spec/oauth2/strategy/auth_code_spec.rb
|
266
|
-
- spec/oauth2/strategy/base_spec.rb
|
267
|
-
- spec/oauth2/strategy/client_credentials_spec.rb
|
268
|
-
- spec/oauth2/strategy/implicit_spec.rb
|
269
|
-
- spec/oauth2/strategy/password_spec.rb
|
270
|
-
- spec/oauth2/version_spec.rb
|
271
305
|
homepage: https://github.com/oauth-xx/oauth2
|
272
306
|
licenses:
|
273
307
|
- MIT
|
274
308
|
metadata:
|
309
|
+
homepage_uri: https://github.com/oauth-xx/oauth2
|
310
|
+
source_code_uri: https://github.com/oauth-xx/oauth2/tree/v2.0.2
|
311
|
+
changelog_uri: https://github.com/oauth-xx/oauth2/blob/v2.0.2/CHANGELOG.md
|
275
312
|
bug_tracker_uri: https://github.com/oauth-xx/oauth2/issues
|
276
|
-
|
277
|
-
documentation_uri: https://www.rubydoc.info/gems/oauth2/1.4.9
|
278
|
-
source_code_uri: https://github.com/oauth-xx/oauth2/tree/v1.4.9
|
313
|
+
documentation_uri: https://www.rubydoc.info/gems/oauth2/2.0.2
|
279
314
|
wiki_uri: https://github.com/oauth-xx/oauth2/wiki
|
280
315
|
rubygems_mfa_required: 'true'
|
281
|
-
post_install_message:
|
316
|
+
post_install_message:
|
282
317
|
rdoc_options: []
|
283
318
|
require_paths:
|
284
319
|
- lib
|
@@ -286,31 +321,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
286
321
|
requirements:
|
287
322
|
- - ">="
|
288
323
|
- !ruby/object:Gem::Version
|
289
|
-
version:
|
324
|
+
version: 2.2.0
|
290
325
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
291
326
|
requirements:
|
292
327
|
- - ">="
|
293
328
|
- !ruby/object:Gem::Version
|
294
|
-
version:
|
329
|
+
version: '0'
|
295
330
|
requirements: []
|
296
|
-
rubygems_version: 3.3.
|
297
|
-
signing_key:
|
331
|
+
rubygems_version: 3.3.16
|
332
|
+
signing_key:
|
298
333
|
specification_version: 4
|
299
334
|
summary: A Ruby wrapper for the OAuth 2.0 protocol.
|
300
|
-
test_files:
|
301
|
-
- spec/fixtures/README.md
|
302
|
-
- spec/fixtures/RS256/jwtRS256.key
|
303
|
-
- spec/fixtures/RS256/jwtRS256.key.pub
|
304
|
-
- spec/helper.rb
|
305
|
-
- spec/oauth2/access_token_spec.rb
|
306
|
-
- spec/oauth2/authenticator_spec.rb
|
307
|
-
- spec/oauth2/client_spec.rb
|
308
|
-
- spec/oauth2/mac_token_spec.rb
|
309
|
-
- spec/oauth2/response_spec.rb
|
310
|
-
- spec/oauth2/strategy/assertion_spec.rb
|
311
|
-
- spec/oauth2/strategy/auth_code_spec.rb
|
312
|
-
- spec/oauth2/strategy/base_spec.rb
|
313
|
-
- spec/oauth2/strategy/client_credentials_spec.rb
|
314
|
-
- spec/oauth2/strategy/implicit_spec.rb
|
315
|
-
- spec/oauth2/strategy/password_spec.rb
|
316
|
-
- spec/oauth2/version_spec.rb
|
335
|
+
test_files: []
|
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::MD5.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
|
data/spec/fixtures/README.md
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# RS256
|
2
|
-
|
3
|
-
## How keys were made
|
4
|
-
|
5
|
-
```shell
|
6
|
-
# No passphrase
|
7
|
-
# Generates the public and private keys:
|
8
|
-
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
|
9
|
-
# Converts the key to PEM format
|
10
|
-
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
|
11
|
-
```
|
@@ -1,51 +0,0 @@
|
|
1
|
-
-----BEGIN RSA PRIVATE KEY-----
|
2
|
-
MIIJKwIBAAKCAgEA5hdXV/4YSymY1T9VNvK2bWRfulwIty1RnAPNINQmfh3aRRkV
|
3
|
-
+PNrbC2Crji9G0AHmQwgW1bZ3kgkkpIm6RVn44fHvBvuXkZ9ABgXw0d2cLIHmwOF
|
4
|
-
xSKmWAm/EW//GszUTLLLsMZUe2udtFJW0jxXB2GRY0WVYuo6Oo58RCeP719lw3Ag
|
5
|
-
s0YF9/IobxKkGd4BautUPw6ZszAa3o+j0zR74x7ouPxybZAOuPsMxqanyeYJeH4o
|
6
|
-
sJjLMYV9qem9uG2sj7GENJ8UszcpmGbqxBhexPEB7mgDeONIF0XJF23zdOf8ANE5
|
7
|
-
mAU2h2v7M6moAfkdUzJ+j48+VT2omHAzAL5yNcmrl2xiWdyoxOw1Y1UmfEmJYV5V
|
8
|
-
gGYyZ12JZRKY+szPT+vR+MDuYxbquF40O7kvkFNBfL1yCpzfSQCLnEs4rX8qRzZX
|
9
|
-
ciLeyq4Ht5FLuRFgxjA//XI8LAmp0u7gk+Q7FUH1UgW3kmJDTG0XaxQxYTBSIO7m
|
10
|
-
cmyjDyBgKVuQmt5E1ycFeteOVdPD/CG/fPYhthvc4UytEFwsMdNy3iD6/wuUH68t
|
11
|
-
AKam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B2GRY0WVYuo6Oo58RCeP719lw3Ags0YF9/IobxKkGd4BautUPw6ZszAa3o+j0zR7
|
6
|
-
4x7ouPxybZAOuPsMxqanyeYJeH4osJjLMYV9qem9uG2sj7GENJ8UszcpmGbqxBhe
|
7
|
-
xPEB7mgDeONIF0XJF23zdOf8ANE5mAU2h2v7M6moAfkdUzJ+j48+VT2omHAzAL5y
|
8
|
-
Ncmrl2xiWdyoxOw1Y1UmfEmJYV5VgGYyZ12JZRKY+szPT+vR+MDuYxbquF40O7kv
|
9
|
-
kFNBfL1yCpzfSQCLnEs4rX8qRzZXciLeyq4Ht5FLuRFgxjA//XI8LAmp0u7gk+Q7
|
10
|
-
FUH1UgW3kmJDTG0XaxQxYTBSIO7mcmyjDyBgKVuQmt5E1ycFeteOVdPD/CG/fPYh
|
11
|
-
thvc4UytEFwsMdNy3iD6/wuUH68tAKam28UZaOb0qK+00cQQD8fulY9rKtSL10Lv
|
12
|
-
JFWUOa/SJyLvk9vUmfvFn182il1nX6GpyxyMmE/FCnH4CT/DjrSZf08mOO8eL5of
|
13
|
-
YHMK/oiXr1eODqx+pOwClNsCAwEAAQ==
|
14
|
-
-----END PUBLIC KEY-----
|
data/spec/helper.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
DEBUG = ENV['DEBUG'] == 'true'
|
4
|
-
RUN_COVERAGE = ENV['CI_CODECOV'] || ENV['CI'].nil?
|
5
|
-
|
6
|
-
ruby_version = Gem::Version.new(RUBY_VERSION)
|
7
|
-
minimum_version = ->(version) { ruby_version >= Gem::Version.new(version) && RUBY_ENGINE == 'ruby' }
|
8
|
-
coverage = minimum_version.call('2.7') && RUN_COVERAGE
|
9
|
-
debug = minimum_version.call('2.5') && DEBUG
|
10
|
-
|
11
|
-
require 'simplecov' if coverage
|
12
|
-
require 'byebug' if debug
|
13
|
-
|
14
|
-
require 'oauth2'
|
15
|
-
require 'addressable/uri'
|
16
|
-
require 'rspec'
|
17
|
-
require 'rspec/stubbed_env'
|
18
|
-
require 'rspec/pending_for'
|
19
|
-
require 'silent_stream'
|
20
|
-
|
21
|
-
RSpec.configure do |config|
|
22
|
-
config.expect_with :rspec do |c|
|
23
|
-
c.syntax = :expect
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
Faraday.default_adapter = :test
|
28
|
-
|
29
|
-
RSpec.configure do |conf|
|
30
|
-
conf.include SilentStream
|
31
|
-
end
|
32
|
-
|
33
|
-
VERBS = [:get, :post, :put, :delete].freeze
|