Skip to content

Commit 2b2dfb2

Browse files
fwiningerkjg
authored andcommitted
Drop support ruby 1.x, rails 2.x, rails 3.x (#141)
* Remove Rails <4 exceptions Signed-off-by: Florian Wininger <[email protected]> * Remove Ruby 1.X exceptions Signed-off-by: Florian Wininger <[email protected]> * Rubocop : use ruby19 hash style Signed-off-by: Florian Wininger <[email protected]> * Remove GemFiles and Environnement Rails 2.X, Rails 3.X, Ruby 1.X Signed-off-by: Florian Wininger <[email protected]> * Use default rubocop configuration Signed-off-by: Florian Wininger <[email protected]> * Remove useless assignement Signed-off-by: Florian Wininger <[email protected]>
1 parent 914a666 commit 2b2dfb2

27 files changed

+181
-353
lines changed

.rubocop.yml

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ Lint/AssignmentInCondition:
1212
Exclude:
1313
- 'lib/api_auth/base.rb'
1414

15-
# Offense count: 1
16-
Lint/UselessAssignment:
17-
Exclude:
18-
- 'spec/request_drivers/rest_client_spec.rb'
19-
2015
# Offense count: 2
2116
Metrics/AbcSize:
2217
Max: 25
@@ -60,42 +55,9 @@ Style/Documentation:
6055
- 'lib/api_auth/railtie.rb'
6156
- 'lib/api_auth/request_drivers/rest_client.rb'
6257

63-
# Offense count: 1
64-
# Cop supports --auto-correct.
65-
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
66-
Style/ExtraSpacing:
67-
Exclude:
68-
- 'lib/api_auth/railtie.rb'
69-
7058
# Offense count: 1
7159
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
7260
Style/FileName:
7361
Exclude:
7462
- 'lib/api-auth.rb'
75-
76-
# Offense count: 110
77-
# Cop supports --auto-correct.
78-
# Configuration parameters: SupportedStyles, UseHashRocketsWithSymbolValues.
79-
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
80-
Style/HashSyntax:
81-
EnforcedStyle: hash_rockets
82-
83-
# Offense count: 4
84-
# Cop supports --auto-correct.
85-
# Configuration parameters: PreferredDelimiters.
86-
Style/PercentLiteralDelimiters:
87-
Exclude:
88-
- 'api_auth.gemspec'
89-
90-
# Offense count: 1
91-
# Cop supports --auto-correct.
92-
# Configuration parameters: EnforcedStyle, SupportedStyles.
93-
# SupportedStyles: use_perl_names, use_english_names
94-
Style/SpecialGlobalVars:
95-
Enabled: false
96-
97-
# Offense count: 4
98-
# Cop supports --auto-correct.
99-
Style/UnneededPercentQ:
100-
Exclude:
101-
- 'api_auth.gemspec'
63+
- 'Appraisals'

.travis.yml

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@ language: ruby
22
sudo: false
33
cache: bundler
44
rvm:
5-
- 1.8.7-p374
6-
- 1.9.3
75
- 2.1.9
8-
- 2.2.5
9-
- 2.3.1
6+
- 2.2.6
7+
- 2.3.3
8+
- 2.4.0
109
gemfile:
11-
- gemfiles/rails_23.gemfile
12-
- gemfiles/rails_30.gemfile
13-
- gemfiles/rails_31.gemfile
14-
- gemfiles/rails_32.gemfile
1510
- gemfiles/rails_4.gemfile
1611
- gemfiles/rails_41.gemfile
1712
- gemfiles/rails_42.gemfile
@@ -27,42 +22,10 @@ script:
2722

2823
matrix:
2924
exclude:
30-
- rvm: 1.8.7-p374
31-
gemfile: gemfiles/rails_4.gemfile
32-
- rvm: 1.8.7-p374
33-
gemfile: gemfiles/rails_41.gemfile
34-
- rvm: 1.8.7-p374
35-
gemfile: gemfiles/rails_42.gemfile
36-
- rvm: 1.8.7-p374
37-
gemfile: gemfiles/rails_5.gemfile
38-
- rvm: 1.9.3
39-
gemfile: gemfiles/rails_5.gemfile
40-
- rvm: 2.1.9
41-
gemfile: gemfiles/rails_23.gemfile
42-
- rvm: 2.1.9
43-
gemfile: gemfiles/rails_30.gemfile
44-
- rvm: 2.1.9
45-
gemfile: gemfiles/rails_31.gemfile
4625
- rvm: 2.1.9
4726
gemfile: gemfiles/rails_5.gemfile
48-
- rvm: 2.2.5
49-
gemfile: gemfiles/rails_23.gemfile
50-
- rvm: 2.2.5
51-
gemfile: gemfiles/rails_30.gemfile
52-
- rvm: 2.2.5
53-
gemfile: gemfiles/rails_31.gemfile
54-
- rvm: 2.2.5
55-
gemfile: gemfiles/rails_32.gemfile
56-
- rvm: 2.3.1
57-
gemfile: gemfiles/rails_23.gemfile
58-
- rvm: 2.3.1
59-
gemfile: gemfiles/rails_30.gemfile
60-
- rvm: 2.3.1
61-
gemfile: gemfiles/rails_31.gemfile
62-
- rvm: 2.3.1
63-
gemfile: gemfiles/rails_32.gemfile
6427
include:
65-
- rvm: 2.3.1
28+
- rvm: 2.3.3
6629
gemfile: gemfiles/rails_5.gemfile
6730
env: TEST_SUITE="rubocop lib/ spec/"
6831

Appraisals

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,23 @@
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-5' do
2+
gem 'actionpack', '~> 5.0.2'
3+
gem 'activeresource', '~> 5.0.2'
4+
gem 'activesupport', '~> 5.0.2'
55
end
66

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-42' do
8+
gem 'actionpack', '~> 4.2.0'
9+
gem 'activeresource', '~> 4.0.0'
10+
gem 'activesupport', '~> 4.2.0'
1111
end
1212

13-
appraise "rails-4" do
14-
gem "actionpack", "~> 4.0.4"
15-
gem "activeresource", "~> 4.0.0"
16-
gem "activesupport", "~> 4.0.4"
13+
appraise 'rails-41' do
14+
gem 'actionpack', '~> 4.1.0'
15+
gem 'activeresource', '~> 4.0.0'
16+
gem 'activesupport', '~> 4.1.0'
1717
end
1818

19-
appraise "rails-32" do
20-
gem "actionpack", "~> 3.2.17"
21-
gem "activeresource", "~> 3.2.17"
22-
gem "activesupport", "~> 3.2.17"
23-
gem "httpi", "< 2.3"
24-
gem "i18n", "< 0.7.0"
25-
gem "rack-cache", "< 1.3"
26-
end
27-
28-
appraise "rails-31" do
29-
gem "actionpack", "~> 3.1.0"
30-
gem "activeresource", "~> 3.1.0"
31-
gem "activesupport", "~> 3.1.0"
32-
gem "httpi", "< 2.3"
33-
gem "i18n", "< 0.7.0"
34-
gem "rack-cache", "< 1.3"
35-
end
36-
37-
appraise "rails-30" do
38-
gem "actionpack", "~> 3.0.20"
39-
gem "activeresource", "~> 3.0.20"
40-
gem "activesupport", "~> 3.0.20"
41-
gem "httpi", "< 2.3"
42-
end
43-
44-
appraise "rails-23" do
45-
gem "actionpack", "~> 2.3.2"
46-
gem "activeresource", "~> 2.3.2"
47-
gem "activesupport", "~> 2.3.2"
48-
gem "httpi", "< 2.3"
19+
appraise 'rails-4' do
20+
gem 'actionpack', '~> 4.0.4'
21+
gem 'activeresource', '~> 4.0.0'
22+
gem 'activesupport', '~> 4.0.4'
4923
end

Gemfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
source 'https://rubygems.org'
22
gemspec
33

4-
gem 'rake', '< 11.0', :platforms => :ruby_18
5-
gem 'tins', '< 1.7', :platforms => :ruby_19 # amatch dependency
6-
7-
gem 'rubocop', :platforms => [:ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23]
4+
gem 'rubocop', platforms: %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24]

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
[![Build Status](https://travis-ci.org/mgomes/api_auth.png?branch=master)](https://travis-ci.org/mgomes/api_auth)
44

5-
## IMPORTANT: v2.0.0 is backwards incompatible with the default settings of v1.x to address a security vulnerability. See [CHANGELOG.md](/CHANGELOG.md) for security update information.
6-
75
Logins and passwords are for humans. Communication between applications need to
86
be protected through different means.
97

@@ -51,6 +49,14 @@ minutes in order to avoid replay attacks.
5149
* [HMAC algorithm](http://en.wikipedia.org/wiki/HMAC)
5250
* [RFC 2104 (HMAC)](http://tools.ietf.org/html/rfc2104)
5351

52+
## Requirement
53+
54+
v3.X require Ruby 2.X and if you use Rails at least Rails 4.0.
55+
56+
For older version of Ruby or Rails, please use ApiAuth v2.X.
57+
58+
**IMPORTANT: v2.0.0 is backwards incompatible with the default settings of v1.x to address a security vulnerability. See [CHANGELOG.md](/CHANGELOG.md) for security update information.**
59+
5460
## Install
5561

5662
The gem doesn't have any dependencies outside of having a working OpenSSL

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
1010
spec.pattern = FileList['spec/**/*_spec.rb']
1111
end
1212

13-
task :default => :spec
13+
task default: :spec

api_auth.gemspec

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# -*- encoding: utf-8 -*-
2-
$:.push File.expand_path('../lib', __FILE__)
1+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
32

43
Gem::Specification.new do |s|
5-
s.name = %q{api-auth}
6-
s.summary = %q{Simple HMAC authentication for your APIs}
7-
s.description = %q{Full HMAC auth implementation for use in your gems and Rails apps.}
8-
s.homepage = %q{https://github.com/mgomes/api_auth}
4+
s.name = 'api-auth'
5+
s.summary = 'Simple HMAC authentication for your APIs'
6+
s.description = 'Full HMAC auth implementation for use in your gems and Rails apps.'
7+
s.homepage = 'https://github.com/mgomes/api_auth'
98
s.version = File.read(File.join(File.dirname(__FILE__), 'VERSION'))
109
s.authors = ['Mauricio Gomes']
1110
s.email = '[email protected]'
@@ -14,14 +13,13 @@ Gem::Specification.new do |s|
1413
s.add_development_dependency 'rake'
1514
s.add_development_dependency 'amatch'
1615
s.add_development_dependency 'rspec', '~> 3.4'
17-
s.add_development_dependency 'actionpack', '< 5.0', '> 2.3.2'
18-
s.add_development_dependency 'activesupport', '< 5.0', '> 2.3.2'
16+
s.add_development_dependency 'actionpack', '< 6.0', '> 4.0'
17+
s.add_development_dependency 'activesupport', '< 6.0', '> 4.0'
1918
s.add_development_dependency 'activeresource', '~> 4.0'
2019
s.add_development_dependency 'rest-client', '~> 1.6.0'
2120
s.add_development_dependency 'curb', '~> 0.8.1'
2221
s.add_development_dependency 'httpi'
23-
faraday_version = RUBY_VERSION == '1.8.7' ? '< 0.10' : '>= 0.10'
24-
s.add_development_dependency 'faraday', faraday_version
22+
s.add_development_dependency 'faraday', '>= 0.10'
2523
s.add_development_dependency 'multipart-post', '~> 2.0'
2624

2725
s.files = `git ls-files`.split("\n")

gemfiles/rails_23.gemfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

gemfiles/rails_30.gemfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

gemfiles/rails_31.gemfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

gemfiles/rails_32.gemfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

gemfiles/rails_5.gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
source "https://rubygems.org"
44

5-
gem "actionpack", "~> 5.0.0"
5+
gem "actionpack", "~> 5.0.2"
66
gem "activeresource", "~> 5.0.0", git: 'https://github.com/rails/activeresource.git'
7-
gem "activesupport", "~> 5.0.0"
7+
gem "activesupport", "~> 5.0.2"
88

99
gem "rubocop"
1010

lib/api_auth/base.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# encoding: UTF-8
21
# api-auth is a Ruby gem designed to be used both in your client and server
32
# HTTP-based applications. It implements the same authentication methods (HMAC)
43
# used by Amazon Web Services.
@@ -21,7 +20,7 @@ class << self
2120
#
2221
# secret_key: assigned secret key that is known to both parties
2322
def sign!(request, access_id, secret_key, options = {})
24-
options = { :override_http_method => nil, :digest => 'sha1' }.merge(options)
23+
options = { override_http_method: nil, digest: 'sha1' }.merge(options)
2524
headers = Headers.new(request)
2625
headers.calculate_md5
2726
headers.set_date
@@ -33,7 +32,7 @@ def sign!(request, access_id, secret_key, options = {})
3332
def authentic?(request, secret_key, options = {})
3433
return false if secret_key.nil?
3534

36-
options = { :override_http_method => nil }.merge(options)
35+
options = { override_http_method: nil }.merge(options)
3736

3837
headers = Headers.new(request)
3938

@@ -87,7 +86,7 @@ def signatures_match?(headers, secret_key, options)
8786
digest = match_data[1].nil? ? 'SHA1' : match_data[1].upcase
8887
raise InvalidRequestDigest if !options[:digest].nil? && !options[:digest].casecmp(digest).zero?
8988

90-
options = { :digest => digest }.merge(options)
89+
options = { digest: digest }.merge(options)
9190

9291
header_sig = match_data[3]
9392
calculated_sig = hmac_signature(headers, secret_key, options)

lib/api_auth/helpers.rb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
module ApiAuth
22
module Helpers # :nodoc:
33
def b64_encode(string)
4-
if Base64.respond_to?(:strict_encode64)
5-
Base64.strict_encode64(string)
6-
else
7-
# Fall back to stripping out newlines on Ruby 1.8.
8-
Base64.encode64(string).delete("\n")
9-
end
4+
Base64.strict_encode64(string)
105
end
116

127
def md5_base64digest(string)
13-
if Digest::MD5.respond_to?(:base64digest)
14-
Digest::MD5.base64digest(string)
15-
else
16-
b64_encode(Digest::MD5.digest(string))
17-
end
8+
Digest::MD5.base64digest(string)
189
end
1910

2011
# Capitalizes the keys of a hash

0 commit comments

Comments
 (0)