authlogic 4.5.0 → 6.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/lib/authlogic/acts_as_authentic/base.rb +19 -19
  3. data/lib/authlogic/acts_as_authentic/email.rb +3 -170
  4. data/lib/authlogic/acts_as_authentic/logged_in_status.rb +3 -1
  5. data/lib/authlogic/acts_as_authentic/login.rb +7 -174
  6. data/lib/authlogic/acts_as_authentic/magic_columns.rb +7 -4
  7. data/lib/authlogic/acts_as_authentic/password.rb +67 -256
  8. data/lib/authlogic/acts_as_authentic/perishable_token.rb +8 -5
  9. data/lib/authlogic/acts_as_authentic/persistence_token.rb +10 -4
  10. data/lib/authlogic/acts_as_authentic/queries/case_sensitivity.rb +53 -0
  11. data/lib/authlogic/acts_as_authentic/queries/find_with_case.rb +36 -20
  12. data/lib/authlogic/acts_as_authentic/session_maintenance.rb +12 -8
  13. data/lib/authlogic/acts_as_authentic/single_access_token.rb +10 -8
  14. data/lib/authlogic/config.rb +9 -1
  15. data/lib/authlogic/controller_adapters/abstract_adapter.rb +28 -4
  16. data/lib/authlogic/controller_adapters/rack_adapter.rb +2 -0
  17. data/lib/authlogic/controller_adapters/rails_adapter.rb +7 -30
  18. data/lib/authlogic/controller_adapters/sinatra_adapter.rb +6 -0
  19. data/lib/authlogic/cookie_credentials.rb +63 -0
  20. data/lib/authlogic/crypto_providers/bcrypt.rb +3 -3
  21. data/lib/authlogic/crypto_providers/md5/v2.rb +35 -0
  22. data/lib/authlogic/crypto_providers/md5.rb +6 -6
  23. data/lib/authlogic/crypto_providers/scrypt.rb +2 -0
  24. data/lib/authlogic/crypto_providers/sha1/v2.rb +41 -0
  25. data/lib/authlogic/crypto_providers/sha1.rb +7 -6
  26. data/lib/authlogic/crypto_providers/sha256/v2.rb +58 -0
  27. data/lib/authlogic/crypto_providers/sha256.rb +5 -0
  28. data/lib/authlogic/crypto_providers/sha512/v2.rb +39 -0
  29. data/lib/authlogic/crypto_providers/sha512.rb +9 -5
  30. data/lib/authlogic/crypto_providers.rb +5 -20
  31. data/lib/authlogic/errors.rb +50 -0
  32. data/lib/authlogic/i18n/translator.rb +4 -1
  33. data/lib/authlogic/i18n.rb +3 -1
  34. data/lib/authlogic/random.rb +2 -0
  35. data/lib/authlogic/session/base.rb +2197 -39
  36. data/lib/authlogic/session/magic_column/assigns_last_request_at.rb +46 -0
  37. data/lib/authlogic/test_case/mock_api_controller.rb +52 -0
  38. data/lib/authlogic/test_case/mock_controller.rb +3 -1
  39. data/lib/authlogic/test_case/mock_cookie_jar.rb +32 -6
  40. data/lib/authlogic/test_case/mock_logger.rb +2 -0
  41. data/lib/authlogic/test_case/mock_request.rb +12 -0
  42. data/lib/authlogic/test_case/rails_request_adapter.rb +9 -1
  43. data/lib/authlogic/test_case.rb +5 -0
  44. data/lib/authlogic/version.rb +2 -1
  45. data/lib/authlogic.rb +5 -28
  46. metadata +175 -200
  47. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -28
  48. data/.github/ISSUE_TEMPLATE/feature_proposal.md +0 -32
  49. data/.github/triage.md +0 -86
  50. data/.gitignore +0 -15
  51. data/.rubocop.yml +0 -133
  52. data/.rubocop_todo.yml +0 -74
  53. data/.travis.yml +0 -24
  54. data/CHANGELOG.md +0 -348
  55. data/CONTRIBUTING.md +0 -91
  56. data/Gemfile +0 -6
  57. data/LICENSE +0 -20
  58. data/README.md +0 -448
  59. data/Rakefile +0 -21
  60. data/UPGRADING.md +0 -22
  61. data/authlogic.gemspec +0 -40
  62. data/doc/use_normal_rails_validation.md +0 -82
  63. data/gemfiles/Gemfile.rails-4.2.x +0 -6
  64. data/gemfiles/Gemfile.rails-5.1.x +0 -6
  65. data/gemfiles/Gemfile.rails-5.2.x +0 -6
  66. data/lib/authlogic/acts_as_authentic/restful_authentication.rb +0 -106
  67. data/lib/authlogic/acts_as_authentic/validations_scope.rb +0 -35
  68. data/lib/authlogic/authenticates_many/association.rb +0 -50
  69. data/lib/authlogic/authenticates_many/base.rb +0 -81
  70. data/lib/authlogic/crypto_providers/aes256.rb +0 -71
  71. data/lib/authlogic/crypto_providers/wordpress.rb +0 -72
  72. data/lib/authlogic/regex.rb +0 -79
  73. data/lib/authlogic/session/activation.rb +0 -73
  74. data/lib/authlogic/session/active_record_trickery.rb +0 -65
  75. data/lib/authlogic/session/brute_force_protection.rb +0 -127
  76. data/lib/authlogic/session/callbacks.rb +0 -153
  77. data/lib/authlogic/session/cookies.rb +0 -329
  78. data/lib/authlogic/session/existence.rb +0 -103
  79. data/lib/authlogic/session/foundation.rb +0 -105
  80. data/lib/authlogic/session/http_auth.rb +0 -107
  81. data/lib/authlogic/session/id.rb +0 -53
  82. data/lib/authlogic/session/klass.rb +0 -73
  83. data/lib/authlogic/session/magic_columns.rb +0 -119
  84. data/lib/authlogic/session/magic_states.rb +0 -82
  85. data/lib/authlogic/session/params.rb +0 -130
  86. data/lib/authlogic/session/password.rb +0 -318
  87. data/lib/authlogic/session/perishable_token.rb +0 -24
  88. data/lib/authlogic/session/persistence.rb +0 -77
  89. data/lib/authlogic/session/priority_record.rb +0 -38
  90. data/lib/authlogic/session/scopes.rb +0 -138
  91. data/lib/authlogic/session/session.rb +0 -77
  92. data/lib/authlogic/session/timeout.rb +0 -103
  93. data/lib/authlogic/session/unauthorized_record.rb +0 -56
  94. data/lib/authlogic/session/validation.rb +0 -93
  95. data/test/acts_as_authentic_test/base_test.rb +0 -27
  96. data/test/acts_as_authentic_test/email_test.rb +0 -241
  97. data/test/acts_as_authentic_test/logged_in_status_test.rb +0 -64
  98. data/test/acts_as_authentic_test/login_test.rb +0 -153
  99. data/test/acts_as_authentic_test/magic_columns_test.rb +0 -29
  100. data/test/acts_as_authentic_test/password_test.rb +0 -263
  101. data/test/acts_as_authentic_test/perishable_token_test.rb +0 -98
  102. data/test/acts_as_authentic_test/persistence_token_test.rb +0 -62
  103. data/test/acts_as_authentic_test/restful_authentication_test.rb +0 -48
  104. data/test/acts_as_authentic_test/session_maintenance_test.rb +0 -150
  105. data/test/acts_as_authentic_test/single_access_test.rb +0 -46
  106. data/test/adapter_test.rb +0 -23
  107. data/test/authenticates_many_test.rb +0 -33
  108. data/test/config_test.rb +0 -38
  109. data/test/crypto_provider_test/aes256_test.rb +0 -16
  110. data/test/crypto_provider_test/bcrypt_test.rb +0 -16
  111. data/test/crypto_provider_test/scrypt_test.rb +0 -16
  112. data/test/crypto_provider_test/sha1_test.rb +0 -25
  113. data/test/crypto_provider_test/sha256_test.rb +0 -16
  114. data/test/crypto_provider_test/sha512_test.rb +0 -16
  115. data/test/crypto_provider_test/wordpress_test.rb +0 -26
  116. data/test/fixtures/companies.yml +0 -5
  117. data/test/fixtures/employees.yml +0 -17
  118. data/test/fixtures/projects.yml +0 -3
  119. data/test/fixtures/users.yml +0 -41
  120. data/test/i18n/lol.yml +0 -4
  121. data/test/i18n_test.rb +0 -35
  122. data/test/libs/affiliate.rb +0 -9
  123. data/test/libs/company.rb +0 -8
  124. data/test/libs/employee.rb +0 -9
  125. data/test/libs/employee_session.rb +0 -4
  126. data/test/libs/ldaper.rb +0 -5
  127. data/test/libs/project.rb +0 -5
  128. data/test/libs/user.rb +0 -9
  129. data/test/libs/user_session.rb +0 -27
  130. data/test/random_test.rb +0 -15
  131. data/test/session_test/activation_test.rb +0 -45
  132. data/test/session_test/active_record_trickery_test.rb +0 -78
  133. data/test/session_test/brute_force_protection_test.rb +0 -110
  134. data/test/session_test/callbacks_test.rb +0 -42
  135. data/test/session_test/cookies_test.rb +0 -244
  136. data/test/session_test/credentials_test.rb +0 -0
  137. data/test/session_test/existence_test.rb +0 -88
  138. data/test/session_test/foundation_test.rb +0 -24
  139. data/test/session_test/http_auth_test.rb +0 -60
  140. data/test/session_test/id_test.rb +0 -19
  141. data/test/session_test/klass_test.rb +0 -42
  142. data/test/session_test/magic_columns_test.rb +0 -62
  143. data/test/session_test/magic_states_test.rb +0 -60
  144. data/test/session_test/params_test.rb +0 -61
  145. data/test/session_test/password_test.rb +0 -107
  146. data/test/session_test/perishability_test.rb +0 -17
  147. data/test/session_test/persistence_test.rb +0 -35
  148. data/test/session_test/scopes_test.rb +0 -68
  149. data/test/session_test/session_test.rb +0 -80
  150. data/test/session_test/timeout_test.rb +0 -84
  151. data/test/session_test/unauthorized_record_test.rb +0 -15
  152. data/test/session_test/validation_test.rb +0 -25
  153. data/test/test_helper.rb +0 -272
data/README.md DELETED
@@ -1,448 +0,0 @@
1
- # Authlogic
2
-
3
- A clean, simple, and unobtrusive ruby authentication solution.
4
-
5
- [![Gem Version][5]][6] [![Build Status][1]][2] [![Code Climate][7]][8] [![Dependency Status][3]][4]
6
-
7
- ## Sponsors
8
-
9
- [![Timber Logging](http://res.cloudinary.com/timber/image/upload/v1490556810/pricing/sponsorship.png)](https://timber.io?utm_source=github&utm_medium=authlogic)
10
-
11
- [Tail Authlogic users](https://timber.io/docs/app/console/tail-a-user) in your logs!
12
-
13
- ## Documentation
14
-
15
- | Version | Documentation |
16
- | ----------- | ------------- |
17
- | Unreleased | https://github.com/binarylogic/authlogic/blob/master/README.md |
18
- | 4.5.0 | https://github.com/binarylogic/authlogic/blob/v4.5.0/README.md |
19
- | 3.7.0 | https://github.com/binarylogic/authlogic/blob/v3.7.0/README.md |
20
- | 2.1.11 | https://github.com/binarylogic/authlogic/blob/v2.1.11/README.rdoc |
21
- | 1.4.3 | https://github.com/binarylogic/authlogic/blob/v1.4.3/README.rdoc |
22
-
23
- ## Table of Contents
24
-
25
- - [1. Introduction](#1-introduction)
26
- - [1.a. Compatibility](#1a-compatibility)
27
- - [1.b. Overview](#1b-overview)
28
- - [1.c. Reference Documentation](#1c-reference-documentation)
29
- - [2. Rails](#2-rails)
30
- - [2.a. The users table](#2a-the-users-table)
31
- - [2.b. Controller](#2b-controller)
32
- - [2.c. View](#2c-view)
33
- - [2.d. CSRF Protection](#2d-csrf-protection)
34
- - [3. Testing](#3-testing)
35
- - [4. Helpful links](#4-helpful-links)
36
- - [5. Add-ons](#5-add-ons)
37
- - [6. Internals](#6-internals)
38
-
39
- ## 1. Introduction
40
-
41
- ### 1.a. Compatibility
42
-
43
- | Version | branch | ruby | activerecord |
44
- | ------- | ------------ | -------- | ------------- |
45
- | 4.4 | 4-4-stable | >= 2.3.0 | >= 4.2, < 5.3 |
46
- | 4.3 | 4-3-stable | >= 2.3.0 | >= 4.2, < 5.3 |
47
- | 4.2 | 4-2-stable | >= 2.2.0 | >= 4.2, < 5.3 |
48
- | 3 | 3-stable | >= 1.9.3 | >= 3.2, < 5.2 |
49
- | 2 | rails2 | >= 1.9.3 | ~> 2.3.0 |
50
- | 1 | ? | ? | ? |
51
-
52
- Under SemVer, [changes to dependencies][10] do not require a major release.
53
-
54
- ### 1.b. Overview
55
-
56
- Authlogic introduces a new type of model. You can have as many as you want, and
57
- name them whatever you want, just like your other models. In this example, we
58
- want to authenticate with our `User` model, which is inferred from the name:
59
-
60
- ```ruby
61
- class UserSession < Authlogic::Session::Base
62
- # specify configuration here, such as:
63
- # logout_on_timeout true
64
- # ...many more options in the documentation
65
- end
66
- ```
67
-
68
- In a `UserSessionsController`, login the user by using it just like your other models:
69
-
70
- ```ruby
71
- UserSession.create(:login => "bjohnson", :password => "my password", :remember_me => true)
72
-
73
- session = UserSession.new(:login => "bjohnson", :password => "my password", :remember_me => true)
74
- session.save
75
-
76
- # requires the authlogic-oid "add on" gem
77
- UserSession.create(:openid_identifier => "identifier", :remember_me => true)
78
-
79
- # skip authentication and log the user in directly, the true means "remember me"
80
- UserSession.create(my_user_object, true)
81
- ```
82
-
83
- The above handles the entire authentication process for you by:
84
-
85
- 1. authenticating (i.e. **validating** the record)
86
- 2. sets up the proper session values and cookies to persist the session (i.e. **saving** the record).
87
-
88
- You can also log out (i.e. **destroying** the session):
89
-
90
- ``` ruby
91
- session.destroy
92
- ```
93
-
94
- After a session has been created, you can persist it (i.e. **finding** the
95
- record) across requests. Thus keeping the user logged in:
96
-
97
- ``` ruby
98
- session = UserSession.find
99
- ```
100
-
101
- To get all of the nice authentication functionality in your model just do this:
102
-
103
- ```ruby
104
- class User < ApplicationRecord
105
- acts_as_authentic do |c|
106
- c.my_config_option = my_value
107
- end # the configuration block is optional
108
- end
109
- ```
110
-
111
- This handles validations, etc. It is also "smart" in the sense that it if a
112
- login field is present it will use that to authenticate, if not it will look for
113
- an email field, etc. This is all configurable, but for 99% of cases that above
114
- is all you will need to do.
115
-
116
- You may specify how passwords are cryptographically hashed (or encrypted) by
117
- setting the Authlogic::CryptoProvider option:
118
-
119
- ``` ruby
120
- c.crypto_provider = Authlogic::CryptoProviders::BCrypt
121
- ```
122
-
123
- You may validate international email addresses by enabling the provided alternate regex:
124
-
125
- ``` ruby
126
- c.validates_format_of_email_field_options = {:with => Authlogic::Regex.email_nonascii}
127
- ```
128
-
129
- Also, sessions are automatically maintained. You can switch this on and off with
130
- configuration, but the following will automatically log a user in after a
131
- successful registration:
132
-
133
- ``` ruby
134
- User.create(params[:user])
135
- ```
136
-
137
- You can switch this on and off with the following configuration:
138
-
139
- ```ruby
140
- class User < ApplicationRecord
141
- acts_as_authentic do |c|
142
- c.log_in_after_create = false
143
- end # the configuration block is optional
144
- end
145
- ```
146
-
147
- Authlogic also updates the session when the user changes his/her password. You can also switch this on and off with the following configuration:
148
-
149
- ```ruby
150
- class User < ApplicationRecord
151
- acts_as_authentic do |c|
152
- c.log_in_after_password_change = false
153
- end # the configuration block is optional
154
- end
155
- ```
156
-
157
- Authlogic is very flexible, it has a strong public API and a plethora of hooks
158
- to allow you to modify behavior and extend it. Check out the helpful links below
159
- to dig deeper.
160
-
161
- ### 1.c. Reference Documentation
162
-
163
- This README is just an introduction, but we also have [reference
164
- documentation](http://www.rubydoc.info/github/binarylogic/authlogic).
165
-
166
- **To use the reference documentation, you must understand how Authlogic's
167
- code is organized.** There are 2 models, your Authlogic model and your
168
- ActiveRecord model:
169
-
170
- 1. **Authlogic::Session**, your session models that
171
- extend `Authlogic::Session::Base`.
172
- 2. **Authlogic::ActsAsAuthentic**, which adds in functionality to your
173
- ActiveRecord model when you call `acts_as_authentic`.
174
-
175
- Each of the above has various modules that are organized by topic: passwords,
176
- cookies, etc. For example, if you want to timeout users after a certain period
177
- of inactivity, you would look in `Authlogic::Session::Timeout`.
178
-
179
- ## 2. Rails
180
-
181
- Let's walk through a typical rails setup.
182
-
183
- ### 2.a. The users table
184
-
185
- If you want to enable all the features of Authlogic, a migration to create a
186
- `User` model might look like this:
187
-
188
- ``` ruby
189
- class CreateUser < ActiveRecord::Migration
190
- def change
191
- create_table :users do |t|
192
- # Authlogic::ActsAsAuthentic::Email
193
- t.string :email
194
-
195
- # Authlogic::ActsAsAuthentic::Password
196
- t.string :crypted_password
197
- t.string :password_salt
198
-
199
- # Authlogic::ActsAsAuthentic::PersistenceToken
200
- t.string :persistence_token
201
- t.index :persistence_token, unique: true
202
-
203
- # Authlogic::ActsAsAuthentic::SingleAccessToken
204
- t.string :single_access_token
205
- t.index :single_access_token, unique: true
206
-
207
- # Authlogic::ActsAsAuthentic::PerishableToken
208
- t.string :perishable_token
209
- t.index :perishable_token, unique: true
210
-
211
- # Authlogic::Session::MagicColumns
212
- t.integer :login_count, default: 0, null: false
213
- t.integer :failed_login_count, default: 0, null: false
214
- t.datetime :last_request_at
215
- t.datetime :current_login_at
216
- t.datetime :last_login_at
217
- t.string :current_login_ip
218
- t.string :last_login_ip
219
-
220
- # Authlogic::Session::MagicStates
221
- t.boolean :active, default: false
222
- t.boolean :approved, default: false
223
- t.boolean :confirmed, default: false
224
-
225
- t.timestamps
226
- end
227
- end
228
- end
229
- ```
230
-
231
- In the `User` model,
232
-
233
- ```ruby
234
- class User < ApplicationRecord
235
- acts_as_authentic
236
-
237
- # Validate email, login, and password as you see fit.
238
- #
239
- # Authlogic < 5 added these validation for you, making them a little awkward
240
- # to change. In 4.4.0, those automatic validations were deprecated. See
241
- # https://github.com/binarylogic/authlogic/blob/master/doc/use_normal_rails_validation.md
242
- validates :email,
243
- format: {
244
- with: ::Authlogic::Regex::EMAIL,
245
- message: "should look like an email address."
246
- },
247
- length: { maximum: 100 },
248
- uniqueness: {
249
- case_sensitive: false,
250
- if: :email_changed?
251
- }
252
-
253
- validates :login,
254
- format: {
255
- with: ::Authlogic::Regex::LOGIN,
256
- message: "should use only letters, numbers, spaces, and .-_@+ please."
257
- },
258
- length: { within: 3..100 },
259
- uniqueness: {
260
- case_sensitive: false,
261
- if: :login_changed?
262
- }
263
-
264
- validates :password,
265
- confirmation: { if: :require_password? },
266
- length: {
267
- minimum: 8,
268
- if: :require_password?
269
- }
270
- validates :password_confirmation,
271
- length: {
272
- minimum: 8,
273
- if: :require_password?
274
- }
275
- end
276
- ```
277
-
278
- ### 2.b. Controller
279
-
280
- Your sessions controller will look just like your other controllers.
281
-
282
- ```ruby
283
- class UserSessionsController < ApplicationController
284
- def new
285
- @user_session = UserSession.new
286
- end
287
-
288
- def create
289
- @user_session = UserSession.new(user_session_params)
290
- if @user_session.save
291
- redirect_to account_url
292
- else
293
- render :action => :new
294
- end
295
- end
296
-
297
- def destroy
298
- current_user_session.destroy
299
- redirect_to new_user_session_url
300
- end
301
-
302
- private
303
-
304
- def user_session_params
305
- params.require(:user_session).permit(:email, :password, :remember_me)
306
- end
307
- end
308
- ```
309
-
310
- As you can see, this fits nicely into the [conventional controller methods][9].
311
-
312
- #### 2.b.1. Helper Methods
313
-
314
- ```ruby
315
- class ApplicationController
316
- helper_method :current_user_session, :current_user
317
-
318
- private
319
- def current_user_session
320
- return @current_user_session if defined?(@current_user_session)
321
- @current_user_session = UserSession.find
322
- end
323
-
324
- def current_user
325
- return @current_user if defined?(@current_user)
326
- @current_user = current_user_session && current_user_session.user
327
- end
328
- end
329
- ```
330
-
331
- ### 2.c. View
332
-
333
- ```erb
334
- <%= form_for @user_session do |f| %>
335
- <% if @user_session.errors.any? %>
336
- <div id="error_explanation">
337
- <h2><%= pluralize(@user_session.errors.count, "error") %> prohibited:</h2>
338
- <ul>
339
- <% @user_session.errors.full_messages.each do |msg| %>
340
- <li><%= msg %></li>
341
- <% end %>
342
- </ul>
343
- </div>
344
- <% end %>
345
- <%= f.label :login %><br />
346
- <%= f.text_field :login %><br />
347
- <br />
348
- <%= f.label :password %><br />
349
- <%= f.password_field :password %><br />
350
- <br />
351
- <%= f.submit "Login" %>
352
- <% end %>
353
- ```
354
-
355
- ### 2.d. CSRF Protection
356
-
357
- Because Authlogic introduces its own methods for storing user sessions, the CSRF
358
- (Cross Site Request Forgery) protection that is built into Rails will not work
359
- out of the box.
360
-
361
- No generally applicable mitigation by the authlogic library is possible, because
362
- the instance variable you use to store a reference to the user session in `def
363
- current_user_session` will not be known to authlogic.
364
-
365
- You will need to override `ActionController::Base#handle_unverified_request` to
366
- do something appropriate to how your app handles user sessions, e.g.:
367
-
368
- ```ruby
369
- class ApplicationController < ActionController::Base
370
- ...
371
- protected
372
-
373
- def handle_unverified_request
374
- # raise an exception
375
- fail ActionController::InvalidAuthenticityToken
376
- # or destroy session, redirect
377
- if current_user_session
378
- current_user_session.destroy
379
- end
380
- redirect_to root_url
381
- end
382
- end
383
- ```
384
-
385
- ### 2.e SameSite Cookie Attribute
386
- The SameSite attribute tells browsers when and how to fire cookies in first- or third-party situations. SameSite is used by a variety of browsers to identify whether or not to allow a cookie to be accessed.
387
-
388
- Up until recently, the standard default value when SameSite was not explicitly defined was to allow cookies in both first- and third-party contexts. However, starting with Chrome 80+, the SameSite attribute will not default to Lax behavior meaning cookies will only be permitted in first-party contexts.
389
-
390
- Authlogic can allow you to explicitly set the value of SameSite to one of: Lax, Strict, or None. Note that when setting SameSite to None, the `secure` flag must also be set (secure is the default in Authlogic).
391
-
392
- Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#SameSite
393
-
394
- ## 3. Testing
395
-
396
- See [Authlogic::TestCase](https://github.com/binarylogic/authlogic/blob/master/lib/authlogic/test_case.rb)
397
-
398
- ## 4. Helpful links
399
-
400
- * <b>API Reference:</b> http://www.rubydoc.info/github/binarylogic/authlogic
401
- * <b>Repository:</b> https://github.com/binarylogic/authlogic/tree/master
402
- * <b>Railscasts Screencast:</b> http://railscasts.com/episodes/160-authlogic
403
- * <b>Example repository with tutorial in README:</b> https://github.com/binarylogic/authlogic_example/tree/master
404
- * <b>Tutorial</b>: Rails Authentication with Authlogic https://www.sitepoint.com/rails-authentication-with-authlogic
405
- * <b>Issues:</b> https://github.com/binarylogic/authlogic/issues
406
- * <b>Chrome is not logging out on browser close</b> https://productforums.google.com/forum/#!topic/chrome/9l-gKYIUg50/discussion
407
-
408
- ## 5. Add-ons
409
-
410
- * <b>Authlogic OpenID addon:</b> https://github.com/binarylogic/authlogic_openid
411
- * <b>Authlogic LDAP addon:</b> https://github.com/binarylogic/authlogic_ldap
412
- * <b>Authlogic Facebook Connect:</b> https://github.com/kalasjocke/authlogic-facebook-connect
413
- * <b>Authlogic Facebook Connect (New JS API):</b> https://github.com/studybyte/authlogic_facebook_connect
414
- * <b>Authlogic Facebook Shim</b> https://github.com/james2m/authlogic_facebook_shim
415
- * <b>Authlogic OAuth (Twitter):</b> https://github.com/jrallison/authlogic_oauth
416
- * <b>Authlogic Oauth and OpenID:</b> https://github.com/lancejpollard/authlogic-connect
417
- * <b>Authlogic PAM:</b> https://github.com/nbudin/authlogic_pam
418
- * <b>Authlogic x509:</b> https://github.com/auth-scc/authlogic_x509
419
-
420
- If you create one of your own, please let us know about it so we can add it to
421
- this list. Or just fork the project, add your link, and send us a pull request.
422
-
423
- ## 6. Internals
424
-
425
- Interested in how all of this all works? Think about an ActiveRecord model. A
426
- database connection must be established before you can use it. In the case of
427
- Authlogic, a controller connection must be established before you can use it. It
428
- uses that controller connection to modify cookies, the current session, login
429
- with HTTP basic, etc. It connects to the controller through a before filter that
430
- is automatically set in your controller which lets Authlogic know about the
431
- current controller object. Then Authlogic leverages that to do everything, it's
432
- a pretty simple design. Nothing crazy going on, Authlogic is just leveraging the
433
- tools your framework provides in the controller object.
434
-
435
- ## Intellectual Property
436
-
437
- Copyright (c) 2012 Ben Johnson of Binary Logic, released under the MIT license
438
-
439
- [1]: https://api.travis-ci.org/binarylogic/authlogic.svg?branch=master
440
- [2]: https://travis-ci.org/binarylogic/authlogic
441
- [3]: https://gemnasium.com/badges/github.com/binarylogic/authlogic.svg
442
- [4]: https://gemnasium.com/binarylogic/authlogic
443
- [5]: https://badge.fury.io/rb/authlogic.png
444
- [6]: http://badge.fury.io/rb/authlogic
445
- [7]: https://codeclimate.com/github/binarylogic/authlogic.png
446
- [8]: https://codeclimate.com/github/binarylogic/authlogic
447
- [9]: http://guides.rubyonrails.org/routing.html#resource-routing-the-rails-default
448
- [10]: https://semver.org/spec/v2.0.0.html#what-should-i-do-if-i-update-my-own-dependencies-without-changing-the-public-api
data/Rakefile DELETED
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubygems"
4
- require "bundler"
5
-
6
- Bundler.setup
7
-
8
- require "rake/testtask"
9
- Rake::TestTask.new(:test) do |test|
10
- test.libs << "test"
11
- test.pattern = "test/**/*_test.rb"
12
- test.verbose = false
13
-
14
- # Set interpreter warning level to 2 (verbose)
15
- test.ruby_opts += ["-W2"]
16
- end
17
-
18
- require "rubocop/rake_task"
19
- RuboCop::RakeTask.new
20
-
21
- task default: %i[rubocop test]
data/UPGRADING.md DELETED
@@ -1,22 +0,0 @@
1
- # Upgrading Authlogic
2
-
3
- Supplemental instructions to complement CHANGELOG.md.
4
-
5
- ## 3.4.0
6
-
7
- In version 3.4.0, released 2014-03-03, the default crypto_provider was changed
8
- from *Sha512* to *SCrypt*.
9
-
10
- If you never set a crypto_provider and are upgrading, your passwords will break
11
- unless you specify `Sha512`.
12
-
13
- ``` ruby
14
- c.crypto_provider = Authlogic::CryptoProviders::Sha512
15
- ```
16
-
17
- And if you want to automatically upgrade from *Sha512* to *SCrypt* as users login:
18
-
19
- ```ruby
20
- c.transition_from_crypto_providers = [Authlogic::CryptoProviders::Sha512]
21
- c.crypto_provider = Authlogic::CryptoProviders::SCrypt
22
- ```
data/authlogic.gemspec DELETED
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "English"
4
- $LOAD_PATH.push File.expand_path("lib", __dir__)
5
- require "authlogic/version"
6
-
7
- ::Gem::Specification.new do |s|
8
- s.name = "authlogic"
9
- s.version = ::Authlogic.gem_version.to_s
10
- s.platform = ::Gem::Platform::RUBY
11
- s.authors = [
12
- "Ben Johnson",
13
- "Tieg Zaharia",
14
- "Jared Beck"
15
- ]
16
- s.email = [
17
- "bjohnson@binarylogic.com",
18
- "tieg.zaharia@gmail.com",
19
- "jared@jaredbeck.com"
20
- ]
21
- s.homepage = "http://github.com/binarylogic/authlogic"
22
- s.summary = "A clean, simple, and unobtrusive ruby authentication solution."
23
- s.license = "MIT"
24
-
25
- s.required_ruby_version = ">= 2.3.0"
26
- s.add_dependency "activerecord", [">= 4.2", "< 5.3"]
27
- s.add_dependency "activesupport", [">= 4.2", "< 5.3"]
28
- s.add_dependency "request_store", "~> 1.0"
29
- s.add_dependency "scrypt", ">= 1.2", "< 4.0"
30
- s.add_development_dependency "bcrypt", "~> 3.1"
31
- s.add_development_dependency "byebug", "~> 10.0"
32
- s.add_development_dependency "minitest-reporters", "~> 1.3"
33
- s.add_development_dependency "rubocop", "~> 0.58.1"
34
- s.add_development_dependency "timecop", "~> 0.7"
35
-
36
- s.files = `git ls-files`.split("\n")
37
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
38
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
39
- s.require_paths = ["lib"]
40
- end
@@ -1,82 +0,0 @@
1
- # Use Normal ActiveRecord Validation
2
-
3
- In Authlogic 4.4.0, [we deprecated][1] the features of Authlogic related to
4
- validating email, login, and password. In 5.0.0 these features will be dropped.
5
- Use normal ActiveRecord validations instead.
6
-
7
- ## Instructions
8
-
9
- First, disable the deprecated Authlogic validations:
10
-
11
- acts_as_authentic do |c|
12
- c.validate_email_field = false
13
- c.validate_login_field = false
14
- c.validate_password_field = false
15
- end
16
-
17
- Then, use normal ActiveRecord validations instead. For example, instead of
18
- the Authlogic method validates_length_of_email_field_options, use
19
-
20
- validates :email, length: { ... }
21
-
22
- It might be a good idea to replace these one field at a time, ie. email,
23
- then login, then password; one field per commit.
24
-
25
- ## Default Values
26
-
27
- The following validations represent the Authlogic < 5 defaults. Merge these
28
- defaults with any settings you may have overwritten.
29
-
30
- ```
31
- validates :email,
32
- format: {
33
- with: ::Authlogic::Regex::EMAIL,
34
- message: proc {
35
- ::Authlogic::I18n.t(
36
- "error_messages.email_invalid",
37
- default: "should look like an email address."
38
- )
39
- }
40
- },
41
- length: { maximum: 100 },
42
- uniqueness: {
43
- case_sensitive: false,
44
- if: :email_changed?
45
- }
46
-
47
- validates :login,
48
- format: {
49
- with: ::Authlogic::Regex::LOGIN,
50
- message: proc {
51
- ::Authlogic::I18n.t(
52
- "error_messages.login_invalid",
53
- default: "should use only letters, numbers, spaces, and .-_@+ please."
54
- )
55
- }
56
- },
57
- length: { within: 3..100 },
58
- uniqueness: {
59
- case_sensitive: false,
60
- if: :login_changed?
61
- }
62
-
63
- validates :password,
64
- confirmation: { if: :require_password? },
65
- length: {
66
- minimum: 8,
67
- if: :require_password?
68
- }
69
- validates :password_confirmation,
70
- length: {
71
- minimum: 8,
72
- if: :require_password?
73
- }
74
- ```
75
-
76
- ## Motivation
77
-
78
- The deprecated features save people some time in the begginning, when setting up
79
- Authlogic. But, later in the life of a project, when these settings need to
80
- change, it is obscure compared to normal ActiveRecord validations.
81
-
82
- [1]: https://github.com/binarylogic/authlogic/pull/623
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => ".."
3
-
4
- gem "activerecord", "~> 4.2.8.rc1"
5
- gem "activesupport", "~> 4.2.8.rc1"
6
- gem "sqlite3", "~> 1.3.6", platforms: :ruby
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => ".."
3
-
4
- gem "activerecord", "~> 5.1.0"
5
- gem "activesupport", "~> 5.1.0"
6
- gem "sqlite3", "~> 1.3.6", platforms: :ruby
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec :path => ".."
3
-
4
- gem "activerecord", "~> 5.2.x"
5
- gem "activesupport", "~> 5.2.x"
6
- gem "sqlite3", "~> 1.3.6", platforms: :ruby