deviseOne 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.travis.yml +38 -0
  4. data/.yardopts +9 -0
  5. data/CHANGELOG.md +1117 -0
  6. data/CONTRIBUTING.md +14 -0
  7. data/Gemfile +29 -0
  8. data/Gemfile.lock +199 -0
  9. data/MIT-LICENSE +20 -0
  10. data/README.md +529 -0
  11. data/Rakefile +35 -0
  12. data/app/controllers/devise/confirmations_controller.rb +47 -0
  13. data/app/controllers/devise/omniauth_callbacks_controller.rb +30 -0
  14. data/app/controllers/devise/passwords_controller.rb +71 -0
  15. data/app/controllers/devise/registrations_controller.rb +143 -0
  16. data/app/controllers/devise/sessions_controller.rb +166 -0
  17. data/app/controllers/devise/unlocks_controller.rb +46 -0
  18. data/app/controllers/devise_controller.rb +193 -0
  19. data/app/helpers/devise_helper.rb +25 -0
  20. data/app/mailers/devise/mailer.rb +20 -0
  21. data/app/views/devise/confirmations/new.html.erb +16 -0
  22. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  23. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  24. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  25. data/app/views/devise/passwords/edit.html.erb +25 -0
  26. data/app/views/devise/passwords/new.html.erb +16 -0
  27. data/app/views/devise/registrations/edit.html.erb +39 -0
  28. data/app/views/devise/registrations/new.html.erb +29 -0
  29. data/app/views/devise/sessions/new.html.erb +27 -0
  30. data/app/views/devise/shared/_links.html.erb +21 -0
  31. data/app/views/devise/unlocks/new.html.erb +16 -0
  32. data/config/locales/en.yml +70 -0
  33. data/devise.gemspec +33 -0
  34. data/devise.png +0 -0
  35. data/gemfiles/Gemfile.rails-3.2-stable +29 -0
  36. data/gemfiles/Gemfile.rails-3.2-stable.lock +169 -0
  37. data/gemfiles/Gemfile.rails-4.0-stable +29 -0
  38. data/gemfiles/Gemfile.rails-4.0-stable.lock +165 -0
  39. data/gemfiles/Gemfile.rails-4.1-stable +29 -0
  40. data/gemfiles/Gemfile.rails-4.1-stable.lock +170 -0
  41. data/lib/devise.rb +499 -0
  42. data/lib/devise/controllers/helpers.rb +284 -0
  43. data/lib/devise/controllers/rememberable.rb +47 -0
  44. data/lib/devise/controllers/scoped_views.rb +17 -0
  45. data/lib/devise/controllers/sign_in_out.rb +102 -0
  46. data/lib/devise/controllers/store_location.rb +58 -0
  47. data/lib/devise/controllers/url_helpers.rb +69 -0
  48. data/lib/devise/delegator.rb +16 -0
  49. data/lib/devise/failure_app.rb +212 -0
  50. data/lib/devise/hooks/activatable.rb +10 -0
  51. data/lib/devise/hooks/csrf_cleaner.rb +7 -0
  52. data/lib/devise/hooks/forgetable.rb +9 -0
  53. data/lib/devise/hooks/lockable.rb +7 -0
  54. data/lib/devise/hooks/proxy.rb +21 -0
  55. data/lib/devise/hooks/rememberable.rb +7 -0
  56. data/lib/devise/hooks/timeoutable.rb +35 -0
  57. data/lib/devise/hooks/trackable.rb +9 -0
  58. data/lib/devise/mailers/helpers.rb +90 -0
  59. data/lib/devise/mapping.rb +175 -0
  60. data/lib/devise/models.rb +119 -0
  61. data/lib/devise/models/authenticatable.rb +290 -0
  62. data/lib/devise/models/confirmable.rb +305 -0
  63. data/lib/devise/models/database_authenticatable.rb +164 -0
  64. data/lib/devise/models/lockable.rb +196 -0
  65. data/lib/devise/models/omniauthable.rb +27 -0
  66. data/lib/devise/models/recoverable.rb +157 -0
  67. data/lib/devise/models/registerable.rb +25 -0
  68. data/lib/devise/models/rememberable.rb +142 -0
  69. data/lib/devise/models/timeoutable.rb +49 -0
  70. data/lib/devise/models/trackable.rb +38 -0
  71. data/lib/devise/models/validatable.rb +66 -0
  72. data/lib/devise/modules.rb +28 -0
  73. data/lib/devise/omniauth.rb +28 -0
  74. data/lib/devise/omniauth/config.rb +45 -0
  75. data/lib/devise/omniauth/url_helpers.rb +18 -0
  76. data/lib/devise/orm/active_record.rb +3 -0
  77. data/lib/devise/orm/mongoid.rb +3 -0
  78. data/lib/devise/parameter_filter.rb +40 -0
  79. data/lib/devise/parameter_sanitizer.rb +99 -0
  80. data/lib/devise/rails.rb +56 -0
  81. data/lib/devise/rails/routes.rb +495 -0
  82. data/lib/devise/rails/warden_compat.rb +22 -0
  83. data/lib/devise/strategies/authenticatable.rb +173 -0
  84. data/lib/devise/strategies/base.rb +20 -0
  85. data/lib/devise/strategies/database_authenticatable.rb +24 -0
  86. data/lib/devise/strategies/rememberable.rb +59 -0
  87. data/lib/devise/test_helpers.rb +132 -0
  88. data/lib/devise/time_inflector.rb +14 -0
  89. data/lib/devise/token_generator.rb +70 -0
  90. data/lib/devise/version.rb +3 -0
  91. data/lib/generators/active_record/devise_generator.rb +91 -0
  92. data/lib/generators/active_record/templates/migration.rb +18 -0
  93. data/lib/generators/active_record/templates/migration_existing.rb +25 -0
  94. data/lib/generators/devise/controllers_generator.rb +44 -0
  95. data/lib/generators/devise/devise_generator.rb +26 -0
  96. data/lib/generators/devise/install_generator.rb +29 -0
  97. data/lib/generators/devise/orm_helpers.rb +51 -0
  98. data/lib/generators/devise/views_generator.rb +135 -0
  99. data/lib/generators/mongoid/devise_generator.rb +55 -0
  100. data/lib/generators/templates/README +35 -0
  101. data/lib/generators/templates/controllers/README +14 -0
  102. data/lib/generators/templates/controllers/confirmations_controller.rb +28 -0
  103. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +28 -0
  104. data/lib/generators/templates/controllers/passwords_controller.rb +32 -0
  105. data/lib/generators/templates/controllers/registrations_controller.rb +60 -0
  106. data/lib/generators/templates/controllers/sessions_controller.rb +25 -0
  107. data/lib/generators/templates/controllers/unlocks_controller.rb +28 -0
  108. data/lib/generators/templates/devise.rb +263 -0
  109. data/lib/generators/templates/markerb/confirmation_instructions.markerb +5 -0
  110. data/lib/generators/templates/markerb/reset_password_instructions.markerb +8 -0
  111. data/lib/generators/templates/markerb/unlock_instructions.markerb +7 -0
  112. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +16 -0
  113. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +19 -0
  114. data/lib/generators/templates/simple_form_for/passwords/new.html.erb +15 -0
  115. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +27 -0
  116. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +17 -0
  117. data/lib/generators/templates/simple_form_for/sessions/new.html.erb +15 -0
  118. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +16 -0
  119. data/script/cached-bundle +49 -0
  120. data/script/s3-put +71 -0
  121. data/test/controllers/custom_registrations_controller_test.rb +35 -0
  122. data/test/controllers/custom_strategy_test.rb +62 -0
  123. data/test/controllers/helpers_test.rb +316 -0
  124. data/test/controllers/internal_helpers_test.rb +129 -0
  125. data/test/controllers/load_hooks_controller_test.rb +19 -0
  126. data/test/controllers/passwords_controller_test.rb +31 -0
  127. data/test/controllers/sessions_controller_test.rb +102 -0
  128. data/test/controllers/url_helpers_test.rb +65 -0
  129. data/test/delegator_test.rb +19 -0
  130. data/test/devise_test.rb +107 -0
  131. data/test/failure_app_test.rb +275 -0
  132. data/test/generators/active_record_generator_test.rb +109 -0
  133. data/test/generators/controllers_generator_test.rb +48 -0
  134. data/test/generators/devise_generator_test.rb +39 -0
  135. data/test/generators/install_generator_test.rb +13 -0
  136. data/test/generators/mongoid_generator_test.rb +23 -0
  137. data/test/generators/views_generator_test.rb +96 -0
  138. data/test/helpers/devise_helper_test.rb +49 -0
  139. data/test/integration/authenticatable_test.rb +731 -0
  140. data/test/integration/confirmable_test.rb +324 -0
  141. data/test/integration/database_authenticatable_test.rb +94 -0
  142. data/test/integration/http_authenticatable_test.rb +105 -0
  143. data/test/integration/lockable_test.rb +239 -0
  144. data/test/integration/omniauthable_test.rb +133 -0
  145. data/test/integration/recoverable_test.rb +334 -0
  146. data/test/integration/registerable_test.rb +361 -0
  147. data/test/integration/rememberable_test.rb +176 -0
  148. data/test/integration/timeoutable_test.rb +189 -0
  149. data/test/integration/trackable_test.rb +92 -0
  150. data/test/mailers/confirmation_instructions_test.rb +115 -0
  151. data/test/mailers/reset_password_instructions_test.rb +96 -0
  152. data/test/mailers/unlock_instructions_test.rb +91 -0
  153. data/test/mapping_test.rb +128 -0
  154. data/test/models/authenticatable_test.rb +23 -0
  155. data/test/models/confirmable_test.rb +461 -0
  156. data/test/models/database_authenticatable_test.rb +249 -0
  157. data/test/models/lockable_test.rb +328 -0
  158. data/test/models/omniauthable_test.rb +7 -0
  159. data/test/models/recoverable_test.rb +205 -0
  160. data/test/models/registerable_test.rb +7 -0
  161. data/test/models/rememberable_test.rb +198 -0
  162. data/test/models/serializable_test.rb +49 -0
  163. data/test/models/timeoutable_test.rb +51 -0
  164. data/test/models/trackable_test.rb +41 -0
  165. data/test/models/validatable_test.rb +127 -0
  166. data/test/models_test.rb +144 -0
  167. data/test/omniauth/config_test.rb +57 -0
  168. data/test/omniauth/url_helpers_test.rb +54 -0
  169. data/test/orm/active_record.rb +10 -0
  170. data/test/orm/mongoid.rb +13 -0
  171. data/test/parameter_sanitizer_test.rb +81 -0
  172. data/test/rails_app/Rakefile +6 -0
  173. data/test/rails_app/app/active_record/admin.rb +6 -0
  174. data/test/rails_app/app/active_record/shim.rb +2 -0
  175. data/test/rails_app/app/active_record/user.rb +6 -0
  176. data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
  177. data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
  178. data/test/rails_app/app/controllers/admins/sessions_controller.rb +6 -0
  179. data/test/rails_app/app/controllers/admins_controller.rb +11 -0
  180. data/test/rails_app/app/controllers/application_controller.rb +12 -0
  181. data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
  182. data/test/rails_app/app/controllers/custom/registrations_controller.rb +21 -0
  183. data/test/rails_app/app/controllers/home_controller.rb +25 -0
  184. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  185. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  186. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +14 -0
  187. data/test/rails_app/app/controllers/users_controller.rb +31 -0
  188. data/test/rails_app/app/helpers/application_helper.rb +3 -0
  189. data/test/rails_app/app/mailers/users/from_proc_mailer.rb +3 -0
  190. data/test/rails_app/app/mailers/users/mailer.rb +3 -0
  191. data/test/rails_app/app/mailers/users/reply_to_mailer.rb +4 -0
  192. data/test/rails_app/app/mongoid/admin.rb +29 -0
  193. data/test/rails_app/app/mongoid/shim.rb +23 -0
  194. data/test/rails_app/app/mongoid/user.rb +39 -0
  195. data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
  196. data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
  197. data/test/rails_app/app/views/admins/index.html.erb +1 -0
  198. data/test/rails_app/app/views/admins/sessions/new.html.erb +2 -0
  199. data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -0
  200. data/test/rails_app/app/views/home/index.html.erb +1 -0
  201. data/test/rails_app/app/views/home/join.html.erb +1 -0
  202. data/test/rails_app/app/views/home/private.html.erb +1 -0
  203. data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -0
  204. data/test/rails_app/app/views/layouts/application.html.erb +24 -0
  205. data/test/rails_app/app/views/users/edit_form.html.erb +1 -0
  206. data/test/rails_app/app/views/users/index.html.erb +1 -0
  207. data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +1 -0
  208. data/test/rails_app/app/views/users/sessions/new.html.erb +1 -0
  209. data/test/rails_app/bin/bundle +3 -0
  210. data/test/rails_app/bin/rails +4 -0
  211. data/test/rails_app/bin/rake +4 -0
  212. data/test/rails_app/config.ru +4 -0
  213. data/test/rails_app/config/application.rb +40 -0
  214. data/test/rails_app/config/boot.rb +14 -0
  215. data/test/rails_app/config/database.yml +18 -0
  216. data/test/rails_app/config/environment.rb +5 -0
  217. data/test/rails_app/config/environments/development.rb +30 -0
  218. data/test/rails_app/config/environments/production.rb +80 -0
  219. data/test/rails_app/config/environments/test.rb +36 -0
  220. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  221. data/test/rails_app/config/initializers/devise.rb +180 -0
  222. data/test/rails_app/config/initializers/inflections.rb +2 -0
  223. data/test/rails_app/config/initializers/secret_token.rb +8 -0
  224. data/test/rails_app/config/initializers/session_store.rb +1 -0
  225. data/test/rails_app/config/routes.rb +122 -0
  226. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +71 -0
  227. data/test/rails_app/db/schema.rb +55 -0
  228. data/test/rails_app/lib/shared_admin.rb +17 -0
  229. data/test/rails_app/lib/shared_user.rb +29 -0
  230. data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
  231. data/test/rails_app/public/404.html +26 -0
  232. data/test/rails_app/public/422.html +26 -0
  233. data/test/rails_app/public/500.html +26 -0
  234. data/test/rails_app/public/favicon.ico +0 -0
  235. data/test/routes_test.rb +264 -0
  236. data/test/support/action_controller/record_identifier.rb +10 -0
  237. data/test/support/assertions.rb +39 -0
  238. data/test/support/helpers.rb +73 -0
  239. data/test/support/integration.rb +92 -0
  240. data/test/support/locale/en.yml +8 -0
  241. data/test/support/mongoid.yml +6 -0
  242. data/test/support/webrat/integrations/rails.rb +24 -0
  243. data/test/test_helper.rb +34 -0
  244. data/test/test_helpers_test.rb +163 -0
  245. data/test/test_models.rb +33 -0
  246. metadata +531 -0
@@ -0,0 +1,29 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: '..'
4
+
5
+ gem "rails", github: 'rails/rails', branch: '4-1-stable'
6
+ gem "omniauth", "~> 1.2.0"
7
+ gem "omniauth-oauth2", "~> 1.1.0"
8
+ gem "rdoc"
9
+
10
+ group :test do
11
+ gem "omniauth-facebook"
12
+ gem "omniauth-openid", "~> 1.0.1"
13
+ gem "webrat", "0.7.3", require: false
14
+ gem "mocha", "~> 1.1", require: false
15
+ end
16
+
17
+ platforms :jruby do
18
+ gem "activerecord-jdbc-adapter"
19
+ gem "activerecord-jdbcsqlite3-adapter"
20
+ gem "jruby-openssl"
21
+ end
22
+
23
+ platforms :ruby do
24
+ gem "sqlite3"
25
+ end
26
+
27
+ group :mongoid do
28
+ gem "mongoid", "~> 4.0.0"
29
+ end
@@ -0,0 +1,170 @@
1
+ GIT
2
+ remote: git://github.com/rails/rails.git
3
+ revision: 042c7cb9ccfb771dcfd3dcacb7cb2d19d3747853
4
+ branch: 4-1-stable
5
+ specs:
6
+ actionmailer (4.1.8)
7
+ actionpack (= 4.1.8)
8
+ actionview (= 4.1.8)
9
+ mail (~> 2.5, >= 2.5.4)
10
+ actionpack (4.1.8)
11
+ actionview (= 4.1.8)
12
+ activesupport (= 4.1.8)
13
+ rack (~> 1.5.2)
14
+ rack-test (~> 0.6.2)
15
+ actionview (4.1.8)
16
+ activesupport (= 4.1.8)
17
+ builder (~> 3.1)
18
+ erubis (~> 2.7.0)
19
+ activemodel (4.1.8)
20
+ activesupport (= 4.1.8)
21
+ builder (~> 3.1)
22
+ activerecord (4.1.8)
23
+ activemodel (= 4.1.8)
24
+ activesupport (= 4.1.8)
25
+ arel (~> 5.0.0)
26
+ activesupport (4.1.8)
27
+ i18n (~> 0.6, >= 0.6.9)
28
+ json (~> 1.7, >= 1.7.7)
29
+ minitest (~> 5.1)
30
+ thread_safe (~> 0.1)
31
+ tzinfo (~> 1.1)
32
+ rails (4.1.8)
33
+ actionmailer (= 4.1.8)
34
+ actionpack (= 4.1.8)
35
+ actionview (= 4.1.8)
36
+ activemodel (= 4.1.8)
37
+ activerecord (= 4.1.8)
38
+ activesupport (= 4.1.8)
39
+ bundler (>= 1.3.0, < 2.0)
40
+ railties (= 4.1.8)
41
+ sprockets-rails (~> 2.0)
42
+ railties (4.1.8)
43
+ actionpack (= 4.1.8)
44
+ activesupport (= 4.1.8)
45
+ rake (>= 0.8.7)
46
+ thor (>= 0.18.1, < 2.0)
47
+
48
+ PATH
49
+ remote: ..
50
+ specs:
51
+ devise (3.4.1)
52
+ bcrypt (~> 3.0)
53
+ orm_adapter (~> 0.1)
54
+ railties (>= 3.2.6, < 5)
55
+ responders
56
+ thread_safe (~> 0.1)
57
+ warden (~> 1.2.3)
58
+
59
+ GEM
60
+ remote: https://rubygems.org/
61
+ specs:
62
+ arel (5.0.1.20140414130214)
63
+ bcrypt (3.1.9)
64
+ bson (2.3.0)
65
+ builder (3.2.2)
66
+ connection_pool (2.1.0)
67
+ erubis (2.7.0)
68
+ faraday (0.9.0)
69
+ multipart-post (>= 1.2, < 3)
70
+ hashie (3.3.1)
71
+ hike (1.2.3)
72
+ i18n (0.6.11)
73
+ json (1.8.1)
74
+ jwt (1.0.0)
75
+ mail (2.6.3)
76
+ mime-types (>= 1.16, < 3)
77
+ metaclass (0.0.4)
78
+ mime-types (2.4.3)
79
+ mini_portile (0.6.1)
80
+ minitest (5.4.3)
81
+ mocha (1.1.0)
82
+ metaclass (~> 0.0.1)
83
+ mongoid (4.0.0)
84
+ activemodel (~> 4.0)
85
+ moped (~> 2.0.0)
86
+ origin (~> 2.1)
87
+ tzinfo (>= 0.3.37)
88
+ moped (2.0.2)
89
+ bson (~> 2.2)
90
+ connection_pool (~> 2.0)
91
+ optionable (~> 0.2.0)
92
+ multi_json (1.10.1)
93
+ multi_xml (0.5.5)
94
+ multipart-post (2.0.0)
95
+ nokogiri (1.6.4.1)
96
+ mini_portile (~> 0.6.0)
97
+ oauth2 (0.9.4)
98
+ faraday (>= 0.8, < 0.10)
99
+ jwt (~> 1.0)
100
+ multi_json (~> 1.3)
101
+ multi_xml (~> 0.5)
102
+ rack (~> 1.2)
103
+ omniauth (1.2.2)
104
+ hashie (>= 1.2, < 4)
105
+ rack (~> 1.0)
106
+ omniauth-facebook (1.6.0)
107
+ omniauth-oauth2 (~> 1.1)
108
+ omniauth-oauth2 (1.1.2)
109
+ faraday (>= 0.8, < 0.10)
110
+ multi_json (~> 1.3)
111
+ oauth2 (~> 0.9.3)
112
+ omniauth (~> 1.2)
113
+ omniauth-openid (1.0.1)
114
+ omniauth (~> 1.0)
115
+ rack-openid (~> 1.3.1)
116
+ optionable (0.2.0)
117
+ origin (2.1.1)
118
+ orm_adapter (0.5.0)
119
+ rack (1.5.2)
120
+ rack-openid (1.3.1)
121
+ rack (>= 1.1.0)
122
+ ruby-openid (>= 2.1.8)
123
+ rack-test (0.6.2)
124
+ rack (>= 1.0)
125
+ rake (10.3.2)
126
+ rdoc (4.1.2)
127
+ json (~> 1.4)
128
+ responders (1.1.2)
129
+ railties (>= 3.2, < 4.2)
130
+ ruby-openid (2.6.0)
131
+ sprockets (2.12.3)
132
+ hike (~> 1.2)
133
+ multi_json (~> 1.0)
134
+ rack (~> 1.0)
135
+ tilt (~> 1.1, != 1.3.0)
136
+ sprockets-rails (2.2.0)
137
+ actionpack (>= 3.0)
138
+ activesupport (>= 3.0)
139
+ sprockets (>= 2.8, < 4.0)
140
+ sqlite3 (1.3.10)
141
+ thor (0.19.1)
142
+ thread_safe (0.3.4)
143
+ tilt (1.4.1)
144
+ tzinfo (1.2.2)
145
+ thread_safe (~> 0.1)
146
+ warden (1.2.3)
147
+ rack (>= 1.0)
148
+ webrat (0.7.3)
149
+ nokogiri (>= 1.2.0)
150
+ rack (>= 1.0)
151
+ rack-test (>= 0.5.3)
152
+
153
+ PLATFORMS
154
+ ruby
155
+
156
+ DEPENDENCIES
157
+ activerecord-jdbc-adapter
158
+ activerecord-jdbcsqlite3-adapter
159
+ devise!
160
+ jruby-openssl
161
+ mocha (~> 1.1)
162
+ mongoid (~> 4.0.0)
163
+ omniauth (~> 1.2.0)
164
+ omniauth-facebook
165
+ omniauth-oauth2 (~> 1.1.0)
166
+ omniauth-openid (~> 1.0.1)
167
+ rails!
168
+ rdoc
169
+ sqlite3
170
+ webrat (= 0.7.3)
@@ -0,0 +1,499 @@
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
+ require 'responders'
8
+
9
+ module Devise
10
+ autoload :Delegator, 'devise/delegator'
11
+ autoload :FailureApp, 'devise/failure_app'
12
+ autoload :OmniAuth, 'devise/omniauth'
13
+ autoload :ParameterFilter, 'devise/parameter_filter'
14
+ autoload :BaseSanitizer, 'devise/parameter_sanitizer'
15
+ autoload :ParameterSanitizer, 'devise/parameter_sanitizer'
16
+ autoload :TestHelpers, 'devise/test_helpers'
17
+ autoload :TimeInflector, 'devise/time_inflector'
18
+ autoload :TokenGenerator, 'devise/token_generator'
19
+
20
+ module Controllers
21
+ autoload :Helpers, 'devise/controllers/helpers'
22
+ autoload :Rememberable, 'devise/controllers/rememberable'
23
+ autoload :ScopedViews, 'devise/controllers/scoped_views'
24
+ autoload :SignInOut, 'devise/controllers/sign_in_out'
25
+ autoload :StoreLocation, 'devise/controllers/store_location'
26
+ autoload :UrlHelpers, 'devise/controllers/url_helpers'
27
+ end
28
+
29
+ module Hooks
30
+ autoload :Proxy, 'devise/hooks/proxy'
31
+ end
32
+
33
+ module Mailers
34
+ autoload :Helpers, 'devise/mailers/helpers'
35
+ end
36
+
37
+ module Strategies
38
+ autoload :Base, 'devise/strategies/base'
39
+ autoload :Authenticatable, 'devise/strategies/authenticatable'
40
+ end
41
+
42
+ # Constants which holds devise configuration for extensions. Those should
43
+ # not be modified by the "end user" (this is why they are constants).
44
+ ALL = []
45
+ CONTROLLERS = ActiveSupport::OrderedHash.new
46
+ ROUTES = ActiveSupport::OrderedHash.new
47
+ STRATEGIES = ActiveSupport::OrderedHash.new
48
+ URL_HELPERS = ActiveSupport::OrderedHash.new
49
+
50
+ # Strategies that do not require user input.
51
+ NO_INPUT = []
52
+
53
+ # True values used to check params
54
+ TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
55
+
56
+ # Secret key used by the key generator
57
+ mattr_accessor :secret_key
58
+ @@secret_key = nil
59
+
60
+ [ :allow_insecure_token_lookup,
61
+ :allow_insecure_sign_in_after_confirmation,
62
+ :token_authentication_key ].each do |method|
63
+ class_eval <<-RUBY
64
+ def self.#{method}
65
+ ActiveSupport::Deprecation.warn "Devise.#{method} is deprecated " \
66
+ "and has no effect"
67
+ end
68
+
69
+ def self.#{method}=(val)
70
+ ActiveSupport::Deprecation.warn "Devise.#{method}= is deprecated " \
71
+ "and has no effect"
72
+ end
73
+ RUBY
74
+ end
75
+
76
+ # Custom domain or key for cookies. Not set by default
77
+ mattr_accessor :rememberable_options
78
+ @@rememberable_options = {}
79
+
80
+ # The number of times to encrypt password.
81
+ mattr_accessor :stretches
82
+ @@stretches = 10
83
+
84
+ # The default key used when authenticating over http auth.
85
+ mattr_accessor :http_authentication_key
86
+ @@http_authentication_key = nil
87
+
88
+ # Keys used when authenticating a user.
89
+ mattr_accessor :authentication_keys
90
+ @@authentication_keys = [ :email ]
91
+
92
+ # Request keys used when authenticating a user.
93
+ mattr_accessor :request_keys
94
+ @@request_keys = []
95
+
96
+ # Keys that should be case-insensitive.
97
+ mattr_accessor :case_insensitive_keys
98
+ @@case_insensitive_keys = [ :email ]
99
+
100
+ # Keys that should have whitespace stripped.
101
+ mattr_accessor :strip_whitespace_keys
102
+ @@strip_whitespace_keys = []
103
+
104
+ # If http authentication is enabled by default.
105
+ mattr_accessor :http_authenticatable
106
+ @@http_authenticatable = false
107
+
108
+ # If http headers should be returned for ajax requests. True by default.
109
+ mattr_accessor :http_authenticatable_on_xhr
110
+ @@http_authenticatable_on_xhr = true
111
+
112
+ # If params authenticatable is enabled by default.
113
+ mattr_accessor :params_authenticatable
114
+ @@params_authenticatable = true
115
+
116
+ # The realm used in Http Basic Authentication.
117
+ mattr_accessor :http_authentication_realm
118
+ @@http_authentication_realm = "Application"
119
+
120
+ # Email regex used to validate email formats. It simply asserts that
121
+ # an one (and only one) @ exists in the given string. This is mainly
122
+ # to give user feedback and not to assert the e-mail validity.
123
+ mattr_accessor :email_regexp
124
+ @@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
125
+
126
+ # Range validation for password length
127
+ mattr_accessor :password_length
128
+ @@password_length = 6..128
129
+
130
+ # The time the user will be remembered without asking for credentials again.
131
+ mattr_accessor :remember_for
132
+ @@remember_for = 2.weeks
133
+
134
+ # If true, extends the user's remember period when remembered via cookie.
135
+ mattr_accessor :extend_remember_period
136
+ @@extend_remember_period = false
137
+
138
+ # If true, all the remember me tokens are going to be invalidated when the user signs out.
139
+ mattr_accessor :expire_all_remember_me_on_sign_out
140
+ @@expire_all_remember_me_on_sign_out = true
141
+
142
+ # Time interval you can access your account before confirming your account.
143
+ # nil - allows unconfirmed access for unlimited time
144
+ mattr_accessor :allow_unconfirmed_access_for
145
+ @@allow_unconfirmed_access_for = 0.days
146
+
147
+ # Time interval the confirmation token is valid. nil = unlimited
148
+ mattr_accessor :confirm_within
149
+ @@confirm_within = nil
150
+
151
+ # Defines which key will be used when confirming an account.
152
+ mattr_accessor :confirmation_keys
153
+ @@confirmation_keys = [ :email ]
154
+
155
+ # Defines if email should be reconfirmable.
156
+ # False by default for backwards compatibility.
157
+ mattr_accessor :reconfirmable
158
+ @@reconfirmable = false
159
+
160
+ # Time interval to timeout the user session without activity.
161
+ mattr_accessor :timeout_in
162
+ @@timeout_in = 30.minutes
163
+
164
+ # Authentication token expiration on timeout
165
+ mattr_accessor :expire_auth_token_on_timeout
166
+ @@expire_auth_token_on_timeout = false
167
+
168
+ # Used to encrypt password. Please generate one with rake secret.
169
+ mattr_accessor :pepper
170
+ @@pepper = nil
171
+
172
+ # Scoped views. Since it relies on fallbacks to render default views, it's
173
+ # turned off by default.
174
+ mattr_accessor :scoped_views
175
+ @@scoped_views = false
176
+
177
+ # Defines which strategy can be used to lock an account.
178
+ # Values: :failed_attempts, :none
179
+ mattr_accessor :lock_strategy
180
+ @@lock_strategy = :failed_attempts
181
+
182
+ # Defines which key will be used when locking and unlocking an account
183
+ mattr_accessor :unlock_keys
184
+ @@unlock_keys = [ :email ]
185
+
186
+ # Defines which strategy can be used to unlock an account.
187
+ # Values: :email, :time, :both
188
+ mattr_accessor :unlock_strategy
189
+ @@unlock_strategy = :both
190
+
191
+ # Number of authentication tries before locking an account
192
+ mattr_accessor :maximum_attempts
193
+ @@maximum_attempts = 20
194
+
195
+ # Time interval to unlock the account if :time is defined as unlock_strategy.
196
+ mattr_accessor :unlock_in
197
+ @@unlock_in = 1.hour
198
+
199
+ # Defines which key will be used when recovering the password for an account
200
+ mattr_accessor :reset_password_keys
201
+ @@reset_password_keys = [ :email ]
202
+
203
+ # Time interval you can reset your password with a reset password key
204
+ mattr_accessor :reset_password_within
205
+ @@reset_password_within = 6.hours
206
+
207
+ # The default scope which is used by warden.
208
+ mattr_accessor :default_scope
209
+ @@default_scope = nil
210
+
211
+ # Address which sends Devise e-mails.
212
+ mattr_accessor :mailer_sender
213
+ @@mailer_sender = nil
214
+
215
+ # Skip session storage for the following strategies
216
+ mattr_accessor :skip_session_storage
217
+ @@skip_session_storage = []
218
+
219
+ # Which formats should be treated as navigational.
220
+ mattr_accessor :navigational_formats
221
+ @@navigational_formats = ["*/*", :html]
222
+
223
+ # When set to true, signing out a user signs out all other scopes.
224
+ mattr_accessor :sign_out_all_scopes
225
+ @@sign_out_all_scopes = true
226
+
227
+ # The default method used while signing out
228
+ mattr_accessor :sign_out_via
229
+ @@sign_out_via = :get
230
+
231
+ # The parent controller all Devise controllers inherits from.
232
+ # Defaults to ApplicationController. This should be set early
233
+ # in the initialization process and should be set to a string.
234
+ mattr_accessor :parent_controller
235
+ @@parent_controller = "ApplicationController"
236
+
237
+ # The parent mailer all Devise mailers inherit from.
238
+ # Defaults to ActionMailer::Base. This should be set early
239
+ # in the initialization process and should be set to a string.
240
+ mattr_accessor :parent_mailer
241
+ @@parent_mailer = "ActionMailer::Base"
242
+
243
+ # The router Devise should use to generate routes. Defaults
244
+ # to :main_app. Should be overridden by engines in order
245
+ # to provide custom routes.
246
+ mattr_accessor :router_name
247
+ @@router_name = nil
248
+
249
+ # Set the OmniAuth path prefix so it can be overridden when
250
+ # Devise is used in a mountable engine
251
+ mattr_accessor :omniauth_path_prefix
252
+ @@omniauth_path_prefix = nil
253
+
254
+ # Set if we should clean up the CSRF Token on authentication
255
+ mattr_accessor :clean_up_csrf_token_on_authentication
256
+ @@clean_up_csrf_token_on_authentication = true
257
+
258
+ # PRIVATE CONFIGURATION
259
+
260
+ # Store scopes mappings.
261
+ mattr_reader :mappings
262
+ @@mappings = ActiveSupport::OrderedHash.new
263
+
264
+ # OmniAuth configurations.
265
+ mattr_reader :omniauth_configs
266
+ @@omniauth_configs = ActiveSupport::OrderedHash.new
267
+
268
+ # Define a set of modules that are called when a mapping is added.
269
+ mattr_reader :helpers
270
+ @@helpers = Set.new
271
+ @@helpers << Devise::Controllers::Helpers
272
+
273
+ # Private methods to interface with Warden.
274
+ mattr_accessor :warden_config
275
+ @@warden_config = nil
276
+ @@warden_config_blocks = []
277
+
278
+ # When true, enter in paranoid mode to avoid user enumeration.
279
+ mattr_accessor :paranoid
280
+ @@paranoid = false
281
+
282
+ # When true, warn user if they just used next-to-last attempt of authentication
283
+ mattr_accessor :last_attempt_warning
284
+ @@last_attempt_warning = true
285
+
286
+ # Stores the token generator
287
+ mattr_accessor :token_generator
288
+ @@token_generator = nil
289
+
290
+ # Default way to setup Devise. Run rails generate devise_install to create
291
+ # a fresh initializer with all configuration values.
292
+ def self.setup
293
+ yield self
294
+ end
295
+
296
+ class Getter
297
+ def initialize name
298
+ @name = name
299
+ end
300
+
301
+ def get
302
+ ActiveSupport::Dependencies.constantize(@name)
303
+ end
304
+ end
305
+
306
+ def self.ref(arg)
307
+ if defined?(ActiveSupport::Dependencies::ClassCache)
308
+ ActiveSupport::Dependencies::reference(arg)
309
+ Getter.new(arg)
310
+ else
311
+ ActiveSupport::Dependencies.ref(arg)
312
+ end
313
+ end
314
+
315
+ def self.available_router_name
316
+ router_name || :main_app
317
+ end
318
+
319
+ def self.omniauth_providers
320
+ omniauth_configs.keys
321
+ end
322
+
323
+ # Get the mailer class from the mailer reference object.
324
+ def self.mailer
325
+ @@mailer_ref.get
326
+ end
327
+
328
+ # Set the mailer reference object to access the mailer.
329
+ def self.mailer=(class_name)
330
+ @@mailer_ref = ref(class_name)
331
+ end
332
+ self.mailer = "Devise::Mailer"
333
+
334
+ # Small method that adds a mapping to Devise.
335
+ def self.add_mapping(resource, options)
336
+ mapping = Devise::Mapping.new(resource, options)
337
+ @@mappings[mapping.name] = mapping
338
+ @@default_scope ||= mapping.name
339
+ @@helpers.each { |h| h.define_helpers(mapping) }
340
+ mapping
341
+ end
342
+
343
+ # Make Devise aware of an 3rd party Devise-module (like invitable). For convenience.
344
+ #
345
+ # == Options:
346
+ #
347
+ # +model+ - String representing the load path to a custom *model* for this module (to autoload.)
348
+ # +controller+ - Symbol representing the name of an existing or custom *controller* for this module.
349
+ # +route+ - Symbol representing the named *route* helper for this module.
350
+ # +strategy+ - Symbol representing if this module got a custom *strategy*.
351
+ # +insert_at+ - Integer representing the order in which this module's model will be included
352
+ #
353
+ # All values, except :model, accept also a boolean and will have the same name as the given module
354
+ # name.
355
+ #
356
+ # == Examples:
357
+ #
358
+ # Devise.add_module(:party_module)
359
+ # Devise.add_module(:party_module, strategy: true, controller: :sessions)
360
+ # Devise.add_module(:party_module, model: 'party_module/model')
361
+ # Devise.add_module(:party_module, insert_at: 0)
362
+ #
363
+ def self.add_module(module_name, options = {})
364
+ options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input, :insert_at)
365
+
366
+ ALL.insert (options[:insert_at] || -1), module_name
367
+
368
+ if strategy = options[:strategy]
369
+ strategy = (strategy == true ? module_name : strategy)
370
+ STRATEGIES[module_name] = strategy
371
+ end
372
+
373
+ if controller = options[:controller]
374
+ controller = (controller == true ? module_name : controller)
375
+ CONTROLLERS[module_name] = controller
376
+ end
377
+
378
+ NO_INPUT << strategy if options[:no_input]
379
+
380
+ if route = options[:route]
381
+ case route
382
+ when TrueClass
383
+ key, value = module_name, []
384
+ when Symbol
385
+ key, value = route, []
386
+ when Hash
387
+ key, value = route.keys.first, route.values.flatten
388
+ else
389
+ raise ArgumentError, ":route should be true, a Symbol or a Hash"
390
+ end
391
+
392
+ URL_HELPERS[key] ||= []
393
+ URL_HELPERS[key].concat(value)
394
+ URL_HELPERS[key].uniq!
395
+
396
+ ROUTES[module_name] = key
397
+ end
398
+
399
+ if options[:model]
400
+ path = (options[:model] == true ? "devise/models/#{module_name}" : options[:model])
401
+ camelized = ActiveSupport::Inflector.camelize(module_name.to_s)
402
+ Devise::Models.send(:autoload, camelized.to_sym, path)
403
+ end
404
+
405
+ Devise::Mapping.add_module module_name
406
+ end
407
+
408
+ # Sets warden configuration using a block that will be invoked on warden
409
+ # initialization.
410
+ #
411
+ # Devise.setup do |config|
412
+ # config.allow_unconfirmed_access_for = 2.days
413
+ #
414
+ # config.warden do |manager|
415
+ # # Configure warden to use other strategies, like oauth.
416
+ # manager.oauth(:twitter)
417
+ # end
418
+ # end
419
+ def self.warden(&block)
420
+ @@warden_config_blocks << block
421
+ end
422
+
423
+ # Specify an OmniAuth provider.
424
+ #
425
+ # config.omniauth :github, APP_ID, APP_SECRET
426
+ #
427
+ def self.omniauth(provider, *args)
428
+ @@helpers << Devise::OmniAuth::UrlHelpers
429
+ config = Devise::OmniAuth::Config.new(provider, args)
430
+ @@omniauth_configs[config.strategy_name.to_sym] = config
431
+ end
432
+
433
+ # Include helpers in the given scope to AC and AV.
434
+ def self.include_helpers(scope)
435
+ ActiveSupport.on_load(:action_controller) do
436
+ include scope::Helpers if defined?(scope::Helpers)
437
+ include scope::UrlHelpers
438
+ end
439
+
440
+ ActiveSupport.on_load(:action_view) do
441
+ include scope::UrlHelpers
442
+ end
443
+ end
444
+
445
+ # Regenerates url helpers considering Devise.mapping
446
+ def self.regenerate_helpers!
447
+ Devise::Controllers::UrlHelpers.remove_helpers!
448
+ Devise::Controllers::UrlHelpers.generate_helpers!
449
+ end
450
+
451
+ # A method used internally to setup warden manager from the Rails initialize
452
+ # block.
453
+ def self.configure_warden! #:nodoc:
454
+ @@warden_configured ||= begin
455
+ warden_config.failure_app = Devise::Delegator.new
456
+ warden_config.default_scope = Devise.default_scope
457
+ warden_config.intercept_401 = false
458
+
459
+ Devise.mappings.each_value do |mapping|
460
+ warden_config.scope_defaults mapping.name, strategies: mapping.strategies
461
+
462
+ warden_config.serialize_into_session(mapping.name) do |record|
463
+ mapping.to.serialize_into_session(record)
464
+ end
465
+
466
+ warden_config.serialize_from_session(mapping.name) do |key|
467
+ # Previous versions contained an additional entry at the beginning of
468
+ # key with the record's class name.
469
+ args = key[-2, 2]
470
+ mapping.to.serialize_from_session(*args)
471
+ end
472
+ end
473
+
474
+ @@warden_config_blocks.map { |block| block.call Devise.warden_config }
475
+ true
476
+ end
477
+ end
478
+
479
+ # Generate a friendly string randomly to be used as token.
480
+ def self.friendly_token
481
+ SecureRandom.urlsafe_base64(15).tr('lIO0', 'sxyz')
482
+ end
483
+
484
+ # constant-time comparison algorithm to prevent timing attacks
485
+ def self.secure_compare(a, b)
486
+ return false if a.blank? || b.blank? || a.bytesize != b.bytesize
487
+ l = a.unpack "C#{a.bytesize}"
488
+
489
+ res = 0
490
+ b.each_byte { |byte| res |= byte ^ l.shift }
491
+ res == 0
492
+ end
493
+ end
494
+
495
+ require 'warden'
496
+ require 'devise/mapping'
497
+ require 'devise/models'
498
+ require 'devise/modules'
499
+ require 'devise/rails'