api-auth 1.5.0 → 2.6.0

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.
Files changed (68) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/main.yml +71 -0
  3. data/.gitignore +13 -44
  4. data/.rubocop.yml +39 -0
  5. data/.rubocop_todo.yml +83 -0
  6. data/Appraisals +12 -36
  7. data/CHANGELOG.md +75 -1
  8. data/README.md +155 -52
  9. data/Rakefile +1 -1
  10. data/VERSION +1 -1
  11. data/api_auth.gemspec +35 -23
  12. data/gemfiles/rails_60.gemfile +9 -0
  13. data/gemfiles/rails_61.gemfile +9 -0
  14. data/gemfiles/rails_70.gemfile +9 -0
  15. data/lib/api-auth.rb +1 -1
  16. data/lib/api_auth/base.rb +41 -35
  17. data/lib/api_auth/errors.rb +4 -3
  18. data/lib/api_auth/headers.rb +38 -42
  19. data/lib/api_auth/helpers.rb +7 -16
  20. data/lib/api_auth/railtie.rb +34 -74
  21. data/lib/api_auth/request_drivers/action_controller.rb +27 -27
  22. data/lib/api_auth/request_drivers/action_dispatch.rb +0 -6
  23. data/lib/api_auth/request_drivers/curb.rb +16 -21
  24. data/lib/api_auth/request_drivers/faraday.rb +25 -34
  25. data/lib/api_auth/request_drivers/faraday_env.rb +102 -0
  26. data/lib/api_auth/request_drivers/grape_request.rb +87 -0
  27. data/lib/api_auth/request_drivers/http.rb +96 -0
  28. data/lib/api_auth/request_drivers/httpi.rb +22 -27
  29. data/lib/api_auth/request_drivers/net_http.rb +21 -26
  30. data/lib/api_auth/request_drivers/rack.rb +23 -28
  31. data/lib/api_auth/request_drivers/rest_client.rb +24 -29
  32. data/lib/api_auth.rb +4 -0
  33. data/lib/faraday/api_auth/middleware.rb +35 -0
  34. data/lib/faraday/api_auth.rb +8 -0
  35. data/spec/api_auth_spec.rb +135 -96
  36. data/spec/faraday_middleware_spec.rb +17 -0
  37. data/spec/headers_spec.rb +148 -108
  38. data/spec/helpers_spec.rb +8 -10
  39. data/spec/railtie_spec.rb +80 -99
  40. data/spec/request_drivers/action_controller_spec.rb +122 -79
  41. data/spec/request_drivers/action_dispatch_spec.rb +212 -85
  42. data/spec/request_drivers/curb_spec.rb +36 -33
  43. data/spec/request_drivers/faraday_env_spec.rb +188 -0
  44. data/spec/request_drivers/faraday_spec.rb +87 -83
  45. data/spec/request_drivers/grape_request_spec.rb +280 -0
  46. data/spec/request_drivers/http_spec.rb +190 -0
  47. data/spec/request_drivers/httpi_spec.rb +59 -59
  48. data/spec/request_drivers/net_http_spec.rb +70 -66
  49. data/spec/request_drivers/rack_spec.rb +101 -97
  50. data/spec/request_drivers/rest_client_spec.rb +218 -144
  51. data/spec/spec_helper.rb +15 -12
  52. metadata +144 -83
  53. data/.travis.yml +0 -40
  54. data/Gemfile.lock +0 -115
  55. data/gemfiles/rails_23.gemfile +0 -9
  56. data/gemfiles/rails_23.gemfile.lock +0 -70
  57. data/gemfiles/rails_30.gemfile +0 -9
  58. data/gemfiles/rails_30.gemfile.lock +0 -92
  59. data/gemfiles/rails_31.gemfile +0 -9
  60. data/gemfiles/rails_31.gemfile.lock +0 -98
  61. data/gemfiles/rails_32.gemfile +0 -9
  62. data/gemfiles/rails_32.gemfile.lock +0 -97
  63. data/gemfiles/rails_4.gemfile +0 -9
  64. data/gemfiles/rails_4.gemfile.lock +0 -94
  65. data/gemfiles/rails_41.gemfile +0 -9
  66. data/gemfiles/rails_41.gemfile.lock +0 -98
  67. data/gemfiles/rails_42.gemfile +0 -9
  68. data/gemfiles/rails_42.gemfile.lock +0 -115
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 79cbdc86c27b9748d521ca8e0efe2038efa0641b
4
- data.tar.gz: 2cc39d41382118e60496a8c9ca9693fb6a4baf02
2
+ SHA256:
3
+ metadata.gz: b642f1c16d0ccca2a260e5440012a3d02fe3b333d3cb769a76e139ec97c39368
4
+ data.tar.gz: 5f68593348b4cbcf7b76250675c7bb355904b8f365129b8a57696e04fed5a802
5
5
  SHA512:
6
- metadata.gz: f6f7a9271d443ffc86bb0cbb3f674febbe860832429e677a54c7e03cea418597768b746b8ce90f51789be20f21f97011be1e6ff50f1ba4ec3e665cc4351c6da7
7
- data.tar.gz: 28873d74e56b7e7cb9b8aee01811841971a79a2d3fa459ca399ac28088495e9e29f26d35216369db5fd626e9f8917877dbcc53d40cb08a23c66bb48f5a6f4975
6
+ metadata.gz: f148aa229d78829b86af9772e962463866e3ad85653b9fc759494969c901717be7d9c6b11087f6873253777610d9dcf3b209189e0076249d72a5256dc2acf026
7
+ data.tar.gz: 6fab592a96c63ab8c52665c321c4291a5bd67fea0d366298a1c3efa82a6819e5a7434f2ed18c0cf48cac301cc219963fcdde831c237868e9a03cc5d09c3ae440
@@ -0,0 +1,71 @@
1
+ name: main
2
+ on:
3
+ - push
4
+ - pull_request
5
+ jobs:
6
+ rspec:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: true
10
+ matrix:
11
+ ruby-version:
12
+ - 2.6
13
+ - 2.7
14
+ - 3.0
15
+ - 3.1
16
+ gemfile:
17
+ - rails_60.gemfile
18
+ - rails_61.gemfile
19
+ - rails_70.gemfile
20
+ exclude:
21
+ - ruby-version: 3.0
22
+ gemfile: rails_60.gemfile
23
+ - ruby-version: 3.1
24
+ gemfile: rails_60.gemfile
25
+ - ruby-version: 2.6
26
+ gemfile: rails_70.gemfile
27
+ - ruby-version: 2.7
28
+ gemfile: rails_70.gemfile
29
+ steps:
30
+ - name: Install packages required for `curb` gem
31
+ run: |
32
+ sudo apt-get update
33
+ sudo apt-get install -y libcurl4 libcurl3-gnutls libcurl4-openssl-dev
34
+
35
+ - name: Checkout repository
36
+ uses: actions/checkout@v2
37
+
38
+ - name: Install Ruby
39
+ uses: ruby/setup-ruby@v1
40
+ with:
41
+ ruby-version: ${{ matrix.ruby-version }}
42
+ bundler-cache: true
43
+
44
+ - name: Install required gems
45
+ run: BUNDLE_GEMFILE=gemfiles/${{ matrix.gemfile }} bundle install
46
+
47
+ - name: Run rspec tests
48
+ run: BUNDLE_GEMFILE=gemfiles/${{ matrix.gemfile }} bundle exec rspec
49
+
50
+ rubocop:
51
+ runs-on: ubuntu-latest
52
+ steps:
53
+ - name: Install packages required for `curb` gem
54
+ run: |
55
+ sudo apt-get update
56
+ sudo apt-get install -y libcurl4 libcurl3-gnutls libcurl4-openssl-dev
57
+
58
+ - name: Checkout repository
59
+ uses: actions/checkout@v2
60
+
61
+ - name: Install Ruby
62
+ uses: ruby/setup-ruby@v1
63
+ with:
64
+ ruby-version: 3.1
65
+ bundler-cache: true
66
+
67
+ - name: Install required gems
68
+ run: bundle install
69
+
70
+ - name: Run rubocop
71
+ run: bundle exec rubocop
data/.gitignore CHANGED
@@ -1,44 +1,13 @@
1
- .rvmrc
2
-
3
- # rcov generated
4
- coverage
5
-
6
- # rdoc generated
7
- rdoc
8
-
9
- # yard generated
10
- doc
11
- .yardoc
12
-
13
- # bundler
14
- .bundle
15
-
16
- # jeweler generated
17
- pkg
18
-
19
- # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
20
- #
21
- # * Create a file at ~/.gitignore
22
- # * Include files you want ignored
23
- # * Run: git config --global core.excludesfile ~/.gitignore
24
- #
25
- # After doing this, these files will be ignored in all your git projects,
26
- # saving you from having to 'pollute' every project you touch with them
27
- #
28
- # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
29
- #
30
- # For MacOS:
31
- #
32
- #.DS_Store
33
- #
34
- # For TextMate
35
- #*.tmproj
36
- #tmtags
37
- #
38
- # For emacs:
39
- #*~
40
- #\#*
41
- #.\#*
42
- #
43
- # For vim:
44
- #*.swp
1
+ /.bundle
2
+ /.ruby-version
3
+ /.rvmrc
4
+ /Gemfile.lock
5
+ /rdoc
6
+ /pkg
7
+ /coverage
8
+ /doc
9
+ /.yardoc
10
+ gemfiles/*.lock
11
+ gemfiles/.bundle/
12
+ /.idea
13
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,39 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ NewCops: enable
5
+ TargetRubyVersion: 2.6
6
+
7
+ Metrics/AbcSize:
8
+ Max: 28
9
+
10
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
11
+ # URISchemes: http, https
12
+ Layout/LineLength:
13
+ Max: 140
14
+
15
+ Metrics/MethodLength:
16
+ Max: 40
17
+
18
+ Metrics/BlockLength:
19
+ Exclude:
20
+ - 'spec/**/*.rb'
21
+ - 'api_auth.gemspec'
22
+
23
+ Naming/FileName:
24
+ Exclude:
25
+ - 'lib/api-auth.rb'
26
+
27
+ Style/FrozenStringLiteralComment:
28
+ Enabled: false
29
+
30
+ Style/StringLiterals:
31
+ Exclude:
32
+ - 'gemfiles/*.gemfile'
33
+
34
+ Lint/DuplicateBranch:
35
+ Enabled: false
36
+
37
+ # Development dependencies in gemspec is valid for gems
38
+ Gemspec/DevelopmentDependencies:
39
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,83 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-08-03 07:19:11 UTC using RuboCop version 1.32.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: AllowSafeAssignment.
11
+ Lint/AssignmentInCondition:
12
+ Exclude:
13
+ - 'lib/api_auth/base.rb'
14
+
15
+ # Offense count: 4
16
+ # Configuration parameters: AllowedMethods.
17
+ # AllowedMethods: enums
18
+ Lint/ConstantDefinitionInBlock:
19
+ Exclude:
20
+ - 'spec/railtie_spec.rb'
21
+
22
+ # Offense count: 9
23
+ # Configuration parameters: CheckForMethodsWithNoSideEffects.
24
+ Lint/Void:
25
+ Exclude:
26
+ - 'lib/api_auth/headers.rb'
27
+ - 'lib/api_auth/request_drivers/action_controller.rb'
28
+ - 'lib/api_auth/request_drivers/curb.rb'
29
+ - 'lib/api_auth/request_drivers/faraday.rb'
30
+ - 'lib/api_auth/request_drivers/grape_request.rb'
31
+ - 'lib/api_auth/request_drivers/httpi.rb'
32
+ - 'lib/api_auth/request_drivers/net_http.rb'
33
+ - 'lib/api_auth/request_drivers/rack.rb'
34
+ - 'lib/api_auth/request_drivers/rest_client.rb'
35
+
36
+ # Offense count: 2
37
+ # Configuration parameters: IgnoredMethods.
38
+ Metrics/CyclomaticComplexity:
39
+ Max: 16
40
+
41
+ # Offense count: 11
42
+ Naming/AccessorMethodName:
43
+ Exclude:
44
+ - 'lib/api_auth/railtie.rb'
45
+ - 'lib/api_auth/request_drivers/action_controller.rb'
46
+ - 'lib/api_auth/request_drivers/curb.rb'
47
+ - 'lib/api_auth/request_drivers/faraday.rb'
48
+ - 'lib/api_auth/request_drivers/faraday_env.rb'
49
+ - 'lib/api_auth/request_drivers/grape_request.rb'
50
+ - 'lib/api_auth/request_drivers/http.rb'
51
+ - 'lib/api_auth/request_drivers/httpi.rb'
52
+ - 'lib/api_auth/request_drivers/net_http.rb'
53
+ - 'lib/api_auth/request_drivers/rack.rb'
54
+ - 'lib/api_auth/request_drivers/rest_client.rb'
55
+
56
+ # Offense count: 3
57
+ # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
58
+ # AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
59
+ Naming/MethodParameterName:
60
+ Exclude:
61
+ - 'lib/api_auth/base.rb'
62
+ - 'spec/railtie_spec.rb'
63
+
64
+ # Offense count: 4
65
+ # Configuration parameters: AllowedConstants.
66
+ Style/Documentation:
67
+ Exclude:
68
+ - 'spec/**/*'
69
+ - 'test/**/*'
70
+ - 'lib/api_auth/railtie.rb'
71
+ - 'lib/api_auth/request_drivers/rest_client.rb'
72
+
73
+ # Offense count: 1
74
+ # Configuration parameters: AllowedMethods.
75
+ # AllowedMethods: respond_to_missing?
76
+ Style/OptionalBooleanParameter:
77
+ Exclude:
78
+ - 'lib/api_auth/railtie.rb'
79
+
80
+ # Offense count: 1
81
+ Lint/UselessConstantScoping:
82
+ Exclude:
83
+ - 'lib/api_auth/base.rb'
data/Appraisals CHANGED
@@ -1,41 +1,17 @@
1
- appraise "rails-42" do
2
- gem "actionpack", "~> 4.2.0"
3
- gem "activeresource", "~> 4.0.0"
4
- gem "activesupport", "~> 4.2.0"
1
+ appraise 'rails-60' do
2
+ gem 'actionpack', '~> 6.0'
3
+ gem 'activeresource', '~> 5.1'
4
+ gem 'activesupport', '~> 6.0'
5
5
  end
6
6
 
7
- appraise "rails-41" do
8
- gem "actionpack", "~> 4.1.0"
9
- gem "activeresource", "~> 4.0.0"
10
- gem "activesupport", "~> 4.1.0"
7
+ appraise 'rails-61' do
8
+ gem 'actionpack', '~> 6.1'
9
+ gem 'activeresource', '~> 5.1'
10
+ gem 'activesupport', '~> 6.1'
11
11
  end
12
12
 
13
- appraise "rails-4" do
14
- gem "actionpack", "~> 4.0.4"
15
- gem "activeresource", "~> 4.0.0"
16
- gem "activesupport", "~> 4.0.4"
17
- end
18
-
19
- appraise "rails-32" do
20
- gem "actionpack", "~> 3.2.17"
21
- gem "activeresource", "~> 3.2.17"
22
- gem "activesupport", "~> 3.2.17"
23
- end
24
-
25
- appraise "rails-31" do
26
- gem "actionpack", "~> 3.1.0"
27
- gem "activeresource", "~> 3.1.0"
28
- gem "activesupport", "~> 3.1.0"
29
- end
30
-
31
- appraise "rails-30" do
32
- gem "actionpack", "~> 3.0.20"
33
- gem "activeresource", "~> 3.0.20"
34
- gem "activesupport", "~> 3.0.20"
35
- end
36
-
37
- appraise "rails-23" do
38
- gem "actionpack", "~> 2.3.2"
39
- gem "activeresource", "~> 2.3.2"
40
- gem "activesupport", "~> 2.3.2"
13
+ appraise 'rails-70' do
14
+ gem 'actionpack', '~> 7.0'
15
+ gem 'activeresource', '~> 6.0'
16
+ gem 'activesupport', '~> 7.0'
41
17
  end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,77 @@
1
+ # 2.6.0 (2025-01-18)
2
+ - Add Faraday middleware support (#1322051 Frédéric Mangano)
3
+ - Add MD5 compatibility option in authentic? method (#a618e15 Samir ALI CHERIF)
4
+ - Add support for Ruby 3.1 and Rails 7.0 (#552cab0 fwininger)
5
+ - Drop support for Rails 5 and Ruby 2.5 (#552cab0 fwininger)
6
+ - Fix HTTPS URL handling (#c734a88 fwininger)
7
+ - Update Grape to v2.0+ for Rails 7/Rack 3 compatibility
8
+ - Update Rubocop to v1.50+ and Curb to v1.0+ for Ruby 3.x compatibility
9
+ - Fix Ruby 2.6 compatibility with Rails 6.x (Logger loading issue)
10
+ - Add drb gem dependency (2.0.4-2.0.5) for Ruby 3.4+ compatibility while avoiding Ruby 2.6 conflicts
11
+
12
+ # 2.5.1 (2021-11-26)
13
+ - Add spec coverage for all content hashes (#202 fwininger)
14
+ - Require MFA for Rubygems (#203 fwininger)
15
+ - Integration with GitHub Actions
16
+ - Fix look up of `X-AUTHORIZATION-CONTENT-SHA256` header
17
+ - Adding license information to the gemspec
18
+
19
+ # 2.5.0 (2021-05-11)
20
+ - Add support for Ruby 3.0 (#194 fwininger)
21
+ - Add support for Rails 6.1 (#194 fwininger)
22
+ - Drop support for Ruby 2.4 (#193 fwininger)
23
+ - Drop support for Rails 5.0 (#194 fwininger)
24
+ - Drop support for Rails 5.1 (#194 fwininger)
25
+ - Fix Faraday warning: `WARNING: Faraday::Request#method is deprecated` (#191 fwininger)
26
+
27
+ # 2.4.1 (2020-06-23)
28
+ - Fix inadvertant ActiveSupport dependecy (#189 taylorthurlow)
29
+
30
+ # 2.4.0 (2020-05-05)
31
+ - Improved support for Rails 6.0 (#179 taylorthurlow, #177 fwininger)
32
+ - Added Ruby 2.6.0 support (#174 fwininger)
33
+ - README updates (#186 iranthau)
34
+
35
+ # 2.3.1 (2018-11-06)
36
+ - Fixed a regression in the http.rb driver (#173 tycooon)
37
+
38
+ # 2.3.0 (2018-10-23)
39
+ - Added support for Grape API (#169 phuongnd08 & dunghuynh)
40
+ - Added option for specifying customer headers to sign via new `headers_to_sign`
41
+ argument (#170 fakenine)
42
+ - Fix tests and drop support for Ruby < 2.3 (#171 fwininger)
43
+
44
+ # 2.2.0 (2018-03-12)
45
+ - Drop support ruby 1.x, rails 2.x, rails 3.x (#141 fwininger)
46
+ - Add http.rb request driver (#164 tycooon)
47
+ - Fix POST and PUT requests in RestClient (#151 fwininger)
48
+ - Allow clock skew to be user-defined (#136 mlarraz)
49
+ - Adds #original_uri method to all request drivers (#137 iMacTia)
50
+ - Rubocop and test fixes (fwininger & nicolasleger)
51
+ - Changed return type for request #content_md5 #timestamp #content_type (fwininger)
52
+ - Fix URI edge case where a URI contains another URI (zfletch)
53
+ - Updates to the README (zfletch)
54
+
55
+ # 2.1.0 (2016-12-22)
56
+ - Fixed a NoMethodError that might occur when using the NetHttp Driver (#130 grahamkenville)
57
+ - More securely compare signatures in a way that prevents timing attacks (#56 leishman, #133 will0)
58
+ - Remove support for MD2 and MD4 hashing algorithms since they are insecure (#134 will0)
59
+ - Disallow requests that are too far in the future to limit the time available for a brute force signature guess (#119 fwininger)
60
+
61
+ # 2.0.1 (2016-07-25)
62
+ - Support of `api_auth_options` in ActiveResource integration (#102 fwininger)
63
+ - Replace use of `#blank?` with `#nil?` to not depend on ActiveSupport (#114 packrat386)
64
+ - Fix Auth header matching to not match invalid SHA algorithms (#115 packrat386)
65
+ - Replace `alias_method_chain` with `alias_method` in the railtie since
66
+ alias_method_chain is deprecated in Rails 5 (#118 mlarraz)
67
+
68
+ # 2.0.0 (2016-05-11)
69
+ - IMPORTANT: 2.0.0 is backwards incompatible with the default settings of v1.x
70
+ v2.0.0 always includes the http method in the canonical string.
71
+ You can use the upgrade strategy in v1.4.x and above to migrate to v2.0.0
72
+ without any down time. Please see the 1.4.0 release nodes for more info
73
+ - Added support for other digest algorithms like SHA-256 (#98 fwininger)
74
+
1
75
  # 1.5.0 (2016-01-21)
2
76
  - Added a sign_with_http_method configuration option to the ActiveResource
3
77
  rails tie to correspond to passing the `:with_http_method => true` into
@@ -7,7 +81,7 @@
7
81
  - Fixed an issue where getters wouldn't immediately have the correct value after
8
82
  setting a date or content md5 in some of the request drivers (#91)
9
83
 
10
- # 1.4 (2015-12-16)
84
+ # 1.4.0 (2015-12-16)
11
85
 
12
86
  ## IMPORTANT SECURITY FIX (with backwards compatible fallback)
13
87