authlogic 3.4.6 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +33 -0
  4. data/.rubocop_todo.yml +427 -0
  5. data/.travis.yml +24 -3
  6. data/CHANGELOG.md +9 -2
  7. data/CONTRIBUTING.md +40 -1
  8. data/Gemfile +1 -1
  9. data/README.md +295 -0
  10. data/Rakefile +10 -2
  11. data/authlogic.gemspec +6 -5
  12. data/lib/authlogic.rb +2 -2
  13. data/lib/authlogic/acts_as_authentic/base.rb +2 -2
  14. data/lib/authlogic/acts_as_authentic/email.rb +59 -14
  15. data/lib/authlogic/acts_as_authentic/logged_in_status.rb +4 -3
  16. data/lib/authlogic/acts_as_authentic/login.rb +62 -12
  17. data/lib/authlogic/acts_as_authentic/magic_columns.rb +17 -6
  18. data/lib/authlogic/acts_as_authentic/password.rb +107 -53
  19. data/lib/authlogic/acts_as_authentic/persistence_token.rb +10 -9
  20. data/lib/authlogic/acts_as_authentic/restful_authentication.rb +2 -0
  21. data/lib/authlogic/acts_as_authentic/session_maintenance.rb +48 -35
  22. data/lib/authlogic/acts_as_authentic/single_access_token.rb +19 -15
  23. data/lib/authlogic/acts_as_authentic/validations_scope.rb +2 -2
  24. data/lib/authlogic/authenticates_many/association.rb +6 -5
  25. data/lib/authlogic/authenticates_many/base.rb +22 -12
  26. data/lib/authlogic/config.rb +2 -1
  27. data/lib/authlogic/controller_adapters/abstract_adapter.rb +2 -1
  28. data/lib/authlogic/controller_adapters/rack_adapter.rb +3 -4
  29. data/lib/authlogic/controller_adapters/rails_adapter.rb +26 -14
  30. data/lib/authlogic/controller_adapters/sinatra_adapter.rb +1 -1
  31. data/lib/authlogic/crypto_providers/aes256.rb +16 -12
  32. data/lib/authlogic/crypto_providers/bcrypt.rb +10 -4
  33. data/lib/authlogic/crypto_providers/md5.rb +7 -7
  34. data/lib/authlogic/crypto_providers/scrypt.rb +10 -2
  35. data/lib/authlogic/crypto_providers/sha1.rb +3 -3
  36. data/lib/authlogic/crypto_providers/sha256.rb +3 -3
  37. data/lib/authlogic/crypto_providers/sha512.rb +4 -4
  38. data/lib/authlogic/crypto_providers/wordpress.rb +13 -13
  39. data/lib/authlogic/i18n.rb +22 -16
  40. data/lib/authlogic/i18n/translator.rb +1 -1
  41. data/lib/authlogic/random.rb +13 -12
  42. data/lib/authlogic/regex.rb +3 -3
  43. data/lib/authlogic/session/activation.rb +7 -6
  44. data/lib/authlogic/session/active_record_trickery.rb +1 -2
  45. data/lib/authlogic/session/base.rb +7 -6
  46. data/lib/authlogic/session/brute_force_protection.rb +58 -34
  47. data/lib/authlogic/session/callbacks.rb +16 -12
  48. data/lib/authlogic/session/cookies.rb +29 -14
  49. data/lib/authlogic/session/existence.rb +10 -10
  50. data/lib/authlogic/session/foundation.rb +11 -7
  51. data/lib/authlogic/session/http_auth.rb +6 -5
  52. data/lib/authlogic/session/id.rb +5 -4
  53. data/lib/authlogic/session/klass.rb +2 -1
  54. data/lib/authlogic/session/magic_columns.rb +21 -14
  55. data/lib/authlogic/session/magic_states.rb +25 -14
  56. data/lib/authlogic/session/params.rb +41 -26
  57. data/lib/authlogic/session/password.rb +62 -40
  58. data/lib/authlogic/session/perishable_token.rb +3 -2
  59. data/lib/authlogic/session/persistence.rb +3 -3
  60. data/lib/authlogic/session/priority_record.rb +5 -4
  61. data/lib/authlogic/session/scopes.rb +20 -9
  62. data/lib/authlogic/session/session.rb +9 -4
  63. data/lib/authlogic/session/timeout.rb +40 -23
  64. data/lib/authlogic/session/unauthorized_record.rb +6 -5
  65. data/lib/authlogic/session/validation.rb +18 -9
  66. data/lib/authlogic/test_case.rb +2 -2
  67. data/lib/authlogic/test_case/mock_controller.rb +9 -9
  68. data/lib/authlogic/test_case/mock_cookie_jar.rb +2 -2
  69. data/lib/authlogic/test_case/mock_logger.rb +1 -1
  70. data/lib/authlogic/test_case/mock_request.rb +2 -1
  71. data/lib/authlogic/test_case/rails_request_adapter.rb +5 -5
  72. data/test/acts_as_authentic_test/email_test.rb +29 -17
  73. data/test/acts_as_authentic_test/logged_in_status_test.rb +9 -3
  74. data/test/acts_as_authentic_test/login_test.rb +47 -13
  75. data/test/acts_as_authentic_test/magic_columns_test.rb +4 -4
  76. data/test/acts_as_authentic_test/password_test.rb +31 -21
  77. data/test/acts_as_authentic_test/perishable_token_test.rb +15 -15
  78. data/test/acts_as_authentic_test/session_maintenance_test.rb +20 -13
  79. data/test/acts_as_authentic_test/single_access_test.rb +8 -8
  80. data/test/authenticates_many_test.rb +4 -4
  81. data/test/crypto_provider_test/aes256_test.rb +2 -2
  82. data/test/crypto_provider_test/scrypt_test.rb +1 -1
  83. data/test/crypto_provider_test/sha1_test.rb +3 -3
  84. data/test/crypto_provider_test/sha256_test.rb +1 -1
  85. data/test/crypto_provider_test/sha512_test.rb +2 -2
  86. data/test/gemfiles/Gemfile.rails-3.2.x +2 -2
  87. data/test/gemfiles/Gemfile.rails-5.0.x +6 -0
  88. data/test/i18n_test.rb +5 -5
  89. data/test/libs/affiliate.rb +2 -2
  90. data/test/libs/company.rb +1 -1
  91. data/test/libs/employee.rb +2 -2
  92. data/test/libs/employee_session.rb +1 -1
  93. data/test/libs/ldaper.rb +1 -1
  94. data/test/libs/project.rb +1 -1
  95. data/test/random_test.rb +5 -4
  96. data/test/session_test/activation_test.rb +5 -5
  97. data/test/session_test/active_record_trickery_test.rb +7 -5
  98. data/test/session_test/cookies_test.rb +8 -6
  99. data/test/session_test/existence_test.rb +19 -13
  100. data/test/session_test/http_auth_test.rb +0 -3
  101. data/test/session_test/id_test.rb +2 -2
  102. data/test/session_test/klass_test.rb +1 -1
  103. data/test/session_test/magic_columns_test.rb +0 -3
  104. data/test/session_test/magic_states_test.rb +11 -11
  105. data/test/session_test/params_test.rb +10 -10
  106. data/test/session_test/password_test.rb +4 -5
  107. data/test/session_test/perishability_test.rb +3 -3
  108. data/test/session_test/scopes_test.rb +8 -8
  109. data/test/session_test/session_test.rb +5 -4
  110. data/test/session_test/timeout_test.rb +8 -8
  111. data/test/session_test/unauthorized_record_test.rb +2 -2
  112. data/test/session_test/validation_test.rb +3 -3
  113. data/test/test_helper.rb +9 -5
  114. metadata +54 -24
  115. data/README.rdoc +0 -232
@@ -1,18 +1,39 @@
1
1
  language: ruby
2
+
3
+ # cache: bundler
4
+ # We would like to enable travis' bundler cache (cache: bundler) but for some reason
5
+ # travis installs our bundle under the test directory (test/vendor/bundle/*) and, as a
6
+ # result, travis tries to run all of the tests of all of our dependencies!
7
+ # TODO: There's probably a way to configure the bundle path
8
+
9
+ before_install:
10
+ - gem update bundler
11
+
2
12
  rvm:
3
13
  - 1.9.3
4
- - 2.0.0
5
- - 2.1.0
6
- - jruby
14
+ - 2.1.9
15
+ - 2.2.5
16
+ - 2.3.1
7
17
 
8
18
  gemfile:
9
19
  - test/gemfiles/Gemfile.rails-3.2.x
10
20
  - test/gemfiles/Gemfile.rails-4.0.x
11
21
  - test/gemfiles/Gemfile.rails-4.1.x
12
22
  - test/gemfiles/Gemfile.rails-4.2.x
23
+ - test/gemfiles/Gemfile.rails-5.0.x
13
24
 
14
25
  matrix:
15
26
  exclude:
16
27
  - rvm: 1.9.3
17
28
  gemfile: test/gemfiles/Gemfile.rails-4.1.x
29
+ - rvm: 1.9.3
30
+ gemfile: test/gemfiles/Gemfile.rails-5.0.x
31
+ - rvm: 2.1.9
32
+ gemfile: test/gemfiles/Gemfile.rails-5.0.x
33
+ - rvm: 2.2.5
34
+ gemfile: test/gemfiles/Gemfile.rails-3.2.x
35
+ - rvm: 2.3.1
36
+ gemfile: test/gemfiles/Gemfile.rails-3.2.x
18
37
  fast_finish: true
38
+
39
+ sudo: false
@@ -1,9 +1,16 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 3.5.0 2016-08-29
4
+
5
+ * new
6
+ * Rails 5.0 support! Thanks to all reporters and contributors.
4
7
 
5
8
  * changes
6
- * ...
9
+ * increased default minimum password length to 8 (@iainbeeston)
10
+ * bind parameters in where statement for rails 5 support
11
+ * change callback for rails 5 support
12
+ * converts the ActionController::Parameters to a Hash for rails 5 support
13
+ * check last_request_at_threshold even if last_request_at_update_allowed returns true (@rofreg)
7
14
 
8
15
  ## 3.4.6 2015
9
16
 
@@ -1,3 +1,28 @@
1
+ # Contributing to Authlogic
2
+
3
+ ## Issues
4
+
5
+ ### Security Issues
6
+
7
+ **Do not disclose security issues in public.** Instead, please email:
8
+
9
+ ```
10
+ Ben Johnson <bjohnson@binarylogic.com>,
11
+ Tieg Zaharia <tieg.zaharia@gmail.com>
12
+ Jared Beck <jared@jaredbeck.com>
13
+ ```
14
+
15
+ We will review security issues promptly.
16
+
17
+ ### Non-Security Issues
18
+
19
+ Please use github issues for reproducible, minimal bug reports.
20
+
21
+ ### Usage Questions
22
+
23
+ Please use stackoverflow for usage questions.
24
+
25
+ ## Development
1
26
 
2
27
  ### Testing
3
28
 
@@ -5,6 +30,20 @@ Tests can be ran against different versions of Rails like so:
5
30
 
6
31
  ```
7
32
  BUNDLE_GEMFILE=test/gemfiles/Gemfile.rails-3.2.x bundle install
8
- BUNDLE_GEMFILE=test/gemfiles/Gemfile.rails-3.2.x bundle exec rake test
33
+ BUNDLE_GEMFILE=test/gemfiles/Gemfile.rails-3.2.x bundle exec rake
9
34
  ```
10
35
 
36
+ ### Linting
37
+
38
+ Running `rake` also runs a linter, rubocop. Contributions must pass both
39
+ the linter and the tests. The linter can be run on its own.
40
+
41
+ ```
42
+ BUNDLE_GEMFILE=test/gemfiles/Gemfile.rails-3.2.x bundle exec rubocop
43
+ ```
44
+
45
+ To run the tests without linting, use `rake test`.
46
+
47
+ ```
48
+ BUNDLE_GEMFILE=test/gemfiles/Gemfile.rails-3.2.x bundle exec rake test
49
+ ```
data/Gemfile CHANGED
@@ -2,4 +2,4 @@ source "https://rubygems.org"
2
2
  gemspec
3
3
 
4
4
  gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
5
- gem 'sqlite3', :platforms => :ruby
5
+ gem 'sqlite3', :platforms => :ruby
@@ -0,0 +1,295 @@
1
+ # Authlogic
2
+
3
+ **Authlogic supports both rails 3 and 4. For rails 2, see the [rails2 branch](https://github.com/binarylogic/authlogic/tree/rails2).**
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/authlogic.png)](http://badge.fury.io/rb/authlogic)
6
+ [![Build Status](https://travis-ci.org/binarylogic/authlogic.png?branch=master)](https://travis-ci.org/binarylogic/authlogic)
7
+ [![Code Climate](https://codeclimate.com/github/binarylogic/authlogic.png)](https://codeclimate.com/github/binarylogic/authlogic)
8
+
9
+ Authlogic is a clean, simple, and unobtrusive ruby authentication solution.
10
+
11
+ It introduces a new type of model. You can have as many as you want, and name them whatever you want, just like your other models. In this example, we want to authenticate with the User model, which is inferred by the name:
12
+
13
+ ```ruby
14
+ class UserSession < Authlogic::Session::Base
15
+ # specify configuration here, such as:
16
+ # logout_on_timeout true
17
+ # ...many more options in the documentation
18
+ end
19
+ ```
20
+
21
+ In a `UserSessionsController`, login the user by using it just like your other models:
22
+
23
+ ```ruby
24
+ UserSession.create(:login => "bjohnson", :password => "my password", :remember_me => true)
25
+
26
+ session = UserSession.new(:login => "bjohnson", :password => "my password", :remember_me => true)
27
+ session.save
28
+
29
+ # requires the authlogic-oid "add on" gem
30
+ UserSession.create(:openid_identifier => "identifier", :remember_me => true)
31
+
32
+ # skip authentication and log the user in directly, the true means "remember me"
33
+ UserSession.create(my_user_object, true)
34
+ ```
35
+
36
+ The above handles the entire authentication process for you by:
37
+
38
+ 1. authenticating (i.e. **validating** the record)
39
+ 2. sets up the proper session values and cookies to persist the session (i.e. **saving** the record).
40
+
41
+ You can also log out (i.e. **destroying** the session):
42
+
43
+ ``` ruby
44
+ session.destroy
45
+ ```
46
+
47
+ After a session has been created, you can persist it (i.e. **finding** the record) across requests. Thus keeping the user logged in:
48
+
49
+ ``` ruby
50
+ session = UserSession.find
51
+ ```
52
+
53
+ To get all of the nice authentication functionality in your model just do this:
54
+
55
+ ```ruby
56
+ class User < ActiveRecord::Base
57
+ acts_as_authentic do |c|
58
+ c.my_config_option = my_value
59
+ end # the configuration block is optional
60
+ end
61
+ ```
62
+
63
+ This handles validations, etc. It is also "smart" in the sense that it if a login field is present it will use that to authenticate, if not it will look for an email field, etc. This is all configurable, but for 99% of cases that above is all you will need to do.
64
+
65
+ You may specify how passwords are cryptographically hashed (or encrypted) by setting the Authlogic::CryptoProvider option:
66
+
67
+ ``` ruby
68
+ c.crypto_provider = Authlogic::CryptoProviders::BCrypt
69
+ ```
70
+
71
+ You may validate international email addresses by enabling the provided alternate regex:
72
+
73
+ ``` ruby
74
+ c.validates_format_of_email_field_options = {:with => Authlogic::Regex.email_nonascii}
75
+ ```
76
+
77
+ Also, sessions are automatically maintained. You can switch this on and off with configuration, but the following will automatically log a user in after a successful registration:
78
+
79
+ ``` ruby
80
+ User.create(params[:user])
81
+ ```
82
+
83
+ This also updates the session when the user changes his/her password.
84
+
85
+ Authlogic is very flexible, it has a strong public API and a plethora of hooks to allow you to modify behavior and extend it. Check out the helpful links below to dig deeper.
86
+
87
+ ## Upgrading to Authlogic 3.4.0
88
+
89
+ In version 3.4.0, the default crypto_provider was changed from *Sha512* to *SCrypt*.
90
+
91
+ If you never set a crypto_provider and are upgrading, your passwords will break unless you set the original:
92
+
93
+ ``` ruby
94
+ c.crypto_provider = Authlogic::CryptoProviders::Sha512
95
+ ```
96
+
97
+ And if you want to automatically upgrade from *Sha512* to *SCrypt* as users login:
98
+
99
+ ```ruby
100
+ c.transition_from_crypto_providers = [Authlogic::CryptoProviders::Sha512]
101
+ c.crypto_provider = Authlogic::CryptoProviders::SCrypt
102
+ ```
103
+
104
+ ## Helpful links
105
+
106
+ * <b>Documentation:</b> http://rdoc.info/projects/binarylogic/authlogic
107
+ * <b>Repository:</b> http://github.com/binarylogic/authlogic/tree/master
108
+ * <b>Railscasts Screencast:</b> http://railscasts.com/episodes/160-authlogic
109
+ * <b>Example repository with tutorial in README:</b> http://github.com/binarylogic/authlogic_example/tree/master
110
+ * <b>Tutorial: Reset passwords with Authlogic the RESTful way:</b> http://www.binarylogic.com/2008/11/16/tutorial-reset-passwords-with-authlogic
111
+ * <b>Tutorial</b>: Rails Authentication with Authlogic http://www.sitepoint.com/rails-authentication-with-authlogic
112
+ * <b>Issues:</b> http://github.com/binarylogic/authlogic/issues
113
+
114
+ ## Authlogic "add ons"
115
+
116
+ * <b>Authlogic OpenID addon:</b> http://github.com/binarylogic/authlogic_openid
117
+ * <b>Authlogic LDAP addon:</b> http://github.com/binarylogic/authlogic_ldap
118
+ * <b>Authlogic Facebook Connect:</b> http://github.com/kalasjocke/authlogic_facebook_connect
119
+ * <b>Authlogic Facebook Connect (New JS API):</b> http://github.com/studybyte/authlogic_facebook_connect
120
+ * <b>Authlogic Facebook Shim</b> http://github.com/james2m/authlogic_facebook_shim
121
+ * <b>Authlogic OAuth (Twitter):</b> http://github.com/jrallison/authlogic_oauth
122
+ * <b>Authlogic Oauth and OpenID:</b> http://github.com/viatropos/authlogic-connect
123
+ * <b>Authlogic PAM:</b> http://github.com/nbudin/authlogic_pam
124
+ * <b>Authlogic x509:</b> http://github.com/auth-scc/authlogic_x509
125
+
126
+ If you create one of your own, please let me know about it so I can add it to this list. Or just fork the project, add your link, and send me a pull request.
127
+
128
+ ## Documentation explanation
129
+
130
+ You can find anything you want about Authlogic in the [documentation](http://rdoc.info/projects/binarylogic/authlogic), all that you need to do is understand the basic design behind it.
131
+
132
+ That being said, there are 2 models involved during authentication. Your Authlogic model and your ActiveRecord model:
133
+
134
+ 1. <b>Authlogic::Session</b>, your session models that extend Authlogic::Session::Base.
135
+ 2. <b>Authlogic::ActsAsAuthentic</b>, which adds in functionality to your ActiveRecord model when you call acts_as_authentic.
136
+
137
+ Each of the above has its various sub modules that contain common logic. The sub modules are responsible for including *everything* related to it: configuration, class methods, instance methods, etc.
138
+
139
+ For example, if you want to timeout users after a certain period of inactivity, you would look in <b>Authlogic::Session::Timeout</b>. To help you out, I listed the following publicly relevant modules with short descriptions. For the sake of brevity, there are more modules than listed here, the ones not listed are more for internal use, but you can easily read up on them in the [documentation](http://rdoc.info/projects/binarylogic/authlogic).
140
+
141
+ ## Example migration
142
+
143
+ If you want to enable all the features of Authlogic, a migration to create a
144
+ +User+ model, for example, might look like this:
145
+
146
+ ``` ruby
147
+ class CreateUser < ActiveRecord::Migration
148
+ def change
149
+ create_table :users do |t|
150
+ # Authlogic::ActsAsAuthentic::Email
151
+ t.string :email
152
+
153
+ # Authlogic::ActsAsAuthentic::Password
154
+ t.string :crypted_password
155
+ t.string :password_salt
156
+
157
+ # Authlogic::ActsAsAuthentic::PersistenceToken
158
+ t.string :persistence_token
159
+
160
+ # Authlogic::ActsAsAuthentic::SingleAccessToken
161
+ t.string :single_access_token
162
+
163
+ # Authlogic::ActsAsAuthentic::PerishableToken
164
+ t.string :perishable_token
165
+
166
+ # Authlogic::Session::MagicColumns
167
+ t.integer :login_count, default: 0, null: false
168
+ t.integer :failed_login_count, default: 0, null: false
169
+ t.datetime :last_request_at
170
+ t.datetime :current_login_at
171
+ t.datetime :last_login_at
172
+ t.string :current_login_ip
173
+ t.string :last_login_ip
174
+
175
+ # Authlogic::Session::MagicStates
176
+ t.boolean :active, default: false
177
+ t.boolean :approved, default: false
178
+ t.boolean :confirmed, default: false
179
+
180
+ t.timestamps
181
+ end
182
+ end
183
+ end
184
+ ```
185
+
186
+ ## Quick Rails example
187
+
188
+ What if creating sessions worked like an ORM library on the surface...
189
+
190
+ ``` ruby
191
+ UserSession.create(params[:user_session])
192
+ ```
193
+
194
+ What if your user sessions controller could look just like your other controllers...
195
+
196
+ ```ruby
197
+ class UserSessionsController < ApplicationController
198
+ def new
199
+ @user_session = UserSession.new
200
+ end
201
+
202
+ def create
203
+ @user_session = UserSession.new(params[:user_session])
204
+ if @user_session.save
205
+ redirect_to account_url
206
+ else
207
+ render :action => :new
208
+ end
209
+ end
210
+
211
+ def destroy
212
+ current_user_session.destroy
213
+ redirect_to new_user_session_url
214
+ end
215
+ end
216
+ ```
217
+
218
+ As you can see, this fits nicely into the RESTful development pattern. What about the view...
219
+
220
+ ```erb
221
+ <%= form_for @user_session do |f| %>
222
+ <% if @user_session.errors.any? %>
223
+ <div id="error_explanation">
224
+ <h2><%= pluralize(@user_session.errors.count, "error") %> prohibited:</h2>
225
+ <ul>
226
+ <% @user_session.errors.full_messages.each do |msg| %>
227
+ <li><%= msg %></li>
228
+ <% end %>
229
+ </ul>
230
+ </div>
231
+ <% end %>
232
+ <%= f.label :login %><br />
233
+ <%= f.text_field :login %><br />
234
+ <br />
235
+ <%= f.label :password %><br />
236
+ <%= f.password_field :password %><br />
237
+ <br />
238
+ <%= f.submit "Login" %>
239
+ <% end %>
240
+ ```
241
+
242
+ Or how about persisting the session...
243
+
244
+ ```ruby
245
+ class ApplicationController
246
+ helper_method :current_user_session, :current_user
247
+
248
+ private
249
+ def current_user_session
250
+ return @current_user_session if defined?(@current_user_session)
251
+ @current_user_session = UserSession.find
252
+ end
253
+
254
+ def current_user
255
+ return @current_user if defined?(@current_user)
256
+ @current_user = current_user_session && current_user_session.user
257
+ end
258
+ end
259
+ ```
260
+
261
+ ## CSRF Protection
262
+
263
+ Because Authlogic introduces its own methods for storing user sessions, the CSRF (Cross Site Request Forgery) protection that is built into Rails will not work out of the box.
264
+
265
+ No generally applicable mitigation by the authlogic library is possible, because the instance variable you use to store a reference to the user session in `def current_user_session` will not be known to authlogic.
266
+
267
+ You will need to override `ActionController::Base#handle_unverified_request` to do something appropriate to how your app handles user sessions, e.g.:
268
+
269
+ ```ruby
270
+ class ApplicationController < ActionController::Base
271
+ ...
272
+ protected
273
+
274
+ def handle_unverified_request
275
+ # raise an exception
276
+ fail ActionController::InvalidAuthenticityToken
277
+ # or destroy session, redirect
278
+ if current_user_session
279
+ current_user_session.destroy
280
+ end
281
+ redirect_to root_url
282
+ end
283
+ end
284
+ ```
285
+
286
+ ## Testing
287
+
288
+ See [Authlogic::TestCase](https://github.com/binarylogic/authlogic/blob/master/lib/authlogic/test_case.rb)
289
+
290
+ ## Tell me quickly how Authlogic works
291
+
292
+ Interested in how all of this all works? Think about an ActiveRecord model. A database connection must be established before you can use it. In the case of Authlogic, a controller connection must be established before you can use it. It uses that controller connection to modify cookies, the current session, login with HTTP basic, etc. It connects to the controller through a before filter that is automatically set in your controller which lets Authlogic know about the current controller object. Then Authlogic leverages that to do everything, it's a pretty simple design. Nothing crazy going on, Authlogic is just leveraging the tools your framework provides in the controller object.
293
+
294
+
295
+ Copyright (c) 2012 [Ben Johnson of Binary Logic](http://www.binarylogic.com), released under the MIT license
data/Rakefile CHANGED
@@ -7,7 +7,15 @@ require 'rake/testtask'
7
7
  Rake::TestTask.new(:test) do |test|
8
8
  test.libs << 'test'
9
9
  test.pattern = 'test/**/*_test.rb'
10
- test.verbose = true
10
+ test.verbose = false
11
+
12
+ # Set interpreter warning level to 1 (medium). Level 2 produces hundreds of warnings
13
+ # about uninitialized instance variables.
14
+ # TODO: Find a good way to deal with the level 2 warnings.
15
+ test.ruby_opts += ["-W1"]
11
16
  end
12
17
 
13
- task :default => :test
18
+ require "rubocop/rake_task"
19
+ RuboCop::RakeTask.new
20
+
21
+ task :default => [:rubocop, :test]
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "authlogic"
6
- s.version = "3.4.6"
6
+ s.version = "3.5.0"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Ben Johnson"]
9
9
  s.email = ["bjohnson@binarylogic.com"]
@@ -13,15 +13,16 @@ Gem::Specification.new do |s|
13
13
 
14
14
  s.license = 'MIT'
15
15
 
16
- s.add_dependency 'activerecord', '>= 3.2'
17
- s.add_dependency 'activesupport', '>= 3.2'
16
+ s.add_dependency 'activerecord', ['>= 3.2', '< 5.1']
17
+ s.add_dependency 'activesupport', ['>= 3.2', '< 5.1']
18
18
  s.add_dependency 'request_store', '~> 1.0'
19
- s.add_dependency 'scrypt', '>= 1.2', '< 3.0'
19
+ s.add_dependency 'scrypt', '>= 1.2', '< 4.0'
20
20
  s.add_development_dependency 'bcrypt', '~> 3.1'
21
21
  s.add_development_dependency 'timecop', '~> 0.7'
22
+ s.add_development_dependency 'rubocop', '~> 0.41.2'
22
23
 
23
24
  s.files = `git ls-files`.split("\n")
24
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
26
27
  s.require_paths = ["lib"]
27
28
  end