sorcery 0.6.1 → 0.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. data/.travis.yml +2 -0
  2. data/Gemfile +2 -23
  3. data/Gemfile.lock +105 -77
  4. data/README.rdoc +32 -59
  5. data/Rakefile +29 -1
  6. data/VERSION +1 -1
  7. data/lib/generators/sorcery/USAGE +22 -0
  8. data/lib/generators/sorcery/install_generator.rb +77 -0
  9. data/lib/generators/sorcery/templates/initializer.rb +406 -0
  10. data/lib/generators/sorcery/templates/migration/activity_logging.rb +17 -0
  11. data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +13 -0
  12. data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/core.rb +3 -3
  13. data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/external.rb +1 -1
  14. data/lib/generators/sorcery/templates/migration/remember_me.rb +15 -0
  15. data/lib/generators/sorcery/templates/migration/reset_password.rb +17 -0
  16. data/lib/generators/sorcery/templates/migration/user_activation.rb +17 -0
  17. data/lib/sorcery/controller/submodules/activity_logging.rb +24 -10
  18. data/lib/sorcery/controller/submodules/brute_force_protection.rb +3 -2
  19. data/lib/sorcery/controller/submodules/external/protocols/certs/ca-bundle.crt +5182 -0
  20. data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +28 -9
  21. data/lib/sorcery/controller/submodules/external/providers/facebook.rb +12 -4
  22. data/lib/sorcery/controller/submodules/external/providers/github.rb +89 -0
  23. data/lib/sorcery/controller/submodules/external/providers/google.rb +90 -0
  24. data/lib/sorcery/controller/submodules/external/providers/liveid.rb +91 -0
  25. data/lib/sorcery/controller/submodules/external/providers/twitter.rb +8 -2
  26. data/lib/sorcery/controller/submodules/external.rb +17 -4
  27. data/lib/sorcery/controller/submodules/http_basic_auth.rb +1 -1
  28. data/lib/sorcery/controller/submodules/remember_me.rb +26 -15
  29. data/lib/sorcery/controller/submodules/session_timeout.rb +4 -4
  30. data/lib/sorcery/controller.rb +61 -38
  31. data/lib/sorcery/crypto_providers/aes256.rb +7 -3
  32. data/lib/sorcery/engine.rb +1 -0
  33. data/lib/sorcery/model/adapters/active_record.rb +17 -1
  34. data/lib/sorcery/model/adapters/mongo_mapper.rb +54 -0
  35. data/lib/sorcery/model/adapters/mongoid.rb +22 -4
  36. data/lib/sorcery/model/submodules/activity_logging.rb +4 -4
  37. data/lib/sorcery/model/submodules/brute_force_protection.rb +53 -14
  38. data/lib/sorcery/model/submodules/remember_me.rb +10 -3
  39. data/lib/sorcery/model/submodules/reset_password.rb +26 -11
  40. data/lib/sorcery/model/submodules/user_activation.rb +28 -10
  41. data/lib/sorcery/model/temporary_token.rb +8 -1
  42. data/lib/sorcery/model.rb +51 -19
  43. data/lib/sorcery/test_helpers/internal/rails.rb +1 -1
  44. data/lib/sorcery/test_helpers/rails.rb +2 -2
  45. data/lib/sorcery.rb +8 -7
  46. data/sorcery.gemspec +110 -223
  47. data/spec/Gemfile +1 -1
  48. data/spec/Gemfile.lock +26 -26
  49. data/spec/README.md +31 -0
  50. data/spec/rails3/Gemfile +5 -3
  51. data/spec/rails3/Gemfile.lock +74 -48
  52. data/spec/rails3/app/controllers/application_controller.rb +70 -23
  53. data/spec/rails3/app/mailers/sorcery_mailer.rb +7 -0
  54. data/spec/rails3/app/views/application/index.html.erb +17 -0
  55. data/spec/rails3/app/views/sorcery_mailer/send_unlock_token_email.text.erb +1 -0
  56. data/spec/rails3/config/environments/in_memory.rb +35 -0
  57. data/spec/rails3/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +2 -0
  58. data/spec/rails3/spec/controller_activity_logging_spec.rb +33 -3
  59. data/spec/rails3/spec/controller_brute_force_protection_spec.rb +25 -3
  60. data/spec/rails3/spec/controller_oauth2_spec.rb +170 -25
  61. data/spec/rails3/spec/controller_remember_me_spec.rb +37 -6
  62. data/spec/rails3/spec/controller_session_timeout_spec.rb +4 -4
  63. data/spec/rails3/spec/controller_spec.rb +60 -2
  64. data/spec/rails3/spec/integration_spec.rb +23 -0
  65. data/spec/rails3/spec/spec_helper.rb +6 -5
  66. data/spec/rails3_mongo_mapper/.gitignore +4 -0
  67. data/spec/rails3_mongo_mapper/.rspec +1 -0
  68. data/spec/{sinatra_modular → rails3_mongo_mapper}/Gemfile +6 -5
  69. data/spec/rails3_mongo_mapper/Gemfile.lock +154 -0
  70. data/spec/{sinatra → rails3_mongo_mapper}/Rakefile +3 -3
  71. data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +108 -0
  72. data/spec/rails3_mongo_mapper/app/helpers/application_helper.rb +2 -0
  73. data/spec/rails3_mongo_mapper/app/models/authentication.rb +6 -0
  74. data/spec/rails3_mongo_mapper/app/models/user.rb +5 -0
  75. data/spec/rails3_mongo_mapper/app/views/layouts/application.html.erb +14 -0
  76. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.html.erb +17 -0
  77. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.text.erb +9 -0
  78. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.html.erb +17 -0
  79. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.text.erb +9 -0
  80. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.html.erb +16 -0
  81. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.text.erb +8 -0
  82. data/spec/rails3_mongo_mapper/config/application.rb +51 -0
  83. data/spec/rails3_mongo_mapper/config/boot.rb +13 -0
  84. data/spec/rails3_mongo_mapper/config/environment.rb +5 -0
  85. data/spec/rails3_mongo_mapper/config/environments/development.rb +30 -0
  86. data/spec/rails3_mongo_mapper/config/environments/in_memory.rb +0 -0
  87. data/spec/rails3_mongo_mapper/config/environments/production.rb +49 -0
  88. data/spec/rails3_mongo_mapper/config/environments/test.rb +35 -0
  89. data/spec/rails3_mongo_mapper/config/initializers/backtrace_silencers.rb +7 -0
  90. data/spec/rails3_mongo_mapper/config/initializers/inflections.rb +10 -0
  91. data/spec/rails3_mongo_mapper/config/initializers/mime_types.rb +5 -0
  92. data/spec/rails3_mongo_mapper/config/initializers/mongo.rb +2 -0
  93. data/spec/rails3_mongo_mapper/config/initializers/secret_token.rb +7 -0
  94. data/spec/rails3_mongo_mapper/config/initializers/session_store.rb +8 -0
  95. data/spec/rails3_mongo_mapper/config/locales/en.yml +5 -0
  96. data/spec/rails3_mongo_mapper/config/routes.rb +59 -0
  97. data/spec/rails3_mongo_mapper/config.ru +4 -0
  98. data/spec/rails3_mongo_mapper/db/schema.rb +23 -0
  99. data/spec/rails3_mongo_mapper/db/seeds.rb +7 -0
  100. data/spec/rails3_mongo_mapper/lib/tasks/.gitkeep +0 -0
  101. data/spec/rails3_mongo_mapper/public/404.html +26 -0
  102. data/spec/rails3_mongo_mapper/public/422.html +26 -0
  103. data/spec/rails3_mongo_mapper/public/500.html +26 -0
  104. data/spec/rails3_mongo_mapper/public/favicon.ico +0 -0
  105. data/spec/rails3_mongo_mapper/public/images/rails.png +0 -0
  106. data/spec/rails3_mongo_mapper/public/javascripts/application.js +2 -0
  107. data/spec/rails3_mongo_mapper/public/javascripts/controls.js +965 -0
  108. data/spec/rails3_mongo_mapper/public/javascripts/dragdrop.js +974 -0
  109. data/spec/rails3_mongo_mapper/public/javascripts/effects.js +1123 -0
  110. data/spec/rails3_mongo_mapper/public/javascripts/prototype.js +6001 -0
  111. data/spec/rails3_mongo_mapper/public/javascripts/rails.js +175 -0
  112. data/spec/rails3_mongo_mapper/public/robots.txt +5 -0
  113. data/spec/rails3_mongo_mapper/public/stylesheets/.gitkeep +0 -0
  114. data/spec/rails3_mongo_mapper/script/rails +6 -0
  115. data/spec/rails3_mongo_mapper/spec/controller_spec.rb +163 -0
  116. data/spec/rails3_mongo_mapper/spec/spec_helper.orig.rb +27 -0
  117. data/spec/rails3_mongo_mapper/spec/spec_helper.rb +55 -0
  118. data/spec/rails3_mongo_mapper/spec/user_activation_spec.rb +9 -0
  119. data/spec/rails3_mongo_mapper/spec/user_activity_logging_spec.rb +8 -0
  120. data/spec/rails3_mongo_mapper/spec/user_brute_force_protection_spec.rb +8 -0
  121. data/spec/rails3_mongo_mapper/spec/user_oauth_spec.rb +8 -0
  122. data/spec/rails3_mongo_mapper/spec/user_remember_me_spec.rb +8 -0
  123. data/spec/rails3_mongo_mapper/spec/user_reset_password_spec.rb +8 -0
  124. data/spec/rails3_mongo_mapper/spec/user_spec.rb +37 -0
  125. data/spec/rails3_mongo_mapper/vendor/plugins/.gitkeep +0 -0
  126. data/spec/rails3_mongoid/Gemfile +2 -1
  127. data/spec/rails3_mongoid/Gemfile.lock +46 -45
  128. data/spec/rails3_mongoid/app/controllers/application_controller.rb +5 -0
  129. data/spec/rails3_mongoid/config/mongoid.yml +1 -1
  130. data/spec/rails3_mongoid/script/rails +0 -0
  131. data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +105 -0
  132. data/spec/rails3_mongoid/spec/controller_spec.rb +174 -0
  133. data/spec/rails3_mongoid/spec/user_spec.rb +1 -0
  134. data/spec/shared_examples/user_activation_shared_examples.rb +72 -42
  135. data/spec/shared_examples/user_remember_me_shared_examples.rb +2 -1
  136. data/spec/shared_examples/user_reset_password_shared_examples.rb +81 -28
  137. data/spec/shared_examples/user_shared_examples.rb +36 -8
  138. data/spec/sorcery_crypto_providers_spec.rb +5 -1
  139. metadata +239 -346
  140. data/lib/generators/sorcery_migration/sorcery_migration_generator.rb +0 -24
  141. data/lib/generators/sorcery_migration/templates/activity_logging.rb +0 -17
  142. data/lib/generators/sorcery_migration/templates/brute_force_protection.rb +0 -11
  143. data/lib/generators/sorcery_migration/templates/remember_me.rb +0 -15
  144. data/lib/generators/sorcery_migration/templates/reset_password.rb +0 -13
  145. data/lib/generators/sorcery_migration/templates/user_activation.rb +0 -17
  146. data/lib/sorcery/controller/adapters/sinatra.rb +0 -104
  147. data/lib/sorcery/initializers/initializer.rb +0 -178
  148. data/lib/sorcery/sinatra.rb +0 -4
  149. data/lib/sorcery/test_helpers/internal/sinatra.rb +0 -74
  150. data/lib/sorcery/test_helpers/internal/sinatra_modular.rb +0 -74
  151. data/lib/sorcery/test_helpers/sinatra.rb +0 -88
  152. data/spec/rails3/Rakefile.unused +0 -7
  153. data/spec/rails3/public/index.html +0 -239
  154. data/spec/sinatra/Gemfile +0 -15
  155. data/spec/sinatra/Gemfile.lock +0 -117
  156. data/spec/sinatra/authentication.rb +0 -3
  157. data/spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
  158. data/spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
  159. data/spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
  160. data/spec/sinatra/db/migrate/core/20101224223620_create_users.rb +0 -16
  161. data/spec/sinatra/db/migrate/external/20101224223628_create_authentications.rb +0 -14
  162. data/spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
  163. data/spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
  164. data/spec/sinatra/filters.rb +0 -27
  165. data/spec/sinatra/modular.rb +0 -157
  166. data/spec/sinatra/myapp.rb +0 -133
  167. data/spec/sinatra/spec/controller_activity_logging_spec.rb +0 -85
  168. data/spec/sinatra/spec/controller_brute_force_protection_spec.rb +0 -70
  169. data/spec/sinatra/spec/controller_http_basic_auth_spec.rb +0 -53
  170. data/spec/sinatra/spec/controller_oauth2_spec.rb +0 -99
  171. data/spec/sinatra/spec/controller_oauth_spec.rb +0 -100
  172. data/spec/sinatra/spec/controller_remember_me_spec.rb +0 -64
  173. data/spec/sinatra/spec/controller_session_timeout_spec.rb +0 -57
  174. data/spec/sinatra/spec/controller_spec.rb +0 -120
  175. data/spec/sinatra/spec/spec_helper.rb +0 -45
  176. data/spec/sinatra/user.rb +0 -6
  177. data/spec/sinatra/views/test_login.erb +0 -4
  178. data/spec/sinatra_modular/Gemfile.lock +0 -117
  179. data/spec/sinatra_modular/Rakefile +0 -11
  180. data/spec/sinatra_modular/authentication.rb +0 -3
  181. data/spec/sinatra_modular/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
  182. data/spec/sinatra_modular/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
  183. data/spec/sinatra_modular/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
  184. data/spec/sinatra_modular/db/migrate/core/20101224223620_create_users.rb +0 -16
  185. data/spec/sinatra_modular/db/migrate/external/20101224223628_create_authentications.rb +0 -14
  186. data/spec/sinatra_modular/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
  187. data/spec/sinatra_modular/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
  188. data/spec/sinatra_modular/filters.rb +0 -27
  189. data/spec/sinatra_modular/modular.rb +0 -157
  190. data/spec/sinatra_modular/myapp.rb +0 -133
  191. data/spec/sinatra_modular/sorcery_mailer.rb +0 -25
  192. data/spec/sinatra_modular/spec_modular/controller_activity_logging_spec.rb +0 -85
  193. data/spec/sinatra_modular/spec_modular/controller_brute_force_protection_spec.rb +0 -70
  194. data/spec/sinatra_modular/spec_modular/controller_http_basic_auth_spec.rb +0 -53
  195. data/spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb +0 -99
  196. data/spec/sinatra_modular/spec_modular/controller_oauth_spec.rb +0 -100
  197. data/spec/sinatra_modular/spec_modular/controller_remember_me_spec.rb +0 -64
  198. data/spec/sinatra_modular/spec_modular/controller_session_timeout_spec.rb +0 -57
  199. data/spec/sinatra_modular/spec_modular/controller_spec.rb +0 -116
  200. data/spec/sinatra_modular/spec_modular/spec.opts +0 -2
  201. data/spec/sinatra_modular/spec_modular/spec_helper.rb +0 -51
  202. data/spec/sinatra_modular/user.rb +0 -6
  203. data/spec/sinatra_modular/views/test_login.erb +0 -4
  204. /data/spec/{sinatra → rails3_mongo_mapper/app/mailers}/sorcery_mailer.rb +0 -0
  205. /data/spec/{sinatra → rails3_mongo_mapper}/spec/spec.opts +0 -0
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ rvm:
2
+ - 1.9.2
data/Gemfile CHANGED
@@ -1,24 +1,3 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
- gem 'oauth', "~> 0.4.4"
6
- gem 'oauth2', "~> 0.4.1"
1
+ source :rubygems
7
2
 
8
- # Add dependencies to develop your gem here.
9
- # Include everything needed to run rake, tests, features, etc.
10
- group :development do
11
- gem "rails", ">= 3.0.0"
12
- gem 'json', ">= 1.5.1"
13
- gem "mongoid", "~> 2.0"
14
- gem "bson_ext", "~> 1.3"
15
- gem "rspec", "~> 2.5.0"
16
- gem 'rspec-rails', "~> 2.5.0"
17
- gem 'ruby-debug19'
18
- gem 'sqlite3-ruby', :require => 'sqlite3'
19
- gem "yard", "~> 0.6.0"
20
- gem "bundler", "~> 1.0.0"
21
- gem "jeweler", "~> 1.5.2"
22
- gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
23
- gem 'timecop'
24
- end
3
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,103 +1,122 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sorcery (0.7.8)
5
+ bcrypt-ruby (~> 3.0.0)
6
+ bundler (>= 1.1.0)
7
+ oauth (~> 0.4.4)
8
+ oauth2 (~> 0.5.1)
9
+ sorcery
10
+
1
11
  GEM
2
12
  remote: http://rubygems.org/
3
13
  specs:
4
- actionmailer (3.1.0)
5
- actionpack (= 3.1.0)
6
- mail (~> 2.3.0)
7
- actionpack (3.1.0)
8
- activemodel (= 3.1.0)
9
- activesupport (= 3.1.0)
14
+ actionmailer (3.2.2)
15
+ actionpack (= 3.2.2)
16
+ mail (~> 2.4.0)
17
+ actionpack (3.2.2)
18
+ activemodel (= 3.2.2)
19
+ activesupport (= 3.2.2)
10
20
  builder (~> 3.0.0)
11
21
  erubis (~> 2.7.0)
12
- i18n (~> 0.6)
13
- rack (~> 1.3.2)
14
- rack-cache (~> 1.0.3)
15
- rack-mount (~> 0.8.2)
22
+ journey (~> 1.0.1)
23
+ rack (~> 1.4.0)
24
+ rack-cache (~> 1.1)
16
25
  rack-test (~> 0.6.1)
17
- sprockets (~> 2.0.0)
18
- activemodel (3.1.0)
19
- activesupport (= 3.1.0)
20
- bcrypt-ruby (~> 3.0.0)
26
+ sprockets (~> 2.1.2)
27
+ activemodel (3.2.2)
28
+ activesupport (= 3.2.2)
21
29
  builder (~> 3.0.0)
22
- i18n (~> 0.6)
23
- activerecord (3.1.0)
24
- activemodel (= 3.1.0)
25
- activesupport (= 3.1.0)
26
- arel (~> 2.2.1)
30
+ activerecord (3.2.2)
31
+ activemodel (= 3.2.2)
32
+ activesupport (= 3.2.2)
33
+ arel (~> 3.0.2)
27
34
  tzinfo (~> 0.3.29)
28
- activeresource (3.1.0)
29
- activemodel (= 3.1.0)
30
- activesupport (= 3.1.0)
31
- activesupport (3.1.0)
35
+ activeresource (3.2.2)
36
+ activemodel (= 3.2.2)
37
+ activesupport (= 3.2.2)
38
+ activesupport (3.2.2)
39
+ i18n (~> 0.6)
32
40
  multi_json (~> 1.0)
33
- addressable (2.2.6)
41
+ addressable (2.2.7)
34
42
  archive-tar-minitar (0.5.2)
35
- arel (2.2.1)
36
- bcrypt-ruby (3.0.0)
37
- bson (1.3.1)
38
- bson_ext (1.3.1)
43
+ arel (3.0.2)
44
+ bcrypt-ruby (3.0.1)
45
+ bson (1.6.1)
39
46
  builder (3.0.0)
40
- columnize (0.3.4)
47
+ capybara (1.1.2)
48
+ mime-types (>= 1.16)
49
+ nokogiri (>= 1.3.3)
50
+ rack (>= 1.0.0)
51
+ rack-test (>= 0.5.4)
52
+ selenium-webdriver (~> 2.0)
53
+ xpath (~> 0.1.4)
54
+ childprocess (0.3.1)
55
+ ffi (~> 1.0.6)
56
+ columnize (0.3.6)
41
57
  diff-lcs (1.1.3)
42
58
  erubis (2.7.0)
43
- faraday (0.6.1)
44
- addressable (~> 2.2.4)
45
- multipart-post (~> 1.1.0)
46
- rack (< 2, >= 1.1.0)
59
+ faraday (0.7.6)
60
+ addressable (~> 2.2)
61
+ multipart-post (~> 1.1)
62
+ rack (~> 1.1)
63
+ ffi (1.0.11)
47
64
  git (1.2.5)
48
65
  hike (1.2.1)
49
66
  i18n (0.6.0)
50
- jeweler (1.5.2)
51
- bundler (~> 1.0.0)
67
+ jeweler (1.8.3)
68
+ bundler (~> 1.0)
52
69
  git (>= 1.2.5)
53
70
  rake
54
- json (1.5.4)
71
+ rdoc
72
+ journey (1.0.3)
73
+ json (1.6.6)
55
74
  linecache19 (0.5.12)
56
75
  ruby_core_source (>= 0.1.4)
57
- mail (2.3.0)
76
+ mail (2.4.4)
58
77
  i18n (>= 0.4.0)
59
78
  mime-types (~> 1.16)
60
79
  treetop (~> 1.4.8)
61
- mime-types (1.16)
62
- mongo (1.3.1)
63
- bson (>= 1.3.1)
64
- mongoid (2.2.0)
65
- activemodel (~> 3.0)
80
+ mime-types (1.18)
81
+ mongo (1.6.1)
82
+ bson (~> 1.6.1)
83
+ mongoid (2.4.7)
84
+ activemodel (~> 3.1)
66
85
  mongo (~> 1.3)
67
86
  tzinfo (~> 0.3.22)
68
- multi_json (1.0.3)
69
- multipart-post (1.1.3)
87
+ multi_json (1.2.0)
88
+ multipart-post (1.1.5)
89
+ nokogiri (1.5.2)
70
90
  oauth (0.4.5)
71
- oauth2 (0.4.1)
72
- faraday (~> 0.6.1)
73
- multi_json (>= 0.0.5)
74
- polyglot (0.3.2)
75
- rack (1.3.2)
76
- rack-cache (1.0.3)
91
+ oauth2 (0.5.2)
92
+ faraday (~> 0.7)
93
+ multi_json (~> 1.0)
94
+ polyglot (0.3.3)
95
+ rack (1.4.1)
96
+ rack-cache (1.2)
77
97
  rack (>= 0.4)
78
- rack-mount (0.8.3)
79
- rack (>= 1.0.0)
80
98
  rack-ssl (1.3.2)
81
99
  rack
82
100
  rack-test (0.6.1)
83
101
  rack (>= 1.0)
84
- rails (3.1.0)
85
- actionmailer (= 3.1.0)
86
- actionpack (= 3.1.0)
87
- activerecord (= 3.1.0)
88
- activeresource (= 3.1.0)
89
- activesupport (= 3.1.0)
102
+ rails (3.2.2)
103
+ actionmailer (= 3.2.2)
104
+ actionpack (= 3.2.2)
105
+ activerecord (= 3.2.2)
106
+ activeresource (= 3.2.2)
107
+ activesupport (= 3.2.2)
90
108
  bundler (~> 1.0)
91
- railties (= 3.1.0)
92
- railties (3.1.0)
93
- actionpack (= 3.1.0)
94
- activesupport (= 3.1.0)
109
+ railties (= 3.2.2)
110
+ railties (3.2.2)
111
+ actionpack (= 3.2.2)
112
+ activesupport (= 3.2.2)
95
113
  rack-ssl (~> 1.3.2)
96
114
  rake (>= 0.8.7)
97
115
  rdoc (~> 3.4)
98
116
  thor (~> 0.14.6)
99
- rake (0.9.2)
100
- rdoc (3.9.4)
117
+ rake (0.9.2.2)
118
+ rdoc (3.12)
119
+ json (~> 1.4)
101
120
  rspec (2.5.0)
102
121
  rspec-core (~> 2.5.0)
103
122
  rspec-expectations (~> 2.5.0)
@@ -121,14 +140,21 @@ GEM
121
140
  ruby-debug-base19 (>= 0.11.19)
122
141
  ruby_core_source (0.1.5)
123
142
  archive-tar-minitar (>= 0.5.2)
124
- simplecov (0.4.2)
125
- simplecov-html (~> 0.4.4)
126
- simplecov-html (0.4.5)
127
- sprockets (2.0.0)
143
+ rubyzip (0.9.6.1)
144
+ selenium-webdriver (2.20.0)
145
+ childprocess (>= 0.2.5)
146
+ ffi (~> 1.0)
147
+ multi_json (~> 1.0)
148
+ rubyzip
149
+ simplecov (0.6.1)
150
+ multi_json (~> 1.0)
151
+ simplecov-html (~> 0.5.3)
152
+ simplecov-html (0.5.3)
153
+ sprockets (2.1.2)
128
154
  hike (~> 1.2)
129
155
  rack (~> 1.0)
130
- tilt (!= 1.3.0, ~> 1.1)
131
- sqlite3 (1.3.4)
156
+ tilt (~> 1.1, != 1.3.0)
157
+ sqlite3 (1.3.5)
132
158
  sqlite3-ruby (1.3.3)
133
159
  sqlite3 (>= 1.3.3)
134
160
  thor (0.14.6)
@@ -137,25 +163,27 @@ GEM
137
163
  treetop (1.4.10)
138
164
  polyglot
139
165
  polyglot (>= 0.3.1)
140
- tzinfo (0.3.29)
166
+ tzinfo (0.3.32)
167
+ xpath (0.1.4)
168
+ nokogiri (~> 1.3)
141
169
  yard (0.6.8)
142
170
 
143
171
  PLATFORMS
144
172
  ruby
145
173
 
146
174
  DEPENDENCIES
147
- bson_ext (~> 1.3)
148
- bundler (~> 1.0.0)
149
- jeweler (~> 1.5.2)
175
+ bcrypt-ruby (~> 3.0.0)
176
+ bundler (>= 1.1.0)
177
+ capybara (>= 1.1.2)
178
+ jeweler (~> 1.8.3)
150
179
  json (>= 1.5.1)
151
- mongoid (~> 2.0)
152
- oauth (~> 0.4.4)
153
- oauth2 (~> 0.4.1)
180
+ mongoid (~> 2.4.4)
154
181
  rails (>= 3.0.0)
155
182
  rspec (~> 2.5.0)
156
183
  rspec-rails (~> 2.5.0)
157
184
  ruby-debug19
158
185
  simplecov (>= 0.3.8)
186
+ sorcery!
159
187
  sqlite3-ruby
160
188
  timecop
161
189
  yard (~> 0.6.0)
data/README.rdoc CHANGED
@@ -1,12 +1,13 @@
1
+ {<img src="https://secure.travis-ci.org/NoamB/sorcery.png" />}[http://travis-ci.org/NoamB/sorcery]
2
+
1
3
  = sorcery
2
- Magical Authentication for Rails 3 and Sinatra.
3
- Supports ActiveRecord and Mongoid.
4
+ Magical Authentication for Rails 3.
5
+ Supports ActiveRecord, Mongoid and MongoMapper.
4
6
 
5
7
  Inspired by restful_authentication, Authlogic and Devise.
6
8
  Crypto code taken almost unchanged from Authlogic.
7
9
  OAuth code inspired by OmniAuth and Ryan Bates's railscasts about it.
8
10
 
9
-
10
11
  == Philosophy
11
12
 
12
13
 
@@ -24,12 +25,11 @@ Hopefully, I've achieved this. If not, let me know.
24
25
 
25
26
  == Useful Links:
26
27
 
28
+ Railscast: http://railscasts.com/episodes/283-authentication-with-sorcery
27
29
 
28
30
  Example Rails 3 app using sorcery: https://github.com/NoamB/sorcery-example-app
29
31
 
30
- Example Sinatra app using sorcery: https://github.com/NoamB/sorcery-example-app-sinatra
31
-
32
- Documentation: http://rubydoc.info/gems/sorcery/0.6.0/frames
32
+ Documentation: http://rubydoc.info/gems/sorcery/0.7.10/frames
33
33
 
34
34
  Check out the tutorials in the github wiki!
35
35
 
@@ -42,9 +42,10 @@ Below is a summary of the library methods. Most method names are self explaining
42
42
  # core
43
43
  require_login # this is a before filter
44
44
  login(username,password,remember_me = false)
45
+ auto_login(user)# login without credentials
45
46
  logout
46
- logged_in?
47
- current_user
47
+ logged_in? # available to view
48
+ current_user # available to view
48
49
  redirect_back_or_to # used when a user tries to access a page while logged out, is asked to login, and we want to return him back to the page he originally wanted.
49
50
  @user.external? # external users, such as facebook/twitter etc.
50
51
  User.authenticates_with_sorcery!
@@ -61,6 +62,7 @@ Below is a summary of the library methods. Most method names are self explaining
61
62
  create_from(provider) # create the user in the local app db.
62
63
 
63
64
  # remember me
65
+ auto_login(user, should_remember=false) # login without credentials, optional remember_me
64
66
  remember_me!
65
67
  forget_me!
66
68
 
@@ -81,66 +83,39 @@ Please see the tutorials in the github wiki for detailed usage information.
81
83
 
82
84
  If using bundler, first add 'sorcery' to your Gemfile:
83
85
 
84
- gem "sorcery"
86
+ gem "sorcery"
85
87
 
86
- And run
87
-
88
- bundle install
88
+ And run
89
+
90
+ bundle install
89
91
 
90
92
  Otherwise simply
91
93
 
92
- gem install sorcery
94
+ gem install sorcery
93
95
 
94
96
 
95
97
  == Rails 3 Configuration:
96
98
 
99
+ rails generate sorcery:install
97
100
 
98
- For Rails 3 create an initializer file using:
99
-
100
- rake sorcery:bootstrap
101
-
102
- This will create the file as config/initializers/sorcery.rb .
103
- Inside it the comments will tell you everything you need to know.
104
-
105
- For your convenience, Sorcery includes a migrations generator for Rails, which can be used like so:
106
-
107
- rails g sorcery_migration [list of submodules]
101
+ This will generate the core migration file, the initializer file and the 'User' model class.
108
102
 
109
- For example, for only the core functionality use:
103
+ rails generate sorcery:install remember_me reset_password
110
104
 
111
- rails g sorcery_migration core
105
+ This will generate the migrations files for remember_me and reset_password submodules
106
+ and will create the initializer file (and add submodules to it), and create the 'User' model class.
112
107
 
113
- To generate migrations for both the core AND 'remember_me' submodule:
108
+ rails generate sorcery:install --model Person
114
109
 
115
- rails g sorcery_migration core remember_me
110
+ This will generate the core migration file, the initializer and change the model class
111
+ (in the initializer and migration files) to the class 'Person' (and its pluralized version, 'people')
116
112
 
117
- These migrations use the default fields. You can choose to use these migrations or make your own tables and fields. Sorcery tries not to impose a database structure and naming scheme on your application.
113
+ rails generate sorcery:install http_basic_auth external remember_me --migrations
118
114
 
115
+ This will generate only the migration files for the specified submodules and will
116
+ add them to the initializer file.
119
117
 
120
- == Sinatra Configuration:
121
-
122
-
123
- For Sinatra you'll need to create the initializer manually. You can do it in the main app file or in a separate file you require (see example in example app). The code looks as follows:
124
-
125
- Sorcery::Controller::Config.submodules = [] # specify here the submodules you want to include
126
-
127
- Sorcery::Controller::Config.configure do |config|
128
- config.session_timeout = 10.minutes
129
- ...
130
- ...
131
-
132
- config.user_config do |user|
133
- user.username_attribute_name = :email
134
- ...
135
- ...
136
-
137
- end
138
- end
139
-
140
- Finally, to make all the code above take effect, we'll need to re-include the sorcery controller module:
141
-
142
- include Sorcery::Controller::Adapters::Sinatra
143
- include Sorcery::Controller
118
+ Inside the initializer, the comments will tell you what each setting does.
144
119
 
145
120
 
146
121
  == Full Features List by module:
@@ -150,6 +125,7 @@ Core (see lib/sorcery/model.rb and lib/sorcery/controller.rb):
150
125
  * login/logout, optional return user to requested url on login, configurable redirect for non-logged-in users.
151
126
  * password encryption, algorithms: bcrypt(default), md5, sha1, sha256, sha512, aes256, custom(yours!), none. Configurable stretches and salt.
152
127
  * configurable attribute names for username, password and email.
128
+ * allow multiple fields to serve as username.
153
129
 
154
130
  User Activation (see lib/sorcery/model/submodules/user_activation.rb):
155
131
  * User activation by email with optional success email.
@@ -206,13 +182,6 @@ I've got some thoughts which include (unordered):
206
182
  Have an idea? Let me know, and it might get into the gem!
207
183
 
208
184
 
209
- Other stuff:
210
- * Improve specs speed
211
- * Provide an easy way to run specs after install
212
- * Improve documentation
213
- * Try to reduce the number of library methods, and find better names to some
214
-
215
-
216
185
  == Backward compatibility
217
186
 
218
187
 
@@ -228,11 +197,15 @@ The same cannot be said about upgrading to x.4.0 and above, however.
228
197
 
229
198
  Important notes while upgrading:
230
199
 
200
+ * If upgrading from <= 0.6.1 to >= 0.7.0 you need to change 'username_attribute_name' to 'username_attribute_names' in initializer.
231
201
  * If upgrading from <= v0.5.1 to >= v0.5.2 you need to explicitly set your user_class model in the initializer file.
232
202
 
233
203
  # This line must come after the 'user config' block.
234
204
  config.user_class = User
235
205
 
206
+ * Sinatra support existed until v0.7.0 (including), but was dropped later due to being a maintenance nightmare.
207
+
208
+
236
209
  == Contributing to sorcery
237
210
 
238
211
 
data/Rakefile CHANGED
@@ -25,9 +25,10 @@ Jeweler::Tasks.new do |gem|
25
25
  # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
26
26
  # gem.add_runtime_dependency 'jabber4r', '> 0.1'
27
27
  # gem.add_development_dependency 'rspec', '> 1.2.3'
28
+ gem.add_runtime_dependency 'bundler', '1.1.0'
28
29
  gem.add_runtime_dependency 'bcrypt-ruby', '~> 3.0.0'
29
30
  gem.add_runtime_dependency 'oauth', '~> 0.4.4'
30
- gem.add_runtime_dependency 'oauth2', '~> 0.4.1'
31
+ gem.add_runtime_dependency 'oauth2', '~> 0.5.1'
31
32
  end
32
33
  Jeweler::RubygemsDotOrgTasks.new
33
34
 
@@ -50,7 +51,34 @@ task :all_sorcery_specs do
50
51
  directory_name = File.dirname(rakefile)
51
52
  sh <<-CMD
52
53
  cd #{directory_name}
54
+ bundle
53
55
  bundle exec rake
54
56
  CMD
55
57
  end
56
58
  end
59
+
60
+ desc "Bundle all folders"
61
+ task :bundle do
62
+ sh "bundle"
63
+ Dir['spec', 'spec/**'].each do |dir|
64
+ if Dir.exists?(dir) && File.exists?(dir + "/Gemfile")
65
+ sh <<-CMD
66
+ cd #{dir}
67
+ bundle
68
+ CMD
69
+ end
70
+ end
71
+ end
72
+
73
+ desc "Bundle update all folders"
74
+ task :bundle_update do
75
+ sh "bundle update"
76
+ Dir['spec', 'spec/**'].each do |dir|
77
+ if Dir.exists?(dir) && File.exists?(dir + "/Gemfile")
78
+ sh <<-CMD
79
+ cd #{dir}
80
+ bundle update
81
+ CMD
82
+ end
83
+ end
84
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.7.10
@@ -0,0 +1,22 @@
1
+ Description:
2
+ Generates the necessary files to get you up and running with Sorcery gem
3
+
4
+ Examples:
5
+ rails generate sorcery:install
6
+
7
+ This will generate the core migration file, the initializer file and the 'User' model class.
8
+
9
+ rails generate sorcery:install remember_me reset_password
10
+
11
+ This will generate the migrations files for remember_me and reset_password submodules
12
+ and will create the initializer file (and add submodules to it), and create the 'User' model class.
13
+
14
+ rails generate sorcery:install --model Person
15
+
16
+ This will generate the core migration file, the initializer and change the model class
17
+ (in the initializer and migration files) to the class 'Person' (and it's pluralized version, 'people')
18
+
19
+ rails generate sorcery:install http_basic_auth external remember_me --migrations
20
+
21
+ This will generate only the migration files for the specified submodules and will
22
+ add them to the initializer file.
@@ -0,0 +1,77 @@
1
+ require 'rails/generators/migration'
2
+
3
+ module Sorcery
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ argument :submodules, :optional => true, :type => :array, :banner => "submodules"
11
+
12
+ class_option :model, :optional => true, :type => :string, :banner => "model",
13
+ :desc => "Specify the model class name if you will use anything other than 'User'"
14
+
15
+ class_option :migrations, :optional => true, :type => :boolean, :banner => "migrations",
16
+ :desc => "Specify if you want to add submodules to an existing model\n\t\t\t # (will generate migrations files, and add submodules to config file)"
17
+
18
+
19
+ # Copy the initializer file to config/initializers folder.
20
+ def copy_initializer_file
21
+ template "initializer.rb", "config/initializers/sorcery.rb" unless options[:migrations]
22
+ end
23
+
24
+ def configure_initializer_file
25
+ # Add submodules to the initializer file.
26
+ if submodules
27
+ submodule_names = submodules.collect{ |submodule| ':' + submodule }
28
+
29
+ gsub_file "config/initializers/sorcery.rb", /submodules = \[.*\]/ do |str|
30
+ current_submodule_names = (str =~ /\[(.*)\]/ ? $1 : '').delete(' ').split(',')
31
+ "submodules = [#{(current_submodule_names | submodule_names).join(', ')}]"
32
+ end
33
+ end
34
+
35
+ # Generate the model and add 'authenticates_with_sorcery!' unless you passed --migrations
36
+ unless options[:migrations]
37
+ generate "model #{model_class_name} --skip-migration"
38
+ insert_into_file "app/models/#{model_class_name.underscore}.rb", " authenticates_with_sorcery!\n", :after => "class #{model_class_name} < ActiveRecord::Base\n"
39
+ end
40
+ end
41
+
42
+ # Copy the migrations files to db/migrate folder
43
+ def copy_migration_files
44
+ # Copy core migration file in all cases except when you pass --migrations.
45
+ return unless defined?(Sorcery::Generators::InstallGenerator::ActiveRecord)
46
+ migration_template "migration/core.rb", "db/migrate/sorcery_core.rb" unless options[:migrations]
47
+
48
+ if submodules
49
+ submodules.each do |submodule|
50
+ unless submodule == "http_basic_auth" || submodule == "session_timeout"
51
+ migration_template "migration/#{submodule}.rb", "db/migrate/sorcery_#{submodule}.rb"
52
+ end
53
+ end
54
+ end
55
+
56
+
57
+ end
58
+
59
+ # Define the next_migration_number method (necessary for the migration_template method to work)
60
+ def self.next_migration_number(dirname)
61
+ if ActiveRecord::Base.timestamped_migrations
62
+ sleep 1 # make sure each time we get a different timestamp
63
+ Time.new.utc.strftime("%Y%m%d%H%M%S")
64
+ else
65
+ "%.3d" % (current_migration_number(dirname) + 1)
66
+ end
67
+ end
68
+
69
+ private
70
+
71
+ # Either return the model passed in a classified form or return the default "User".
72
+ def model_class_name
73
+ options[:model] ? options[:model].classify : "User"
74
+ end
75
+ end
76
+ end
77
+ end