authpwn_rails 0.16.2 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -6
  3. data/Gemfile +7 -8
  4. data/Gemfile.lock +97 -113
  5. data/Gemfile.rails4 +8 -9
  6. data/{Gemfile.rails3 → Gemfile.rails41} +6 -7
  7. data/Gemfile.rails42 +17 -0
  8. data/README.rdoc +1 -2
  9. data/Rakefile +1 -1
  10. data/VERSION +1 -1
  11. data/app/models/credentials/email.rb +15 -37
  12. data/app/models/credentials/omni_auth_uid.rb +96 -0
  13. data/app/models/credentials/password.rb +0 -5
  14. data/app/models/tokens/base.rb +11 -38
  15. data/authpwn_rails.gemspec +35 -33
  16. data/lib/authpwn_rails/credential_model.rb +1 -5
  17. data/lib/authpwn_rails/generators/all_generator.rb +3 -1
  18. data/lib/authpwn_rails/generators/templates/001_create_users.rb +3 -3
  19. data/lib/authpwn_rails/generators/templates/003_create_credentials.rb +7 -7
  20. data/lib/authpwn_rails/generators/templates/credentials.yml +13 -13
  21. data/lib/authpwn_rails/generators/templates/omniauth_initializer.rb +13 -0
  22. data/lib/authpwn_rails/generators/templates/session_controller_test.rb +22 -0
  23. data/lib/authpwn_rails/generators/templates/session_mailer/email_verification_email.html.erb +3 -3
  24. data/lib/authpwn_rails/generators/templates/session_mailer/email_verification_email.text.erb +1 -1
  25. data/lib/authpwn_rails/generators/templates/session_mailer/reset_password_email.html.erb +3 -3
  26. data/lib/authpwn_rails/generators/templates/session_mailer/reset_password_email.text.erb +1 -1
  27. data/lib/authpwn_rails/generators/templates/session_mailer.rb +1 -1
  28. data/lib/authpwn_rails/generators/templates/session_mailer_test.rb +14 -4
  29. data/lib/authpwn_rails/generators/templates/user.rb +40 -5
  30. data/lib/authpwn_rails/http_basic.rb +6 -5
  31. data/lib/authpwn_rails/routes.rb +20 -7
  32. data/lib/authpwn_rails/session.rb +1 -1
  33. data/lib/authpwn_rails/session_controller.rb +48 -12
  34. data/lib/authpwn_rails/session_mailer.rb +13 -14
  35. data/lib/authpwn_rails/session_model.rb +4 -24
  36. data/lib/authpwn_rails/user_extensions/email_field.rb +5 -21
  37. data/lib/authpwn_rails/user_extensions/password_field.rb +0 -4
  38. data/lib/authpwn_rails/user_model.rb +46 -12
  39. data/lib/authpwn_rails.rb +0 -2
  40. data/test/cookie_controller_test.rb +1 -7
  41. data/test/credentials/omni_auth_uid_credential_test.rb +141 -0
  42. data/test/helpers/action_controller.rb +2 -8
  43. data/test/helpers/db_setup.rb +8 -16
  44. data/test/helpers/routes.rb +35 -30
  45. data/test/helpers/test_order.rb +3 -0
  46. data/test/http_basic_controller_test.rb +7 -18
  47. data/test/routes_test.rb +19 -10
  48. data/test/session_controller_api_test.rb +181 -30
  49. data/test/session_controller_test.rb +6 -0
  50. data/test/session_mailer_api_test.rb +18 -13
  51. data/test/session_mailer_test.rb +6 -0
  52. data/test/test_helper.rb +3 -3
  53. data/test/user_test.rb +54 -7
  54. metadata +65 -64
  55. data/app/models/credentials/facebook.rb +0 -63
  56. data/lib/authpwn_rails/facebook_session.rb +0 -33
  57. data/lib/authpwn_rails/user_extensions/facebook_fields.rb +0 -63
  58. data/test/credentials/facebook_credential_test.rb +0 -64
  59. data/test/facebook_controller_test.rb +0 -65
  60. data/test/user_extensions/facebook_fields_test.rb +0 -61
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38257de1d56ba7c5ea75d7e055fbe62d5a8cf579
4
- data.tar.gz: 70b9271b0f567bf5c358530371ea9f06bd9f93e0
3
+ metadata.gz: e9776c5aa80187c9368f044da7036cb46c872e3e
4
+ data.tar.gz: 2df0b77fc051007d52ea662efb289bedcbbd6ead
5
5
  SHA512:
6
- metadata.gz: 4b89f3ff51230ef53e527075a8fb898e63de72c4276e4d3b3dd5e48dd6aa83312cb16bbfcf629cdb82e5981e24a43bf767f2851d84b2cedf24c65caaaf378017
7
- data.tar.gz: 86d7b0f0f9a05826fc61d1b41461a20b1a8a65e0bc189b47cb9fbb70bce8cf091104f613d20eb76a8a35e0a65d1541756756a7a0c29ebb6dda0451e997fb3b95
6
+ metadata.gz: 3a3c415f26386f64090d662398eee705a573ecf6f10cff87ae754eb3f2e65d26f729e4cc6ac91d494c8f36acc4a560a1520b711b99d933e6609dee2d2c151e26
7
+ data.tar.gz: 261ff309c4d7c7b8bc404d13b4fe7da501801f68c2b4881d9fa55a573ef253bb7f54c16106aa17b2d51d6b53d2843887afa1f9b1e0d52bf5752275f8c1561201
data/.travis.yml CHANGED
@@ -5,13 +5,10 @@ env:
5
5
  - DB=pg DB_USER=postgres
6
6
  - DB=sqlite
7
7
  gemfile:
8
- - Gemfile.rails3
9
8
  - Gemfile.rails4
9
+ - Gemfile.rails41
10
+ - Gemfile.rails42
10
11
  rvm:
11
- - 1.9.3
12
12
  - 2.0.0
13
+ - 2.1.0
13
14
  - rbx
14
- matrix:
15
- exclude:
16
- - gemfile: Gemfile.rails3
17
- rvm: 2.0.0
data/Gemfile CHANGED
@@ -1,17 +1,16 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'fbgraph_rails', '>= 0.2.2'
4
-
5
- gem 'rails', '>= 3.2.17'
3
+ gem 'rails', '>= 4.0.9'
6
4
 
7
5
  group :development do
8
- gem 'bundler', '>= 1.3.5'
6
+ gem 'bundler', '>= 1.7.3'
9
7
  gem 'mocha', '>= 0.14.0'
10
- gem 'jeweler', '>= 1.8.8'
8
+ gem 'jeweler', '>= 2.0.1'
11
9
  gem 'simplecov', '>= 0'
12
- gem 'mysql2', '>= 0.3.14'
13
- gem 'pg', '>= 0.17.0'
14
- gem 'sqlite3', '>= 1.3.8'
10
+ gem 'mysql2', '>= 0.3.16'
11
+ gem 'omniauth', '>= 1.2.2'
12
+ gem 'pg', '>= 0.17.1'
13
+ gem 'sqlite3', '>= 1.3.9'
15
14
  gem 'rubysl', platforms: [:rbx]
16
15
  gem 'rubysl-bundler', platforms: [:rbx]
17
16
  gem 'rubysl-rake', platforms: [:rbx]
data/Gemfile.lock CHANGED
@@ -1,67 +1,55 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- actionmailer (4.0.3)
5
- actionpack (= 4.0.3)
6
- mail (~> 2.5.4)
7
- actionpack (4.0.3)
8
- activesupport (= 4.0.3)
9
- builder (~> 3.1.0)
10
- erubis (~> 2.7.0)
4
+ actionmailer (4.1.7)
5
+ actionpack (= 4.1.7)
6
+ actionview (= 4.1.7)
7
+ mail (~> 2.5, >= 2.5.4)
8
+ actionpack (4.1.7)
9
+ actionview (= 4.1.7)
10
+ activesupport (= 4.1.7)
11
11
  rack (~> 1.5.2)
12
12
  rack-test (~> 0.6.2)
13
- activemodel (4.0.3)
14
- activesupport (= 4.0.3)
15
- builder (~> 3.1.0)
16
- activerecord (4.0.3)
17
- activemodel (= 4.0.3)
18
- activerecord-deprecated_finders (~> 1.0.2)
19
- activesupport (= 4.0.3)
20
- arel (~> 4.0.0)
21
- activerecord-deprecated_finders (1.0.3)
22
- activesupport (4.0.3)
23
- i18n (~> 0.6, >= 0.6.4)
24
- minitest (~> 4.2)
25
- multi_json (~> 1.3)
13
+ actionview (4.1.7)
14
+ activesupport (= 4.1.7)
15
+ builder (~> 3.1)
16
+ erubis (~> 2.7.0)
17
+ activemodel (4.1.7)
18
+ activesupport (= 4.1.7)
19
+ builder (~> 3.1)
20
+ activerecord (4.1.7)
21
+ activemodel (= 4.1.7)
22
+ activesupport (= 4.1.7)
23
+ arel (~> 5.0.0)
24
+ activesupport (4.1.7)
25
+ i18n (~> 0.6, >= 0.6.9)
26
+ json (~> 1.7, >= 1.7.7)
27
+ minitest (~> 5.1)
26
28
  thread_safe (~> 0.1)
27
- tzinfo (~> 0.3.37)
28
- addressable (2.3.5)
29
- arel (4.0.2)
30
- atomic (1.1.14)
31
- builder (3.1.4)
32
- descendants_tracker (0.0.3)
33
- docile (1.1.3)
29
+ tzinfo (~> 1.1)
30
+ addressable (2.3.6)
31
+ arel (5.0.1.20140414130214)
32
+ builder (3.2.2)
33
+ descendants_tracker (0.0.4)
34
+ thread_safe (~> 0.3, >= 0.3.1)
35
+ docile (1.1.5)
34
36
  erubis (2.7.0)
35
37
  faraday (0.9.0)
36
38
  multipart-post (>= 1.2, < 3)
37
- fbgraph (1.10.0)
38
- activesupport
39
- faraday (>= 0.7.5)
40
- hashie (>= 1.0.0)
41
- i18n
42
- json (>= 1.0.0)
43
- oauth2 (>= 0.5.0)
44
- rest-client
45
- fbgraph_rails (0.2.2)
46
- erubis (>= 2.7.0)
47
- fbgraph (>= 1.8.3)
48
- json (>= 1.6.1)
49
- oauth2 (>= 0.5.0)
50
- rails (>= 3.1.0)
51
39
  ffi2-generators (0.1.1)
52
- git (1.2.6)
53
- github_api (0.11.2)
40
+ git (1.2.8)
41
+ github_api (0.12.2)
54
42
  addressable (~> 2.3)
55
- descendants_tracker (~> 0.0.1)
43
+ descendants_tracker (~> 0.0.4)
56
44
  faraday (~> 0.8, < 0.10)
57
- hashie (>= 1.2)
45
+ hashie (>= 3.3)
58
46
  multi_json (>= 1.7.5, < 2.0)
59
- nokogiri (~> 1.6.0)
47
+ nokogiri (~> 1.6.3)
60
48
  oauth2
61
- hashie (2.0.5)
62
- highline (1.6.20)
49
+ hashie (3.3.1)
50
+ highline (1.6.21)
63
51
  hike (1.2.3)
64
- i18n (0.6.9)
52
+ i18n (0.6.11)
65
53
  jeweler (2.0.1)
66
54
  builder
67
55
  bundler (>= 1.0)
@@ -72,53 +60,54 @@ GEM
72
60
  rake
73
61
  rdoc
74
62
  json (1.8.1)
75
- jwt (0.1.11)
76
- multi_json (>= 1.5)
77
- mail (2.5.4)
78
- mime-types (~> 1.16)
79
- treetop (~> 1.4.8)
80
- metaclass (0.0.3)
81
- mime-types (1.25.1)
82
- mini_portile (0.5.2)
83
- minitest (4.7.5)
84
- mocha (1.0.0)
63
+ jwt (1.0.0)
64
+ mail (2.6.3)
65
+ mime-types (>= 1.16, < 3)
66
+ metaclass (0.0.4)
67
+ mime-types (2.4.3)
68
+ mini_portile (0.6.0)
69
+ minitest (5.4.2)
70
+ mocha (1.1.0)
85
71
  metaclass (~> 0.0.1)
86
- multi_json (1.8.4)
72
+ multi_json (1.10.1)
87
73
  multi_xml (0.5.5)
88
74
  multipart-post (2.0.0)
89
- mysql2 (0.3.15)
90
- nokogiri (1.6.1)
91
- mini_portile (~> 0.5.0)
92
- oauth2 (0.9.3)
75
+ mysql2 (0.3.16)
76
+ nokogiri (1.6.3.1)
77
+ mini_portile (= 0.6.0)
78
+ oauth2 (1.0.0)
93
79
  faraday (>= 0.8, < 0.10)
94
- jwt (~> 0.1.8)
80
+ jwt (~> 1.0)
95
81
  multi_json (~> 1.3)
96
82
  multi_xml (~> 0.5)
97
83
  rack (~> 1.2)
84
+ omniauth (1.2.2)
85
+ hashie (>= 1.2, < 4)
86
+ rack (~> 1.0)
98
87
  pg (0.17.1)
99
- polyglot (0.3.4)
100
88
  rack (1.5.2)
101
89
  rack-test (0.6.2)
102
90
  rack (>= 1.0)
103
- rails (4.0.3)
104
- actionmailer (= 4.0.3)
105
- actionpack (= 4.0.3)
106
- activerecord (= 4.0.3)
107
- activesupport (= 4.0.3)
91
+ rails (4.1.7)
92
+ actionmailer (= 4.1.7)
93
+ actionpack (= 4.1.7)
94
+ actionview (= 4.1.7)
95
+ activemodel (= 4.1.7)
96
+ activerecord (= 4.1.7)
97
+ activesupport (= 4.1.7)
108
98
  bundler (>= 1.3.0, < 2.0)
109
- railties (= 4.0.3)
110
- sprockets-rails (~> 2.0.0)
111
- railties (4.0.3)
112
- actionpack (= 4.0.3)
113
- activesupport (= 4.0.3)
99
+ railties (= 4.1.7)
100
+ sprockets-rails (~> 2.0)
101
+ railties (4.1.7)
102
+ actionpack (= 4.1.7)
103
+ activesupport (= 4.1.7)
114
104
  rake (>= 0.8.7)
115
105
  thor (>= 0.18.1, < 2.0)
116
- rake (10.1.1)
117
- rdoc (4.1.1)
106
+ rake (10.3.2)
107
+ rb-readline (0.5.1)
108
+ rdoc (4.1.2)
118
109
  json (~> 1.4)
119
- rest-client (1.6.7)
120
- mime-types (>= 1.16)
121
- rubysl (2.0.15)
110
+ rubysl (2.1.0)
122
111
  rubysl-abbrev (~> 2.0)
123
112
  rubysl-base64 (~> 2.0)
124
113
  rubysl-benchmark (~> 2.0)
@@ -152,7 +141,7 @@ GEM
152
141
  rubysl-io-nonblock (~> 2.0)
153
142
  rubysl-io-wait (~> 2.0)
154
143
  rubysl-ipaddr (~> 2.0)
155
- rubysl-irb (~> 2.0)
144
+ rubysl-irb (~> 2.1)
156
145
  rubysl-logger (~> 2.0)
157
146
  rubysl-mathn (~> 2.0)
158
147
  rubysl-matrix (~> 2.0)
@@ -181,7 +170,6 @@ GEM
181
170
  rubysl-pstore (~> 2.0)
182
171
  rubysl-pty (~> 2.0)
183
172
  rubysl-rational (~> 2.0)
184
- rubysl-readline (~> 2.0)
185
173
  rubysl-resolv (~> 2.0)
186
174
  rubysl-rexml (~> 2.0)
187
175
  rubysl-rinda (~> 2.0)
@@ -232,7 +220,7 @@ GEM
232
220
  rubysl-csv (2.0.2)
233
221
  rubysl-english (~> 2.0)
234
222
  rubysl-curses (2.0.1)
235
- rubysl-date (2.0.6)
223
+ rubysl-date (2.0.8)
236
224
  rubysl-delegate (2.0.1)
237
225
  rubysl-digest (2.0.3)
238
226
  rubysl-drb (2.0.1)
@@ -257,10 +245,10 @@ GEM
257
245
  rubysl-io-nonblock (2.0.0)
258
246
  rubysl-io-wait (2.0.0)
259
247
  rubysl-ipaddr (2.0.0)
260
- rubysl-irb (2.0.4)
248
+ rubysl-irb (2.1.0)
249
+ rb-readline (~> 0.5)
261
250
  rubysl-e2mmap (~> 2.0)
262
251
  rubysl-mathn (~> 2.0)
263
- rubysl-readline (~> 2.0)
264
252
  rubysl-thread (~> 2.0)
265
253
  rubysl-logger (2.0.0)
266
254
  rubysl-mathn (2.0.0)
@@ -285,12 +273,12 @@ GEM
285
273
  rubysl-observer (2.0.0)
286
274
  rubysl-open-uri (2.0.0)
287
275
  rubysl-open3 (2.0.0)
288
- rubysl-openssl (2.1.0)
276
+ rubysl-openssl (2.2.1)
289
277
  rubysl-optparse (2.0.1)
290
278
  rubysl-shellwords (~> 2.0)
291
279
  rubysl-ostruct (2.0.4)
292
- rubysl-pathname (2.0.0)
293
- rubysl-prettyprint (2.0.2)
280
+ rubysl-pathname (2.1.0)
281
+ rubysl-prettyprint (2.0.3)
294
282
  rubysl-prime (2.0.1)
295
283
  rubysl-profile (2.0.0)
296
284
  rubysl-profiler (2.0.1)
@@ -310,9 +298,8 @@ GEM
310
298
  rubysl-tempfile (~> 2.0)
311
299
  rubysl-thread (~> 2.0)
312
300
  rubysl-rational (2.0.1)
313
- rubysl-readline (2.0.2)
314
- rubysl-resolv (2.0.0)
315
- rubysl-rexml (2.0.2)
301
+ rubysl-resolv (2.1.0)
302
+ rubysl-rexml (2.0.3)
316
303
  rubysl-rinda (2.0.1)
317
304
  rubysl-rss (2.0.0)
318
305
  rubysl-scanf (2.0.0)
@@ -331,7 +318,7 @@ GEM
331
318
  rubysl-thwait (2.0.0)
332
319
  rubysl-time (2.0.3)
333
320
  rubysl-timeout (2.0.0)
334
- rubysl-tmpdir (2.0.0)
321
+ rubysl-tmpdir (2.0.1)
335
322
  rubysl-tsort (2.0.1)
336
323
  rubysl-un (2.0.0)
337
324
  rubysl-fileutils (~> 2.0)
@@ -342,43 +329,40 @@ GEM
342
329
  rubysl-xmlrpc (2.0.0)
343
330
  rubysl-yaml (2.0.4)
344
331
  rubysl-zlib (2.0.1)
345
- simplecov (0.8.2)
332
+ simplecov (0.9.1)
346
333
  docile (~> 1.1.0)
347
- multi_json
334
+ multi_json (~> 1.0)
348
335
  simplecov-html (~> 0.8.0)
349
336
  simplecov-html (0.8.0)
350
- sprockets (2.11.0)
337
+ sprockets (2.12.3)
351
338
  hike (~> 1.2)
352
339
  multi_json (~> 1.0)
353
340
  rack (~> 1.0)
354
341
  tilt (~> 1.1, != 1.3.0)
355
- sprockets-rails (2.0.1)
342
+ sprockets-rails (2.2.0)
356
343
  actionpack (>= 3.0)
357
344
  activesupport (>= 3.0)
358
- sprockets (~> 2.8)
359
- sqlite3 (1.3.8)
360
- thor (0.18.1)
361
- thread_safe (0.1.3)
362
- atomic
345
+ sprockets (>= 2.8, < 4.0)
346
+ sqlite3 (1.3.10)
347
+ thor (0.19.1)
348
+ thread_safe (0.3.4)
363
349
  tilt (1.4.1)
364
- treetop (1.4.15)
365
- polyglot
366
- polyglot (>= 0.3.1)
367
- tzinfo (0.3.38)
350
+ tzinfo (1.2.2)
351
+ thread_safe (~> 0.1)
368
352
 
369
353
  PLATFORMS
370
354
  ruby
371
355
 
372
356
  DEPENDENCIES
373
- bundler (>= 1.3.5)
374
- fbgraph_rails (>= 0.2.2)
375
- jeweler (>= 1.8.8)
357
+ bundler (>= 1.7.3)
358
+ jeweler (>= 2.0.1)
376
359
  mocha (>= 0.14.0)
377
- mysql2 (>= 0.3.14)
378
- pg (>= 0.17.0)
379
- rails (>= 3.2.17)
360
+ mysql2 (>= 0.3.16)
361
+ omniauth (>= 1.2.2)
362
+ pg (>= 0.17.1)
363
+ rails (>= 4.0.9)
380
364
  rubysl
381
365
  rubysl-bundler
382
366
  rubysl-rake
383
367
  simplecov
384
- sqlite3 (>= 1.3.8)
368
+ sqlite3 (>= 1.3.9)
data/Gemfile.rails4 CHANGED
@@ -1,17 +1,16 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'fbgraph_rails', '>= 0.2.2'
4
-
5
- gem 'rails', '~> 4.0'
3
+ gem 'rails', '~> 4.0.9'
6
4
 
7
5
  group :development do
8
- gem 'bundler', '>= 1.3.5'
9
- gem 'mocha', '>= 0.14.0'
10
- gem 'jeweler', '>= 1.8.8'
6
+ gem 'bundler', '>= 1.6.2'
7
+ gem 'mocha', '>= 1.1.0'
8
+ gem 'jeweler', '>= 2.0.1'
11
9
  gem 'simplecov', '>= 0'
12
- gem 'mysql2', '>= 0.3.14'
13
- gem 'pg', '>= 0.17.0'
14
- gem 'sqlite3', '>= 1.3.8'
10
+ gem 'mysql2', '>= 0.3.16'
11
+ gem 'omniauth', '>= 1.2.2'
12
+ gem 'pg', '>= 0.17.1'
13
+ gem 'sqlite3', '>= 1.3.10'
15
14
  gem 'rubysl', platforms: [:rbx]
16
15
  gem 'rubysl-bundler', platforms: [:rbx]
17
16
  gem 'rubysl-rake', platforms: [:rbx]
@@ -1,17 +1,16 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'fbgraph_rails', '>= 0.2.2'
4
-
5
- gem 'rails', '~> 3.2.17'
3
+ gem 'rails', '~> 4.1.7'
6
4
 
7
5
  group :development do
8
- gem 'bundler', '>= 1.5.3'
9
- gem 'mocha', '>= 1.0.0'
6
+ gem 'bundler', '>= 1.6.2'
7
+ gem 'mocha', '>= 1.1.0'
10
8
  gem 'jeweler', '>= 2.0.1'
11
9
  gem 'simplecov', '>= 0'
12
- gem 'mysql2', '>= 0.3.15'
10
+ gem 'mysql2', '>= 0.3.16'
11
+ gem 'omniauth', '>= 1.2.2'
13
12
  gem 'pg', '>= 0.17.1'
14
- gem 'sqlite3', '>= 1.3.8'
13
+ gem 'sqlite3', '>= 1.3.10'
15
14
  gem 'rubysl', platforms: [:rbx]
16
15
  gem 'rubysl-bundler', platforms: [:rbx]
17
16
  gem 'rubysl-rake', platforms: [:rbx]
data/Gemfile.rails42 ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '>= 4.2.0.beta2'
4
+
5
+ group :development do
6
+ gem 'bundler', '>= 1.6.2'
7
+ gem 'mocha', '>= 1.1.0'
8
+ gem 'jeweler', '>= 2.0.1'
9
+ gem 'simplecov', '>= 0'
10
+ gem 'mysql2', '>= 0.3.16'
11
+ gem 'omniauth', '>= 1.2.2'
12
+ gem 'pg', '>= 0.17.1'
13
+ gem 'sqlite3', '>= 1.3.10'
14
+ gem 'rubysl', platforms: [:rbx]
15
+ gem 'rubysl-bundler', platforms: [:rbx]
16
+ gem 'rubysl-rake', platforms: [:rbx]
17
+ end
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = authpwn_rails
2
2
 
3
- User authentication for a Ruby on Rails 3 application. Works with Facebook.
3
+ User authentication for a Ruby on Rails 4 application. Works with Facebook.
4
4
 
5
5
  == Integration
6
6
 
@@ -9,7 +9,6 @@ Scaffold user accounts, and session controller views.
9
9
 
10
10
  Wire authentication into your ApplicationController.
11
11
  authenticates_using_session
12
- authenticates_using_facebook
13
12
 
14
13
  Note: the code inside the models and controllers is tucked away in the plug-in.
15
14
  The scaffold models and controllers are there as extension points. You will be
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ Jeweler::Tasks.new do |gem|
16
16
  gem.name = "authpwn_rails"
17
17
  gem.homepage = "http://github.com/pwnall/authpwn_rails"
18
18
  gem.license = "MIT"
19
- gem.summary = %Q{User authentication for Rails 3 and 4 applications.}
19
+ gem.summary = %Q{User authentication for Rails 4 applications.}
20
20
  gem.description = %Q{Works with Facebook.}
21
21
  gem.email = "victor@costan.us"
22
22
  gem.authors = ["Victor Costan"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.16.2
1
+ 0.17.0
@@ -5,13 +5,7 @@ module Credentials
5
5
  class Email < ::Credential
6
6
  # E-mail is a user-visible attribute, so we want good error messages for some
7
7
  # of its validations. This means we must re-define them.
8
- if respond_to?(:clear_validators!)
9
- clear_validators!
10
- else
11
- # Backport clear_validators! from Rails 4.
12
- reset_callbacks :validate
13
- _validators.clear
14
- end
8
+ clear_validators!
15
9
 
16
10
  # The user whose email this is.
17
11
  validates :user, presence: true
@@ -26,17 +20,20 @@ class Email < ::Credential
26
20
  validates :key, presence: true, inclusion: { in: ['0', '1'] }
27
21
 
28
22
  before_validation :set_verified_to_false, on: :create
29
- # :nodoc: by default, e-mail addresses are not verified
23
+ # @private
24
+ # By default, e-mail addresses are not verified.
30
25
  def set_verified_to_false
31
26
  self.key ||= '0' if self.key.nil?
32
27
  end
28
+ private :set_verified_to_false
33
29
 
34
30
  # True if the e-mail has been verified via a token URL.
35
31
  def verified?
36
32
  key == '1'
37
33
  end
38
34
 
39
- # True if the e-mail has been verified via a token URL.
35
+ # @param [Boolean] new_verified_value true if the e-mail has been verified
36
+ # via a token URL.
40
37
  def verified=(new_verified_value)
41
38
  self.key = new_verified_value ? '1' : '0'
42
39
  new_verified_value ? true : false
@@ -59,34 +56,15 @@ class Email < ::Credential
59
56
  user.auth_bounce_reason(credential) || user
60
57
  end
61
58
 
62
- begin
63
- ActiveRecord::QueryMethods.instance_method :references
64
- # Rails 4.
65
-
66
- # Locates the credential holding an e-mail address.
67
- #
68
- # Returns the User matching the given e-mail, or nil if the e-mail is not
69
- # associated with any user.
70
- def self.with(email)
71
- # This method is likely to be used to kick off a complex authentication
72
- # process, so it makes sense to pre-fetch the user's other credentials.
73
- Credentials::Email.includes(user: :credentials).where(name: email).
74
- references(:credential).first
75
- end
76
- rescue NameError
77
- # Rails 3.
78
-
79
- def self.with(email)
80
- # This method is likely to be used to kick off a complex authentication
81
- # process, so it makes sense to pre-fetch the user's other credentials.
82
- Credentials::Email.includes(user: :credentials).where(name: email).
83
- first
84
- end
85
- end
86
-
87
- if ActiveRecord::Base.respond_to? :mass_assignment_sanitizer=
88
- # Forms can only change the e-mail in the credential.
89
- attr_accessible :email
59
+ # Locates the credential holding an e-mail address.
60
+ #
61
+ # Returns the User matching the given e-mail, or nil if the e-mail is not
62
+ # associated with any user.
63
+ def self.with(email)
64
+ # This method is likely to be used to kick off a complex authentication
65
+ # process, so it makes sense to pre-fetch the user's other credentials.
66
+ Credentials::Email.includes(user: :credentials).where(name: email).
67
+ references(:credential).first
90
68
  end
91
69
  end # class Credentials::Email
92
70
 
@@ -0,0 +1,96 @@
1
+ # :namespace
2
+ module Credentials
3
+
4
+ # Associates an OmniAuth authentication method with the user account.
5
+ class OmniAuthUid < ::Credential
6
+ # Virtual attribute: the OmniAuth provider.
7
+ validates :provider, presence: true, length: 1..64
8
+ def provider
9
+ @omni_provider ||= name.split(',', 2).first
10
+ end
11
+ def provider=(new_provider)
12
+ @omni_provider = new_provider
13
+ self.name = "#{@omni_provider},#{@omni_uid}"
14
+ end
15
+
16
+ # Virtual attribute: the UID generated by the OmniAuth provider.
17
+ validates :uid, presence: true, length: 1..128
18
+ def uid
19
+ @omni_uid ||= name.split(',', 2).last
20
+ end
21
+ def uid=(new_uid)
22
+ @omni_uid = new_uid
23
+ self.name = "#{@omni_provider},#{@omni_uid}"
24
+ end
25
+
26
+ # '1' unless this authentication method is blocked.
27
+ validates :key, presence: true, inclusion: { in: ['0', '1'] }
28
+
29
+ before_validation :set_blocked_to_false, on: :create
30
+ # @private
31
+ # By default, OmniAuth authentication methods are not blocked.
32
+ def set_blocked_to_false
33
+ self.key ||= '1' if self.key.nil?
34
+ end
35
+ private :set_blocked_to_false
36
+
37
+ # @return [Boolean] true if the authentication method has been blocked
38
+ def blocked?
39
+ key == '0'
40
+ end
41
+
42
+ # @param [Boolean] new_blocked_value true if this authentication method has
43
+ # been blocked
44
+ def blocked=(new_blocked_value)
45
+ self.key = new_blocked_value ? '0' : '1'
46
+ new_blocked_value ? true : false
47
+ end
48
+
49
+ # Locates a user given an OmniAuth hash.
50
+ #
51
+ # @return [User, Symbol] the authenticated User instance, or a symbol
52
+ # indicating the reason why the (potentially valid) hash was rejected
53
+ def self.authenticate(omniauth_hash)
54
+ credential = with omniauth_hash
55
+ if credential
56
+ user = credential.user
57
+ else
58
+ user = User.related_to_omniauth omniauth_hash
59
+ unless user
60
+ user = User.create_from_omniauth omniauth_hash
61
+ end
62
+
63
+ # If a user was found/created here, attach an OmniAuth credential to the
64
+ # user, so it always survives.
65
+ if user
66
+ credential = Credentials::OmniAuthUid.create! user: user,
67
+ provider: omniauth_hash['provider'], uid: omniauth_hash['uid']
68
+ end
69
+ end
70
+
71
+ return :invalid unless credential
72
+ return :blocked if credential.blocked?
73
+ user.auth_bounce_reason(credential) || user
74
+ end
75
+
76
+ # Locates a user given an OmniAuth hash.
77
+ #
78
+ # This returns a user
79
+ #
80
+ # @return [User] the User matching the given hash, or nil if the hash is not
81
+ # associated with any user
82
+ def self.with(omniauth_hash)
83
+ Credentials::OmniAuthUid.where(name: name_from_omniauth(omniauth_hash)).
84
+ first
85
+ end
86
+
87
+ # @param [Hash] omniauth_hash the hash given in the omniauth.auth Rack
88
+ # environment variable
89
+ # @return [String] the credential name derived from the hash
90
+ def self.name_from_omniauth(omniauth_hash)
91
+ "#{omniauth_hash['provider']},#{omniauth_hash['uid']}"
92
+ end
93
+ end # class Credentials::Email
94
+
95
+ end # namespace Credentials
96
+
@@ -80,11 +80,6 @@ class Password < ::Credential
80
80
  def self.random_salt
81
81
  [(0...12).map { |i| 1 + rand(255) }.pack('C*')].pack('m').strip
82
82
  end
83
-
84
- if ActiveRecord::Base.respond_to? :mass_assignment_sanitizer=
85
- # Forms can only change the plain-text password fields.
86
- attr_accessible :old_password, :password, :password_confirmation
87
- end
88
83
  end # class Credentials::Password
89
84
 
90
85
  end # namespace Credentials