devbootsrap 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/devbootsrap/version.rb +1 -1
- data/lib/devbootsrap.rb +496 -2
- data/lib/devise/version.rb +3 -3
- data/lib/devise.rb +491 -491
- metadata +1 -1
data/lib/devise.rb
CHANGED
@@ -1,491 +1,491 @@
|
|
1
|
-
require 'rails'
|
2
|
-
require 'active_support/core_ext/numeric/time'
|
3
|
-
require 'active_support/dependencies'
|
4
|
-
require 'orm_adapter'
|
5
|
-
require 'set'
|
6
|
-
require 'securerandom'
|
7
|
-
|
8
|
-
module Devise
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
end
|
486
|
-
|
487
|
-
require 'warden'
|
488
|
-
require 'devise/mapping'
|
489
|
-
require 'devise/models'
|
490
|
-
require 'devise/modules'
|
491
|
-
require 'devise/rails'
|
1
|
+
# require 'rails'
|
2
|
+
# require 'active_support/core_ext/numeric/time'
|
3
|
+
# require 'active_support/dependencies'
|
4
|
+
# require 'orm_adapter'
|
5
|
+
# require 'set'
|
6
|
+
# require 'securerandom'
|
7
|
+
|
8
|
+
# module Devise
|
9
|
+
# autoload :Delegator, 'devise/delegator'
|
10
|
+
# autoload :FailureApp, 'devise/failure_app'
|
11
|
+
# autoload :OmniAuth, 'devise/omniauth'
|
12
|
+
# autoload :ParameterFilter, 'devise/parameter_filter'
|
13
|
+
# autoload :BaseSanitizer, 'devise/parameter_sanitizer'
|
14
|
+
# autoload :ParameterSanitizer, 'devise/parameter_sanitizer'
|
15
|
+
# autoload :TestHelpers, 'devise/test_helpers'
|
16
|
+
# autoload :TimeInflector, 'devise/time_inflector'
|
17
|
+
# autoload :TokenGenerator, 'devise/token_generator'
|
18
|
+
|
19
|
+
# module Controllers
|
20
|
+
# autoload :Helpers, 'devise/controllers/helpers'
|
21
|
+
# autoload :Rememberable, 'devise/controllers/rememberable'
|
22
|
+
# autoload :ScopedViews, 'devise/controllers/scoped_views'
|
23
|
+
# autoload :SignInOut, 'devise/controllers/sign_in_out'
|
24
|
+
# autoload :StoreLocation, 'devise/controllers/store_location'
|
25
|
+
# autoload :UrlHelpers, 'devise/controllers/url_helpers'
|
26
|
+
# end
|
27
|
+
|
28
|
+
# module Hooks
|
29
|
+
# autoload :Proxy, 'devise/hooks/proxy'
|
30
|
+
# end
|
31
|
+
|
32
|
+
# module Mailers
|
33
|
+
# autoload :Helpers, 'devise/mailers/helpers'
|
34
|
+
# end
|
35
|
+
|
36
|
+
# module Strategies
|
37
|
+
# autoload :Base, 'devise/strategies/base'
|
38
|
+
# autoload :Authenticatable, 'devise/strategies/authenticatable'
|
39
|
+
# end
|
40
|
+
|
41
|
+
# # Constants which holds devise configuration for extensions. Those should
|
42
|
+
# # not be modified by the "end user" (this is why they are constants).
|
43
|
+
# ALL = []
|
44
|
+
# CONTROLLERS = ActiveSupport::OrderedHash.new
|
45
|
+
# ROUTES = ActiveSupport::OrderedHash.new
|
46
|
+
# STRATEGIES = ActiveSupport::OrderedHash.new
|
47
|
+
# URL_HELPERS = ActiveSupport::OrderedHash.new
|
48
|
+
|
49
|
+
# # Strategies that do not require user input.
|
50
|
+
# NO_INPUT = []
|
51
|
+
|
52
|
+
# # True values used to check params
|
53
|
+
# TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
|
54
|
+
|
55
|
+
# # Secret key used by the key generator
|
56
|
+
# mattr_accessor :secret_key
|
57
|
+
# @@secret_key = nil
|
58
|
+
|
59
|
+
# [ :allow_insecure_token_lookup,
|
60
|
+
# :allow_insecure_sign_in_after_confirmation,
|
61
|
+
# :token_authentication_key ].each do |method|
|
62
|
+
# class_eval <<-RUBY
|
63
|
+
# def self.#{method}
|
64
|
+
# ActiveSupport::Deprecation.warn "Devise.#{method} is deprecated " \
|
65
|
+
# "and has no effect"
|
66
|
+
# end
|
67
|
+
|
68
|
+
# def self.#{method}=(val)
|
69
|
+
# ActiveSupport::Deprecation.warn "Devise.#{method}= is deprecated " \
|
70
|
+
# "and has no effect"
|
71
|
+
# end
|
72
|
+
# RUBY
|
73
|
+
# end
|
74
|
+
|
75
|
+
# # Custom domain or key for cookies. Not set by default
|
76
|
+
# mattr_accessor :rememberable_options
|
77
|
+
# @@rememberable_options = {}
|
78
|
+
|
79
|
+
# # The number of times to encrypt password.
|
80
|
+
# mattr_accessor :stretches
|
81
|
+
# @@stretches = 10
|
82
|
+
|
83
|
+
# # The default key used when authenticating over http auth.
|
84
|
+
# mattr_accessor :http_authentication_key
|
85
|
+
# @@http_authentication_key = nil
|
86
|
+
|
87
|
+
# # Keys used when authenticating a user.
|
88
|
+
# mattr_accessor :authentication_keys
|
89
|
+
# @@authentication_keys = [ :email ]
|
90
|
+
|
91
|
+
# # Request keys used when authenticating a user.
|
92
|
+
# mattr_accessor :request_keys
|
93
|
+
# @@request_keys = []
|
94
|
+
|
95
|
+
# # Keys that should be case-insensitive.
|
96
|
+
# mattr_accessor :case_insensitive_keys
|
97
|
+
# @@case_insensitive_keys = [ :email ]
|
98
|
+
|
99
|
+
# # Keys that should have whitespace stripped.
|
100
|
+
# mattr_accessor :strip_whitespace_keys
|
101
|
+
# @@strip_whitespace_keys = []
|
102
|
+
|
103
|
+
# # If http authentication is enabled by default.
|
104
|
+
# mattr_accessor :http_authenticatable
|
105
|
+
# @@http_authenticatable = false
|
106
|
+
|
107
|
+
# # If http headers should be returned for ajax requests. True by default.
|
108
|
+
# mattr_accessor :http_authenticatable_on_xhr
|
109
|
+
# @@http_authenticatable_on_xhr = true
|
110
|
+
|
111
|
+
# # If params authenticatable is enabled by default.
|
112
|
+
# mattr_accessor :params_authenticatable
|
113
|
+
# @@params_authenticatable = true
|
114
|
+
|
115
|
+
# # The realm used in Http Basic Authentication.
|
116
|
+
# mattr_accessor :http_authentication_realm
|
117
|
+
# @@http_authentication_realm = "Application"
|
118
|
+
|
119
|
+
# # Email regex used to validate email formats. It simply asserts that
|
120
|
+
# # an one (and only one) @ exists in the given string. This is mainly
|
121
|
+
# # to give user feedback and not to assert the e-mail validity.
|
122
|
+
# mattr_accessor :email_regexp
|
123
|
+
# @@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
|
124
|
+
|
125
|
+
# # Range validation for password length
|
126
|
+
# mattr_accessor :password_length
|
127
|
+
# @@password_length = 6..128
|
128
|
+
|
129
|
+
# # The time the user will be remembered without asking for credentials again.
|
130
|
+
# mattr_accessor :remember_for
|
131
|
+
# @@remember_for = 2.weeks
|
132
|
+
|
133
|
+
# # If true, extends the user's remember period when remembered via cookie.
|
134
|
+
# mattr_accessor :extend_remember_period
|
135
|
+
# @@extend_remember_period = false
|
136
|
+
|
137
|
+
# # Time interval you can access your account before confirming your account.
|
138
|
+
# # nil - allows unconfirmed access for unlimited time
|
139
|
+
# mattr_accessor :allow_unconfirmed_access_for
|
140
|
+
# @@allow_unconfirmed_access_for = 0.days
|
141
|
+
|
142
|
+
# # Time interval the confirmation token is valid. nil = unlimited
|
143
|
+
# mattr_accessor :confirm_within
|
144
|
+
# @@confirm_within = nil
|
145
|
+
|
146
|
+
# # Defines which key will be used when confirming an account.
|
147
|
+
# mattr_accessor :confirmation_keys
|
148
|
+
# @@confirmation_keys = [ :email ]
|
149
|
+
|
150
|
+
# # Defines if email should be reconfirmable.
|
151
|
+
# # False by default for backwards compatibility.
|
152
|
+
# mattr_accessor :reconfirmable
|
153
|
+
# @@reconfirmable = false
|
154
|
+
|
155
|
+
# # Time interval to timeout the user session without activity.
|
156
|
+
# mattr_accessor :timeout_in
|
157
|
+
# @@timeout_in = 30.minutes
|
158
|
+
|
159
|
+
# # Authentication token expiration on timeout
|
160
|
+
# mattr_accessor :expire_auth_token_on_timeout
|
161
|
+
# @@expire_auth_token_on_timeout = false
|
162
|
+
|
163
|
+
# # Used to encrypt password. Please generate one with rake secret.
|
164
|
+
# mattr_accessor :pepper
|
165
|
+
# @@pepper = nil
|
166
|
+
|
167
|
+
# # Scoped views. Since it relies on fallbacks to render default views, it's
|
168
|
+
# # turned off by default.
|
169
|
+
# mattr_accessor :scoped_views
|
170
|
+
# @@scoped_views = false
|
171
|
+
|
172
|
+
# # Defines which strategy can be used to lock an account.
|
173
|
+
# # Values: :failed_attempts, :none
|
174
|
+
# mattr_accessor :lock_strategy
|
175
|
+
# @@lock_strategy = :failed_attempts
|
176
|
+
|
177
|
+
# # Defines which key will be used when locking and unlocking an account
|
178
|
+
# mattr_accessor :unlock_keys
|
179
|
+
# @@unlock_keys = [ :email ]
|
180
|
+
|
181
|
+
# # Defines which strategy can be used to unlock an account.
|
182
|
+
# # Values: :email, :time, :both
|
183
|
+
# mattr_accessor :unlock_strategy
|
184
|
+
# @@unlock_strategy = :both
|
185
|
+
|
186
|
+
# # Number of authentication tries before locking an account
|
187
|
+
# mattr_accessor :maximum_attempts
|
188
|
+
# @@maximum_attempts = 20
|
189
|
+
|
190
|
+
# # Time interval to unlock the account if :time is defined as unlock_strategy.
|
191
|
+
# mattr_accessor :unlock_in
|
192
|
+
# @@unlock_in = 1.hour
|
193
|
+
|
194
|
+
# # Defines which key will be used when recovering the password for an account
|
195
|
+
# mattr_accessor :reset_password_keys
|
196
|
+
# @@reset_password_keys = [ :email ]
|
197
|
+
|
198
|
+
# # Time interval you can reset your password with a reset password key
|
199
|
+
# mattr_accessor :reset_password_within
|
200
|
+
# @@reset_password_within = 6.hours
|
201
|
+
|
202
|
+
# # The default scope which is used by warden.
|
203
|
+
# mattr_accessor :default_scope
|
204
|
+
# @@default_scope = nil
|
205
|
+
|
206
|
+
# # Address which sends Devise e-mails.
|
207
|
+
# mattr_accessor :mailer_sender
|
208
|
+
# @@mailer_sender = nil
|
209
|
+
|
210
|
+
# # Skip session storage for the following strategies
|
211
|
+
# mattr_accessor :skip_session_storage
|
212
|
+
# @@skip_session_storage = []
|
213
|
+
|
214
|
+
# # Which formats should be treated as navigational.
|
215
|
+
# mattr_accessor :navigational_formats
|
216
|
+
# @@navigational_formats = ["*/*", :html]
|
217
|
+
|
218
|
+
# # When set to true, signing out a user signs out all other scopes.
|
219
|
+
# mattr_accessor :sign_out_all_scopes
|
220
|
+
# @@sign_out_all_scopes = true
|
221
|
+
|
222
|
+
# # The default method used while signing out
|
223
|
+
# mattr_accessor :sign_out_via
|
224
|
+
# @@sign_out_via = :get
|
225
|
+
|
226
|
+
# # The parent controller all Devise controllers inherits from.
|
227
|
+
# # Defaults to ApplicationController. This should be set early
|
228
|
+
# # in the initialization process and should be set to a string.
|
229
|
+
# mattr_accessor :parent_controller
|
230
|
+
# @@parent_controller = "ApplicationController"
|
231
|
+
|
232
|
+
# # The parent mailer all Devise mailers inherit from.
|
233
|
+
# # Defaults to ActionMailer::Base. This should be set early
|
234
|
+
# # in the initialization process and should be set to a string.
|
235
|
+
# mattr_accessor :parent_mailer
|
236
|
+
# @@parent_mailer = "ActionMailer::Base"
|
237
|
+
|
238
|
+
# # The router Devise should use to generate routes. Defaults
|
239
|
+
# # to :main_app. Should be overridden by engines in order
|
240
|
+
# # to provide custom routes.
|
241
|
+
# mattr_accessor :router_name
|
242
|
+
# @@router_name = nil
|
243
|
+
|
244
|
+
# # Set the omniauth path prefix so it can be overridden when
|
245
|
+
# # Devise is used in a mountable engine
|
246
|
+
# mattr_accessor :omniauth_path_prefix
|
247
|
+
# @@omniauth_path_prefix = nil
|
248
|
+
|
249
|
+
# # Set if we should clean up the CSRF Token on authentication
|
250
|
+
# mattr_accessor :clean_up_csrf_token_on_authentication
|
251
|
+
# @@clean_up_csrf_token_on_authentication = true
|
252
|
+
|
253
|
+
# # PRIVATE CONFIGURATION
|
254
|
+
|
255
|
+
# # Store scopes mappings.
|
256
|
+
# mattr_reader :mappings
|
257
|
+
# @@mappings = ActiveSupport::OrderedHash.new
|
258
|
+
|
259
|
+
# # Omniauth configurations.
|
260
|
+
# mattr_reader :omniauth_configs
|
261
|
+
# @@omniauth_configs = ActiveSupport::OrderedHash.new
|
262
|
+
|
263
|
+
# # Define a set of modules that are called when a mapping is added.
|
264
|
+
# mattr_reader :helpers
|
265
|
+
# @@helpers = Set.new
|
266
|
+
# @@helpers << Devise::Controllers::Helpers
|
267
|
+
|
268
|
+
# # Private methods to interface with Warden.
|
269
|
+
# mattr_accessor :warden_config
|
270
|
+
# @@warden_config = nil
|
271
|
+
# @@warden_config_block = nil
|
272
|
+
|
273
|
+
# # When true, enter in paranoid mode to avoid user enumeration.
|
274
|
+
# mattr_accessor :paranoid
|
275
|
+
# @@paranoid = false
|
276
|
+
|
277
|
+
# # When true, warn user if they just used next-to-last attempt of authentication
|
278
|
+
# mattr_accessor :last_attempt_warning
|
279
|
+
# @@last_attempt_warning = false
|
280
|
+
|
281
|
+
# # Stores the token generator
|
282
|
+
# mattr_accessor :token_generator
|
283
|
+
# @@token_generator = nil
|
284
|
+
|
285
|
+
# # Default way to setup Devise. Run rails generate devise_install to create
|
286
|
+
# # a fresh initializer with all configuration values.
|
287
|
+
# def self.setup
|
288
|
+
# yield self
|
289
|
+
# end
|
290
|
+
|
291
|
+
# class Getter
|
292
|
+
# def initialize name
|
293
|
+
# @name = name
|
294
|
+
# end
|
295
|
+
|
296
|
+
# def get
|
297
|
+
# ActiveSupport::Dependencies.constantize(@name)
|
298
|
+
# end
|
299
|
+
# end
|
300
|
+
|
301
|
+
# def self.ref(arg)
|
302
|
+
# if defined?(ActiveSupport::Dependencies::ClassCache)
|
303
|
+
# ActiveSupport::Dependencies::reference(arg)
|
304
|
+
# Getter.new(arg)
|
305
|
+
# else
|
306
|
+
# ActiveSupport::Dependencies.ref(arg)
|
307
|
+
# end
|
308
|
+
# end
|
309
|
+
|
310
|
+
# def self.available_router_name
|
311
|
+
# router_name || :main_app
|
312
|
+
# end
|
313
|
+
|
314
|
+
# def self.omniauth_providers
|
315
|
+
# omniauth_configs.keys
|
316
|
+
# end
|
317
|
+
|
318
|
+
# # Get the mailer class from the mailer reference object.
|
319
|
+
# def self.mailer
|
320
|
+
# @@mailer_ref.get
|
321
|
+
# end
|
322
|
+
|
323
|
+
# # Set the mailer reference object to access the mailer.
|
324
|
+
# def self.mailer=(class_name)
|
325
|
+
# @@mailer_ref = ref(class_name)
|
326
|
+
# end
|
327
|
+
# self.mailer = "Devise::Mailer"
|
328
|
+
|
329
|
+
# # Small method that adds a mapping to Devise.
|
330
|
+
# def self.add_mapping(resource, options)
|
331
|
+
# mapping = Devise::Mapping.new(resource, options)
|
332
|
+
# @@mappings[mapping.name] = mapping
|
333
|
+
# @@default_scope ||= mapping.name
|
334
|
+
# @@helpers.each { |h| h.define_helpers(mapping) }
|
335
|
+
# mapping
|
336
|
+
# end
|
337
|
+
|
338
|
+
# # Make Devise aware of an 3rd party Devise-module (like invitable). For convenience.
|
339
|
+
# #
|
340
|
+
# # == Options:
|
341
|
+
# #
|
342
|
+
# # +model+ - String representing the load path to a custom *model* for this module (to autoload.)
|
343
|
+
# # +controller+ - Symbol representing the name of an existing or custom *controller* for this module.
|
344
|
+
# # +route+ - Symbol representing the named *route* helper for this module.
|
345
|
+
# # +strategy+ - Symbol representing if this module got a custom *strategy*.
|
346
|
+
# #
|
347
|
+
# # All values, except :model, accept also a boolean and will have the same name as the given module
|
348
|
+
# # name.
|
349
|
+
# #
|
350
|
+
# # == Examples:
|
351
|
+
# #
|
352
|
+
# # Devise.add_module(:party_module)
|
353
|
+
# # Devise.add_module(:party_module, strategy: true, controller: :sessions)
|
354
|
+
# # Devise.add_module(:party_module, model: 'party_module/model')
|
355
|
+
# #
|
356
|
+
# def self.add_module(module_name, options = {})
|
357
|
+
# ALL << module_name
|
358
|
+
# options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input)
|
359
|
+
|
360
|
+
# if strategy = options[:strategy]
|
361
|
+
# strategy = (strategy == true ? module_name : strategy)
|
362
|
+
# STRATEGIES[module_name] = strategy
|
363
|
+
# end
|
364
|
+
|
365
|
+
# if controller = options[:controller]
|
366
|
+
# controller = (controller == true ? module_name : controller)
|
367
|
+
# CONTROLLERS[module_name] = controller
|
368
|
+
# end
|
369
|
+
|
370
|
+
# NO_INPUT << strategy if options[:no_input]
|
371
|
+
|
372
|
+
# if route = options[:route]
|
373
|
+
# case route
|
374
|
+
# when TrueClass
|
375
|
+
# key, value = module_name, []
|
376
|
+
# when Symbol
|
377
|
+
# key, value = route, []
|
378
|
+
# when Hash
|
379
|
+
# key, value = route.keys.first, route.values.flatten
|
380
|
+
# else
|
381
|
+
# raise ArgumentError, ":route should be true, a Symbol or a Hash"
|
382
|
+
# end
|
383
|
+
|
384
|
+
# URL_HELPERS[key] ||= []
|
385
|
+
# URL_HELPERS[key].concat(value)
|
386
|
+
# URL_HELPERS[key].uniq!
|
387
|
+
|
388
|
+
# ROUTES[module_name] = key
|
389
|
+
# end
|
390
|
+
|
391
|
+
# if options[:model]
|
392
|
+
# path = (options[:model] == true ? "devise/models/#{module_name}" : options[:model])
|
393
|
+
# camelized = ActiveSupport::Inflector.camelize(module_name.to_s)
|
394
|
+
# Devise::Models.send(:autoload, camelized.to_sym, path)
|
395
|
+
# end
|
396
|
+
|
397
|
+
# Devise::Mapping.add_module module_name
|
398
|
+
# end
|
399
|
+
|
400
|
+
# # Sets warden configuration using a block that will be invoked on warden
|
401
|
+
# # initialization.
|
402
|
+
# #
|
403
|
+
# # Devise.initialize do |config|
|
404
|
+
# # config.allow_unconfirmed_access_for = 2.days
|
405
|
+
# #
|
406
|
+
# # config.warden do |manager|
|
407
|
+
# # # Configure warden to use other strategies, like oauth.
|
408
|
+
# # manager.oauth(:twitter)
|
409
|
+
# # end
|
410
|
+
# # end
|
411
|
+
# def self.warden(&block)
|
412
|
+
# @@warden_config_block = block
|
413
|
+
# end
|
414
|
+
|
415
|
+
# # Specify an omniauth provider.
|
416
|
+
# #
|
417
|
+
# # config.omniauth :github, APP_ID, APP_SECRET
|
418
|
+
# #
|
419
|
+
# def self.omniauth(provider, *args)
|
420
|
+
# @@helpers << Devise::OmniAuth::UrlHelpers
|
421
|
+
# config = Devise::OmniAuth::Config.new(provider, args)
|
422
|
+
# @@omniauth_configs[config.strategy_name.to_sym] = config
|
423
|
+
# end
|
424
|
+
|
425
|
+
# # Include helpers in the given scope to AC and AV.
|
426
|
+
# def self.include_helpers(scope)
|
427
|
+
# ActiveSupport.on_load(:action_controller) do
|
428
|
+
# include scope::Helpers if defined?(scope::Helpers)
|
429
|
+
# include scope::UrlHelpers
|
430
|
+
# end
|
431
|
+
|
432
|
+
# ActiveSupport.on_load(:action_view) do
|
433
|
+
# include scope::UrlHelpers
|
434
|
+
# end
|
435
|
+
# end
|
436
|
+
|
437
|
+
# # Regenerates url helpers considering Devise.mapping
|
438
|
+
# def self.regenerate_helpers!
|
439
|
+
# Devise::Controllers::UrlHelpers.remove_helpers!
|
440
|
+
# Devise::Controllers::UrlHelpers.generate_helpers!
|
441
|
+
# end
|
442
|
+
|
443
|
+
# # A method used internally to setup warden manager from the Rails initialize
|
444
|
+
# # block.
|
445
|
+
# def self.configure_warden! #:nodoc:
|
446
|
+
# @@warden_configured ||= begin
|
447
|
+
# warden_config.failure_app = Devise::Delegator.new
|
448
|
+
# warden_config.default_scope = Devise.default_scope
|
449
|
+
# warden_config.intercept_401 = false
|
450
|
+
|
451
|
+
# Devise.mappings.each_value do |mapping|
|
452
|
+
# warden_config.scope_defaults mapping.name, strategies: mapping.strategies
|
453
|
+
|
454
|
+
# warden_config.serialize_into_session(mapping.name) do |record|
|
455
|
+
# mapping.to.serialize_into_session(record)
|
456
|
+
# end
|
457
|
+
|
458
|
+
# warden_config.serialize_from_session(mapping.name) do |key|
|
459
|
+
# # Previous versions contained an additional entry at the beginning of
|
460
|
+
# # key with the record's class name.
|
461
|
+
# args = key[-2, 2]
|
462
|
+
# mapping.to.serialize_from_session(*args)
|
463
|
+
# end
|
464
|
+
# end
|
465
|
+
|
466
|
+
# @@warden_config_block.try :call, Devise.warden_config
|
467
|
+
# true
|
468
|
+
# end
|
469
|
+
# end
|
470
|
+
|
471
|
+
# # Generate a friendly string randomly to be used as token.
|
472
|
+
# def self.friendly_token
|
473
|
+
# SecureRandom.urlsafe_base64(15).tr('lIO0', 'sxyz')
|
474
|
+
# end
|
475
|
+
|
476
|
+
# # constant-time comparison algorithm to prevent timing attacks
|
477
|
+
# def self.secure_compare(a, b)
|
478
|
+
# return false if a.blank? || b.blank? || a.bytesize != b.bytesize
|
479
|
+
# l = a.unpack "C#{a.bytesize}"
|
480
|
+
|
481
|
+
# res = 0
|
482
|
+
# b.each_byte { |byte| res |= byte ^ l.shift }
|
483
|
+
# res == 0
|
484
|
+
# end
|
485
|
+
# end
|
486
|
+
|
487
|
+
# require 'warden'
|
488
|
+
# require 'devise/mapping'
|
489
|
+
# require 'devise/models'
|
490
|
+
# require 'devise/modules'
|
491
|
+
# require 'devise/rails'
|