hmac 2.1.0 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7888837728c6bb09e5e14affacdb43a21f11da744c0764bb4ef5a9b57ed0a62b
4
- data.tar.gz: 05ecca95e1798456adb1e5b81201ac8bafdbe981b897a688ebd7bf7a29d270f0
3
+ metadata.gz: 5fd24073f962286b5036af83509c0b66b111570bef35c7dddc985727e83763ed
4
+ data.tar.gz: 2454b49c08c891b5012a0d089ae08dc7ffa9cfef07c06ce54b05d3075dab32ab
5
5
  SHA512:
6
- metadata.gz: 4112f07d1dee0c90e7e5f2a878998401cb1fa8b6b7989a7e5693e8ecfa78acb03ced551a070091a9e2539aa30295c029023a72b1ed3462aaf3665a6c63860ba8
7
- data.tar.gz: d9256aa9cb5973a34f2a0dfc045f6a24b60603574077d259d9d89a399793c7128dfa770039417f63440c28298e6aa8e6140f65250437b4a1da76f87b6556b114
6
+ metadata.gz: afeea418951c0e9a0d2907e021ab445e1bc9b73331d3e3cc3c1a0e51d4773c53586965a36661c1574245d44a7c0fc6cc00431bbe1a9b96701e441faf99e7e7ec
7
+ data.tar.gz: faf288b5fefbf5da8bcd76c413427eeda87a5ae619fd6d14a2aba27910a33290625ef5828e4a3ce09e2a34b3c1611c52b5b024719e4274413e55af46e2957094
data/.rubocop.yml CHANGED
@@ -7,9 +7,11 @@ AllCops:
7
7
  <% end %>
8
8
 
9
9
  # Extensions
10
- require:
10
+ plugins:
11
+ - rubocop-factory_bot
11
12
  - rubocop-rake
12
13
  - rubocop-rspec
14
+ - rubocop-rspec_rails
13
15
 
14
16
  # New rules
15
17
  Lint/DuplicateBranch: # (new in 1.3)
@@ -42,8 +44,6 @@ Style/RedundantArgument: # (new in 1.4)
42
44
  Enabled: true
43
45
  Style/SwapValues: # (new in 1.1)
44
46
  Enabled: true
45
- Gemspec/DateAssignment: # (new in 1.10)
46
- Enabled: true
47
47
  Layout/SpaceBeforeBrackets: # (new in 1.7)
48
48
  Enabled: true
49
49
  Lint/AmbiguousAssignment: # (new in 1.7)
@@ -120,10 +120,6 @@ RSpec/IdenticalEqualityAssertion: # new in 2.4
120
120
  Enabled: true
121
121
  RSpec/SubjectDeclaration: # new in 2.5
122
122
  Enabled: true
123
- RSpec/FactoryBot/SyntaxMethods: # new in 2.7
124
- Enabled: true
125
- RSpec/Rails/AvoidSetupHook: # new in 2.4
126
- Enabled: true
127
123
  Style/NestedFileDirname: # new in 1.26
128
124
  Enabled: true
129
125
  RSpec/BeEq: # new in 2.9.0
@@ -134,6 +130,250 @@ Lint/RefinementImportMethods: # new in 1.27
134
130
  Enabled: true
135
131
  Style/RedundantInitialize: # new in 1.27
136
132
  Enabled: true
133
+ Gemspec/AddRuntimeDependency: # new in 1.65
134
+ Enabled: true
135
+ Gemspec/AttributeAssignment: # new in 1.77
136
+ Enabled: true
137
+ Gemspec/DeprecatedAttributeAssignment: # new in 1.30
138
+ Enabled: true
139
+ Gemspec/DevelopmentDependencies: # new in 1.44
140
+ Enabled: true
141
+ Layout/EmptyLinesAfterModuleInclusion: # new in 1.79
142
+ Enabled: true
143
+ Layout/LineContinuationLeadingSpace: # new in 1.31
144
+ Enabled: true
145
+ Layout/LineContinuationSpacing: # new in 1.31
146
+ Enabled: true
147
+ Lint/ArrayLiteralInRegexp: # new in 1.71
148
+ Enabled: true
149
+ Lint/ConstantOverwrittenInRescue: # new in 1.31
150
+ Enabled: true
151
+ Lint/ConstantReassignment: # new in 1.70
152
+ Enabled: true
153
+ Lint/CopDirectiveSyntax: # new in 1.72
154
+ Enabled: true
155
+ Lint/DataDefineOverride: # new in 1.85
156
+ Enabled: true
157
+ Lint/DuplicateMagicComment: # new in 1.37
158
+ Enabled: true
159
+ Lint/DuplicateMatchPattern: # new in 1.50
160
+ Enabled: true
161
+ Lint/DuplicateSetElement: # new in 1.67
162
+ Enabled: true
163
+ Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69
164
+ Enabled: true
165
+ Lint/ItWithoutArgumentsInBlock: # new in 1.59
166
+ Enabled: true
167
+ Lint/LiteralAssignmentInCondition: # new in 1.58
168
+ Enabled: true
169
+ Lint/MixedCaseRange: # new in 1.53
170
+ Enabled: true
171
+ Lint/NonAtomicFileOperation: # new in 1.31
172
+ Enabled: true
173
+ Lint/NumericOperationWithConstantResult: # new in 1.69
174
+ Enabled: true
175
+ Lint/RedundantRegexpQuantifiers: # new in 1.53
176
+ Enabled: true
177
+ Lint/RedundantTypeConversion: # new in 1.72
178
+ Enabled: true
179
+ Lint/RequireRangeParentheses: # new in 1.32
180
+ Enabled: true
181
+ Lint/SharedMutableDefault: # new in 1.70
182
+ Enabled: true
183
+ Lint/SuppressedExceptionInNumberConversion: # new in 1.72
184
+ Enabled: true
185
+ Lint/UnescapedBracketInRegexp: # new in 1.68
186
+ Enabled: true
187
+ Lint/UnreachablePatternBranch: # new in 1.85
188
+ Enabled: true
189
+ Lint/UselessConstantScoping: # new in 1.72
190
+ Enabled: true
191
+ Lint/UselessDefaultValueArgument: # new in 1.76
192
+ Enabled: true
193
+ Lint/UselessDefined: # new in 1.69
194
+ Enabled: true
195
+ Lint/UselessNumericOperation: # new in 1.66
196
+ Enabled: true
197
+ Lint/UselessOr: # new in 1.76
198
+ Enabled: true
199
+ Lint/UselessRescue: # new in 1.43
200
+ Enabled: true
201
+ Metrics/CollectionLiteralLength: # new in 1.47
202
+ Enabled: true
203
+ Naming/PredicateMethod: # new in 1.76
204
+ Enabled: true
205
+ Security/CompoundHash: # new in 1.28
206
+ Enabled: true
207
+ Style/AmbiguousEndlessMethodDefinition: # new in 1.68
208
+ Enabled: true
209
+ Style/ArrayIntersect: # new in 1.40
210
+ Enabled: true
211
+ Style/ArrayIntersectWithSingleElement: # new in 1.81
212
+ Enabled: true
213
+ Style/BitwisePredicate: # new in 1.68
214
+ Enabled: true
215
+ Style/CollectionQuerying: # new in 1.77
216
+ Enabled: true
217
+ Style/CombinableDefined: # new in 1.68
218
+ Enabled: true
219
+ Style/ComparableBetween: # new in 1.74
220
+ Enabled: true
221
+ Style/ComparableClamp: # new in 1.44
222
+ Enabled: true
223
+ Style/ConcatArrayLiterals: # new in 1.41
224
+ Enabled: true
225
+ Style/DataInheritance: # new in 1.49
226
+ Enabled: true
227
+ Style/DigChain: # new in 1.69
228
+ Enabled: true
229
+ Style/DirEmpty: # new in 1.48
230
+ Enabled: true
231
+ Style/EmptyClassDefinition: # new in 1.84
232
+ Enabled: true
233
+ Style/EmptyHeredoc: # new in 1.32
234
+ Enabled: true
235
+ Style/EmptyStringInsideInterpolation: # new in 1.76
236
+ Enabled: true
237
+ Style/EnvHome: # new in 1.29
238
+ Enabled: true
239
+ Style/ExactRegexpMatch: # new in 1.51
240
+ Enabled: true
241
+ Style/FetchEnvVar: # new in 1.28
242
+ Enabled: true
243
+ Style/FileEmpty: # new in 1.48
244
+ Enabled: true
245
+ Style/FileNull: # new in 1.69
246
+ Enabled: true
247
+ Style/FileOpen: # new in 1.85
248
+ Enabled: true
249
+ Style/FileTouch: # new in 1.69
250
+ Enabled: true
251
+ Style/HashFetchChain: # new in 1.75
252
+ Enabled: true
253
+ Style/HashSlice: # new in 1.71
254
+ Enabled: true
255
+ Style/ItAssignment: # new in 1.70
256
+ Enabled: true
257
+ Style/ItBlockParameter: # new in 1.75
258
+ Enabled: true
259
+ Style/KeywordArgumentsMerging: # new in 1.68
260
+ Enabled: true
261
+ Style/MagicCommentFormat: # new in 1.35
262
+ Enabled: true
263
+ Style/MapCompactWithConditionalBlock: # new in 1.30
264
+ Enabled: true
265
+ Style/MapIntoArray: # new in 1.63
266
+ Enabled: true
267
+ Style/MapJoin: # new in 1.85
268
+ Enabled: true
269
+ Style/MapToSet: # new in 1.42
270
+ Enabled: true
271
+ Style/MinMaxComparison: # new in 1.42
272
+ Enabled: true
273
+ Style/ModuleMemberExistenceCheck: # new in 1.82
274
+ Enabled: true
275
+ Style/NegativeArrayIndex: # new in 1.84
276
+ Enabled: true
277
+ Style/ObjectThen: # new in 1.28
278
+ Enabled: true
279
+ Style/OneClassPerFile: # new in 1.85
280
+ Enabled: true
281
+ Style/OperatorMethodCall: # new in 1.37
282
+ Enabled: true
283
+ Style/PartitionInsteadOfDoubleSelect: # new in 1.85
284
+ Enabled: true
285
+ Style/PredicateWithKind: # new in 1.85
286
+ Enabled: true
287
+ Style/ReduceToHash: # new in 1.85
288
+ Enabled: true
289
+ Style/RedundantArrayConstructor: # new in 1.52
290
+ Enabled: true
291
+ Style/RedundantArrayFlatten: # new in 1.76
292
+ Enabled: true
293
+ Style/RedundantConstantBase: # new in 1.40
294
+ Enabled: true
295
+ Style/RedundantCurrentDirectoryInPath: # new in 1.53
296
+ Enabled: true
297
+ Style/RedundantDoubleSplatHashBraces: # new in 1.41
298
+ Enabled: true
299
+ Style/RedundantEach: # new in 1.38
300
+ Enabled: true
301
+ Style/RedundantFilterChain: # new in 1.52
302
+ Enabled: true
303
+ Style/RedundantFormat: # new in 1.72
304
+ Enabled: true
305
+ Style/RedundantHeredocDelimiterQuotes: # new in 1.45
306
+ Enabled: true
307
+ Style/RedundantInterpolationUnfreeze: # new in 1.66
308
+ Enabled: true
309
+ Style/RedundantLineContinuation: # new in 1.49
310
+ Enabled: true
311
+ Style/RedundantMinMaxBy: # new in 1.85
312
+ Enabled: true
313
+ Style/RedundantRegexpArgument: # new in 1.53
314
+ Enabled: true
315
+ Style/RedundantRegexpConstructor: # new in 1.52
316
+ Enabled: true
317
+ Style/RedundantStringEscape: # new in 1.37
318
+ Enabled: true
319
+ Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
320
+ Enabled: true
321
+ Style/ReverseFind: # new in 1.84
322
+ Enabled: true
323
+ Style/SafeNavigationChainLength: # new in 1.68
324
+ Enabled: true
325
+ Style/SelectByKind: # new in 1.85
326
+ Enabled: true
327
+ Style/SelectByRange: # new in 1.85
328
+ Enabled: true
329
+ Style/SendWithLiteralMethodName: # new in 1.64
330
+ Enabled: true
331
+ Style/SingleLineDoEndBlock: # new in 1.57
332
+ Enabled: true
333
+ Style/SuperArguments: # new in 1.64
334
+ Enabled: true
335
+ Style/SuperWithArgsParentheses: # new in 1.58
336
+ Enabled: true
337
+ Style/TallyMethod: # new in 1.85
338
+ Enabled: true
339
+ Style/YAMLFileRead: # new in 1.53
340
+ Enabled: true
341
+ FactoryBot/AssociationStyle: # new in 2.23
342
+ Enabled: true
343
+ FactoryBot/ConsistentParenthesesStyle: # new in 2.14
344
+ Enabled: true
345
+ FactoryBot/ExcessiveCreateList: # new in 2.25
346
+ Enabled: true
347
+ FactoryBot/FactoryAssociationWithStrategy: # new in 2.23
348
+ Enabled: true
349
+ FactoryBot/FactoryNameStyle: # new in 2.16
350
+ Enabled: true
351
+ FactoryBot/IdSequence: # new in 2.24
352
+ Enabled: true
353
+ FactoryBot/RedundantFactoryOption: # new in 2.23
354
+ Enabled: true
355
+ FactoryBot/SyntaxMethods: # new in 2.7
356
+ Enabled: true
357
+ RSpec/IncludeExamples: # new in 3.6
358
+ Enabled: true
359
+ RSpec/LeakyLocalVariable: # new in 3.8
360
+ Enabled: true
361
+ RSpec/Output: # new in 3.9
362
+ Enabled: true
363
+ RSpecRails/AvoidSetupHook: # new in 2.4
364
+ Enabled: true
365
+ RSpecRails/HaveHttpStatus: # new in 2.12
366
+ Enabled: true
367
+ RSpecRails/HttpStatusNameConsistency: # new in 2.32
368
+ Enabled: true
369
+ RSpecRails/InferredSpecType: # new in 2.14
370
+ Enabled: true
371
+ RSpecRails/MinitestAssertions: # new in 2.17
372
+ Enabled: true
373
+ RSpecRails/NegationBeValid: # new in 2.23
374
+ Enabled: true
375
+ RSpecRails/TravelAround: # new in 2.19
376
+ Enabled: true
137
377
 
138
378
  # Alterations
139
379
  Naming/RescuedExceptionsVariableName:
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.3.6
data/Gemfile CHANGED
@@ -5,8 +5,10 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in hmac.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
- gem "rspec", "~> 3.11"
10
- gem "rubocop", "~> 1.7"
11
- gem "rubocop-rake", "~> 0.6"
12
- gem "rubocop-rspec", "~> 2.9"
8
+ gem "rake", "~> 13.4"
9
+ gem "rspec", "~> 3.13"
10
+ gem "rubocop", "~> 1.86"
11
+ gem "rubocop-factory_bot", "~> 2.28"
12
+ gem "rubocop-rake", "~> 0.7"
13
+ gem "rubocop-rspec", "~> 3.9"
14
+ gem "rubocop-rspec_rails", "~> 2.32"
data/Gemfile.lock CHANGED
@@ -1,62 +1,85 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hmac (2.0.0)
4
+ hmac (2.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.2)
10
- diff-lcs (1.5.0)
11
- parallel (1.22.1)
12
- parser (3.1.2.0)
9
+ ast (2.4.3)
10
+ diff-lcs (1.5.1)
11
+ json (2.19.4)
12
+ language_server-protocol (3.17.0.5)
13
+ lint_roller (1.1.0)
14
+ parallel (2.1.0)
15
+ parser (3.3.11.1)
13
16
  ast (~> 2.4.1)
17
+ racc
18
+ prism (1.9.0)
19
+ racc (1.8.1)
14
20
  rainbow (3.1.1)
15
- rake (13.0.6)
16
- regexp_parser (2.3.0)
17
- rexml (3.2.5)
18
- rspec (3.11.0)
19
- rspec-core (~> 3.11.0)
20
- rspec-expectations (~> 3.11.0)
21
- rspec-mocks (~> 3.11.0)
22
- rspec-core (3.11.0)
23
- rspec-support (~> 3.11.0)
24
- rspec-expectations (3.11.0)
21
+ rake (13.4.2)
22
+ regexp_parser (2.12.0)
23
+ rspec (3.13.0)
24
+ rspec-core (~> 3.13.0)
25
+ rspec-expectations (~> 3.13.0)
26
+ rspec-mocks (~> 3.13.0)
27
+ rspec-core (3.13.0)
28
+ rspec-support (~> 3.13.0)
29
+ rspec-expectations (3.13.0)
25
30
  diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.11.0)
27
- rspec-mocks (3.11.1)
31
+ rspec-support (~> 3.13.0)
32
+ rspec-mocks (3.13.0)
28
33
  diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.11.0)
30
- rspec-support (3.11.0)
31
- rubocop (1.27.0)
32
- parallel (~> 1.10)
33
- parser (>= 3.1.0.0)
34
+ rspec-support (~> 3.13.0)
35
+ rspec-support (3.13.1)
36
+ rubocop (1.86.1)
37
+ json (~> 2.3)
38
+ language_server-protocol (~> 3.17.0.2)
39
+ lint_roller (~> 1.1.0)
40
+ parallel (>= 1.10)
41
+ parser (>= 3.3.0.2)
34
42
  rainbow (>= 2.2.2, < 4.0)
35
- regexp_parser (>= 1.8, < 3.0)
36
- rexml
37
- rubocop-ast (>= 1.16.0, < 2.0)
43
+ regexp_parser (>= 2.9.3, < 3.0)
44
+ rubocop-ast (>= 1.49.0, < 2.0)
38
45
  ruby-progressbar (~> 1.7)
39
- unicode-display_width (>= 1.4.0, < 3.0)
40
- rubocop-ast (1.17.0)
41
- parser (>= 3.1.1.0)
42
- rubocop-rake (0.6.0)
43
- rubocop (~> 1.0)
44
- rubocop-rspec (2.9.0)
45
- rubocop (~> 1.19)
46
- ruby-progressbar (1.11.0)
47
- unicode-display_width (2.1.0)
46
+ unicode-display_width (>= 2.4.0, < 4.0)
47
+ rubocop-ast (1.49.1)
48
+ parser (>= 3.3.7.2)
49
+ prism (~> 1.7)
50
+ rubocop-factory_bot (2.28.0)
51
+ lint_roller (~> 1.1)
52
+ rubocop (~> 1.72, >= 1.72.1)
53
+ rubocop-rake (0.7.1)
54
+ lint_roller (~> 1.1)
55
+ rubocop (>= 1.72.1)
56
+ rubocop-rspec (3.9.0)
57
+ lint_roller (~> 1.1)
58
+ rubocop (~> 1.81)
59
+ rubocop-rspec_rails (2.32.0)
60
+ lint_roller (~> 1.1)
61
+ rubocop (~> 1.72, >= 1.72.1)
62
+ rubocop-rspec (~> 3.5)
63
+ ruby-progressbar (1.13.0)
64
+ unicode-display_width (3.2.0)
65
+ unicode-emoji (~> 4.1)
66
+ unicode-emoji (4.2.0)
48
67
 
49
68
  PLATFORMS
69
+ arm64-darwin-23
70
+ arm64-darwin-24
50
71
  x86_64-darwin-19
51
72
  x86_64-darwin-21
52
73
 
53
74
  DEPENDENCIES
54
75
  hmac!
55
- rake (~> 13.0)
56
- rspec (~> 3.11)
57
- rubocop (~> 1.7)
58
- rubocop-rake (~> 0.6)
59
- rubocop-rspec (~> 2.9)
76
+ rake (~> 13.4)
77
+ rspec (~> 3.13)
78
+ rubocop (~> 1.86)
79
+ rubocop-factory_bot (~> 2.28)
80
+ rubocop-rake (~> 0.7)
81
+ rubocop-rspec (~> 3.9)
82
+ rubocop-rspec_rails (~> 2.32)
60
83
 
61
84
  BUNDLED WITH
62
- 2.3.10
85
+ 2.5.7
data/README.md CHANGED
@@ -18,7 +18,79 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ### Configuration
22
+
23
+ You'll need to set a secret key, for example:
24
+
25
+ `config/initializers/hmac.rb`
26
+ ```ruby
27
+ HMAC.configure do |config|
28
+ config.secret = ENV["HMAC_SECRET"]
29
+ end
30
+ ```
31
+
32
+ This can be overriden when intializing the HMAC generator if needed.
33
+
34
+ ### Generating an HMAC
35
+
36
+ Firstly, create yourself a generator, giving it a context for the HMAC.
37
+
38
+ The idea is that you can produce tokens for the same record ID in
39
+ different contexts, without allowing someone to use a token from one
40
+ context in another.
41
+
42
+ ```ruby
43
+ generator = HMAC::Generator.new(context: "user_sessions")
44
+ ```
45
+
46
+ Then you can generate a token for a given record ID:
47
+
48
+ ```ruby
49
+ token = generator.generate(user.id)
50
+ ```
51
+
52
+ You can also pass in a `public` boolean when creating the generator to
53
+ similarly produce a different HMAC for the same ID and context but in
54
+ public and private situations. To be honest I don't remember why I
55
+ added this, but it's there if you need it.
56
+
57
+ ```ruby
58
+ generator = HMAC::Generator.new(context: "user_sessions", public: true)
59
+ ```
60
+
61
+ Finally, you can pass in an arbitrary hash of extra fields to be
62
+ included in the hash, if you want to confirm more than just the ID.
63
+
64
+ ```ruby
65
+ token = generator.generate(user.id, { email_address: user.email_address })
66
+ ```
67
+
68
+ ### Validating an HMAC
69
+
70
+ You can verify a token by creating a validator with the same context
71
+ and then calling `verify` on it. The initializer is identical to the
72
+ generator.
73
+
74
+ ```ruby
75
+ validator = HMAC::Validator.new(context: "user_sessions")
76
+ ```
77
+
78
+ Then you can verify a token for a given record ID:
79
+
80
+ ```ruby
81
+ validator.verify(token, against_id: user.id)
82
+ ```
83
+
84
+ Similarly, extra fields can be passed in to be checked.
85
+
86
+ ```ruby
87
+ validator.verify(token, against_id: user.id, extra_fields: {
88
+ email_address: user.email_address,
89
+ })
90
+ ```
91
+
92
+ The `#verify` method will return `true` or `false`. If `false`,
93
+ something doesn't match and you should refuse the request.
22
94
 
23
95
  ## Development
24
96
 
data/bin/rspec ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/rubocop ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("rubocop", "rubocop")
@@ -1,3 +1,4 @@
1
+ require "openssl"
1
2
  require_relative "generator"
2
3
 
3
4
  module HMAC
@@ -7,7 +8,7 @@ module HMAC
7
8
  end
8
9
 
9
10
  def validate(hmac, against_id:, extra_fields: {})
10
- present?(hmac) && hmac == @generator.generate(id: against_id, extra_fields:)
11
+ present?(hmac) && OpenSSL.secure_compare(hmac, @generator.generate(id: against_id, extra_fields:))
11
12
  end
12
13
 
13
14
  private
data/lib/hmac/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HMAC
4
- VERSION = "2.1.0"
4
+ VERSION = "2.1.1"
5
5
  end
metadata CHANGED
@@ -1,16 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hmac
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Crosby-McCullough
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-04-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
- description:
14
12
  email:
15
13
  - elliot.cm@gmail.com
16
14
  executables: []
@@ -21,7 +19,7 @@ files:
21
19
  - ".gitignore"
22
20
  - ".rspec"
23
21
  - ".rubocop.yml"
24
- - ".ruby-version"
22
+ - ".tool-versions"
25
23
  - CHANGELOG.md
26
24
  - Gemfile
27
25
  - Gemfile.lock
@@ -30,6 +28,8 @@ files:
30
28
  - Rakefile
31
29
  - bin/console
32
30
  - bin/release
31
+ - bin/rspec
32
+ - bin/rubocop
33
33
  - bin/setup
34
34
  - hmac.gemspec
35
35
  - lib/hmac.rb
@@ -42,9 +42,8 @@ metadata:
42
42
  allowed_push_host: https://rubygems.org
43
43
  homepage_uri: https://github.com/SmartCasual/hmac
44
44
  source_code_uri: https://github.com/SmartCasual/hmac
45
- changelog_uri: https://github.com/SmartCasual/hmac/blob/2.1.0/CHANGELOG.md
45
+ changelog_uri: https://github.com/SmartCasual/hmac/blob/2.1.1/CHANGELOG.md
46
46
  rubygems_mfa_required: 'true'
47
- post_install_message:
48
47
  rdoc_options: []
49
48
  require_paths:
50
49
  - lib
@@ -59,8 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
58
  - !ruby/object:Gem::Version
60
59
  version: '0'
61
60
  requirements: []
62
- rubygems_version: 3.3.7
63
- signing_key:
61
+ rubygems_version: 3.7.2
64
62
  specification_version: 4
65
63
  summary: A utility for generating and validating HMAC signatures
66
64
  test_files: []
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.1.1