sorcery 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sorcery might be problematic. Click here for more details.

Files changed (164) hide show
  1. data/Gemfile +2 -1
  2. data/Gemfile.lock +58 -51
  3. data/README.rdoc +19 -57
  4. data/Rakefile +27 -1
  5. data/VERSION +1 -1
  6. data/lib/generators/sorcery/USAGE +22 -0
  7. data/lib/generators/sorcery/install_generator.rb +71 -0
  8. data/lib/{sorcery/initializers → generators/sorcery/templates}/initializer.rb +4 -4
  9. data/lib/generators/sorcery/templates/migration/activity_logging.rb +17 -0
  10. data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +11 -0
  11. data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/core.rb +2 -2
  12. data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/external.rb +1 -1
  13. data/lib/generators/sorcery/templates/migration/remember_me.rb +15 -0
  14. data/lib/generators/sorcery/templates/migration/reset_password.rb +17 -0
  15. data/lib/generators/sorcery/templates/migration/user_activation.rb +17 -0
  16. data/lib/sorcery.rb +5 -7
  17. data/lib/sorcery/controller.rb +40 -39
  18. data/lib/sorcery/controller/submodules/activity_logging.rb +7 -10
  19. data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +23 -8
  20. data/lib/sorcery/controller/submodules/remember_me.rb +3 -2
  21. data/lib/sorcery/model.rb +21 -4
  22. data/lib/sorcery/model/adapters/mongo_mapper.rb +49 -0
  23. data/lib/sorcery/model/adapters/mongoid.rb +1 -1
  24. data/lib/sorcery/model/submodules/brute_force_protection.rb +8 -0
  25. data/lib/sorcery/model/submodules/remember_me.rb +8 -1
  26. data/lib/sorcery/model/submodules/reset_password.rb +10 -0
  27. data/lib/sorcery/model/submodules/user_activation.rb +12 -0
  28. data/sorcery.gemspec +86 -210
  29. data/spec/Gemfile +1 -1
  30. data/spec/Gemfile.lock +28 -15
  31. data/spec/README.md +6 -1
  32. data/spec/rails3/Gemfile +2 -2
  33. data/spec/rails3/Gemfile.lock +45 -50
  34. data/spec/rails3/spec/controller_oauth2_spec.rb +5 -3
  35. data/spec/rails3/spec/spec_helper.rb +1 -3
  36. data/spec/rails3_mongo_mapper/.gitignore +4 -0
  37. data/spec/rails3_mongo_mapper/.rspec +1 -0
  38. data/spec/{sinatra_modular → rails3_mongo_mapper}/Gemfile +5 -5
  39. data/spec/rails3_mongo_mapper/Gemfile.lock +159 -0
  40. data/spec/{sinatra → rails3_mongo_mapper}/Rakefile +3 -3
  41. data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +108 -0
  42. data/spec/rails3_mongo_mapper/app/helpers/application_helper.rb +2 -0
  43. data/spec/{sinatra → rails3_mongo_mapper/app/mailers}/sorcery_mailer.rb +0 -0
  44. data/spec/rails3_mongo_mapper/app/models/authentication.rb +6 -0
  45. data/spec/rails3_mongo_mapper/app/models/user.rb +5 -0
  46. data/spec/rails3_mongo_mapper/app/views/layouts/application.html.erb +14 -0
  47. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.html.erb +17 -0
  48. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.text.erb +9 -0
  49. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.html.erb +17 -0
  50. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.text.erb +9 -0
  51. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.html.erb +16 -0
  52. data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.text.erb +8 -0
  53. data/spec/rails3_mongo_mapper/config.ru +4 -0
  54. data/spec/rails3_mongo_mapper/config/application.rb +51 -0
  55. data/spec/rails3_mongo_mapper/config/boot.rb +13 -0
  56. data/spec/rails3_mongo_mapper/config/environment.rb +5 -0
  57. data/spec/rails3_mongo_mapper/config/environments/development.rb +30 -0
  58. data/spec/rails3_mongo_mapper/config/environments/in_memory.rb +0 -0
  59. data/spec/rails3_mongo_mapper/config/environments/production.rb +49 -0
  60. data/spec/rails3_mongo_mapper/config/environments/test.rb +35 -0
  61. data/spec/rails3_mongo_mapper/config/initializers/backtrace_silencers.rb +7 -0
  62. data/spec/rails3_mongo_mapper/config/initializers/inflections.rb +10 -0
  63. data/spec/rails3_mongo_mapper/config/initializers/mime_types.rb +5 -0
  64. data/spec/rails3_mongo_mapper/config/initializers/mongo.rb +2 -0
  65. data/spec/rails3_mongo_mapper/config/initializers/secret_token.rb +7 -0
  66. data/spec/rails3_mongo_mapper/config/initializers/session_store.rb +8 -0
  67. data/spec/rails3_mongo_mapper/config/locales/en.yml +5 -0
  68. data/spec/rails3_mongo_mapper/config/routes.rb +59 -0
  69. data/spec/rails3_mongo_mapper/db/schema.rb +23 -0
  70. data/spec/rails3_mongo_mapper/db/seeds.rb +7 -0
  71. data/spec/rails3_mongo_mapper/lib/tasks/.gitkeep +0 -0
  72. data/spec/rails3_mongo_mapper/public/404.html +26 -0
  73. data/spec/rails3_mongo_mapper/public/422.html +26 -0
  74. data/spec/rails3_mongo_mapper/public/500.html +26 -0
  75. data/spec/rails3_mongo_mapper/public/favicon.ico +0 -0
  76. data/spec/rails3_mongo_mapper/public/images/rails.png +0 -0
  77. data/spec/rails3_mongo_mapper/public/javascripts/application.js +2 -0
  78. data/spec/rails3_mongo_mapper/public/javascripts/controls.js +965 -0
  79. data/spec/rails3_mongo_mapper/public/javascripts/dragdrop.js +974 -0
  80. data/spec/rails3_mongo_mapper/public/javascripts/effects.js +1123 -0
  81. data/spec/rails3_mongo_mapper/public/javascripts/prototype.js +6001 -0
  82. data/spec/rails3_mongo_mapper/public/javascripts/rails.js +175 -0
  83. data/spec/rails3_mongo_mapper/public/robots.txt +5 -0
  84. data/spec/rails3_mongo_mapper/public/stylesheets/.gitkeep +0 -0
  85. data/spec/rails3_mongo_mapper/script/rails +6 -0
  86. data/spec/{sinatra → rails3_mongo_mapper}/spec/controller_spec.rb +45 -42
  87. data/spec/{sinatra → rails3_mongo_mapper}/spec/spec.opts +0 -0
  88. data/spec/rails3_mongo_mapper/spec/spec_helper.orig.rb +27 -0
  89. data/spec/rails3_mongo_mapper/spec/spec_helper.rb +55 -0
  90. data/spec/rails3_mongo_mapper/spec/user_activation_spec.rb +9 -0
  91. data/spec/rails3_mongo_mapper/spec/user_activity_logging_spec.rb +8 -0
  92. data/spec/rails3_mongo_mapper/spec/user_brute_force_protection_spec.rb +8 -0
  93. data/spec/rails3_mongo_mapper/spec/user_oauth_spec.rb +8 -0
  94. data/spec/rails3_mongo_mapper/spec/user_remember_me_spec.rb +8 -0
  95. data/spec/rails3_mongo_mapper/spec/user_reset_password_spec.rb +8 -0
  96. data/spec/rails3_mongo_mapper/spec/user_spec.rb +37 -0
  97. data/spec/rails3_mongo_mapper/vendor/plugins/.gitkeep +0 -0
  98. data/spec/rails3_mongoid/Gemfile +1 -1
  99. data/spec/rails3_mongoid/Gemfile.lock +44 -35
  100. data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +98 -0
  101. data/spec/rails3_mongoid/spec/user_spec.rb +1 -0
  102. data/spec/shared_examples/user_shared_examples.rb +29 -1
  103. metadata +124 -237
  104. data/lib/generators/sorcery_migration/sorcery_migration_generator.rb +0 -24
  105. data/lib/generators/sorcery_migration/templates/activity_logging.rb +0 -17
  106. data/lib/generators/sorcery_migration/templates/brute_force_protection.rb +0 -11
  107. data/lib/generators/sorcery_migration/templates/remember_me.rb +0 -15
  108. data/lib/generators/sorcery_migration/templates/reset_password.rb +0 -17
  109. data/lib/generators/sorcery_migration/templates/user_activation.rb +0 -17
  110. data/lib/sorcery/controller/adapters/sinatra.rb +0 -115
  111. data/lib/sorcery/sinatra.rb +0 -4
  112. data/lib/sorcery/test_helpers/internal/sinatra.rb +0 -74
  113. data/lib/sorcery/test_helpers/internal/sinatra_modular.rb +0 -74
  114. data/lib/sorcery/test_helpers/sinatra.rb +0 -88
  115. data/spec/rails3/Rakefile.unused +0 -7
  116. data/spec/sinatra/Gemfile +0 -15
  117. data/spec/sinatra/Gemfile.lock +0 -115
  118. data/spec/sinatra/authentication.rb +0 -3
  119. data/spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
  120. data/spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
  121. data/spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
  122. data/spec/sinatra/db/migrate/core/20101224223620_create_users.rb +0 -16
  123. data/spec/sinatra/db/migrate/external/20101224223628_create_authentications.rb +0 -14
  124. data/spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
  125. data/spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
  126. data/spec/sinatra/filters.rb +0 -27
  127. data/spec/sinatra/modular.rb +0 -157
  128. data/spec/sinatra/myapp.rb +0 -133
  129. data/spec/sinatra/spec/controller_activity_logging_spec.rb +0 -85
  130. data/spec/sinatra/spec/controller_brute_force_protection_spec.rb +0 -70
  131. data/spec/sinatra/spec/controller_http_basic_auth_spec.rb +0 -53
  132. data/spec/sinatra/spec/controller_oauth2_spec.rb +0 -96
  133. data/spec/sinatra/spec/controller_oauth_spec.rb +0 -100
  134. data/spec/sinatra/spec/controller_remember_me_spec.rb +0 -64
  135. data/spec/sinatra/spec/controller_session_timeout_spec.rb +0 -57
  136. data/spec/sinatra/spec/spec_helper.rb +0 -45
  137. data/spec/sinatra/user.rb +0 -6
  138. data/spec/sinatra/views/test_login.erb +0 -4
  139. data/spec/sinatra_modular/Gemfile.lock +0 -115
  140. data/spec/sinatra_modular/Rakefile +0 -11
  141. data/spec/sinatra_modular/authentication.rb +0 -3
  142. data/spec/sinatra_modular/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
  143. data/spec/sinatra_modular/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
  144. data/spec/sinatra_modular/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
  145. data/spec/sinatra_modular/db/migrate/core/20101224223620_create_users.rb +0 -16
  146. data/spec/sinatra_modular/db/migrate/external/20101224223628_create_authentications.rb +0 -14
  147. data/spec/sinatra_modular/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
  148. data/spec/sinatra_modular/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
  149. data/spec/sinatra_modular/filters.rb +0 -27
  150. data/spec/sinatra_modular/modular.rb +0 -157
  151. data/spec/sinatra_modular/myapp.rb +0 -133
  152. data/spec/sinatra_modular/sorcery_mailer.rb +0 -25
  153. data/spec/sinatra_modular/spec_modular/controller_activity_logging_spec.rb +0 -85
  154. data/spec/sinatra_modular/spec_modular/controller_brute_force_protection_spec.rb +0 -70
  155. data/spec/sinatra_modular/spec_modular/controller_http_basic_auth_spec.rb +0 -53
  156. data/spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb +0 -96
  157. data/spec/sinatra_modular/spec_modular/controller_oauth_spec.rb +0 -100
  158. data/spec/sinatra_modular/spec_modular/controller_remember_me_spec.rb +0 -64
  159. data/spec/sinatra_modular/spec_modular/controller_session_timeout_spec.rb +0 -57
  160. data/spec/sinatra_modular/spec_modular/controller_spec.rb +0 -116
  161. data/spec/sinatra_modular/spec_modular/spec.opts +0 -2
  162. data/spec/sinatra_modular/spec_modular/spec_helper.rb +0 -51
  163. data/spec/sinatra_modular/user.rb +0 -6
  164. data/spec/sinatra_modular/views/test_login.erb +0 -4
data/Gemfile CHANGED
@@ -3,7 +3,8 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
  gem 'oauth', "~> 0.4.4"
6
- gem 'oauth2', "~> 0.5.1"
6
+ gem 'oauth2', "~> 0.4.1"
7
+ gem 'mongo_mapper'
7
8
 
8
9
  # Add dependencies to develop your gem here.
9
10
  # Include everything needed to run rake, tests, features, etc.
data/Gemfile.lock CHANGED
@@ -1,49 +1,47 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionmailer (3.1.0)
5
- actionpack (= 3.1.0)
4
+ actionmailer (3.1.1)
5
+ actionpack (= 3.1.1)
6
6
  mail (~> 2.3.0)
7
- actionpack (3.1.0)
8
- activemodel (= 3.1.0)
9
- activesupport (= 3.1.0)
7
+ actionpack (3.1.1)
8
+ activemodel (= 3.1.1)
9
+ activesupport (= 3.1.1)
10
10
  builder (~> 3.0.0)
11
11
  erubis (~> 2.7.0)
12
12
  i18n (~> 0.6)
13
13
  rack (~> 1.3.2)
14
- rack-cache (~> 1.0.3)
14
+ rack-cache (~> 1.1)
15
15
  rack-mount (~> 0.8.2)
16
16
  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)
17
+ sprockets (~> 2.0.2)
18
+ activemodel (3.1.1)
19
+ activesupport (= 3.1.1)
21
20
  builder (~> 3.0.0)
22
21
  i18n (~> 0.6)
23
- activerecord (3.1.0)
24
- activemodel (= 3.1.0)
25
- activesupport (= 3.1.0)
22
+ activerecord (3.1.1)
23
+ activemodel (= 3.1.1)
24
+ activesupport (= 3.1.1)
26
25
  arel (~> 2.2.1)
27
26
  tzinfo (~> 0.3.29)
28
- activeresource (3.1.0)
29
- activemodel (= 3.1.0)
30
- activesupport (= 3.1.0)
31
- activesupport (3.1.0)
27
+ activeresource (3.1.1)
28
+ activemodel (= 3.1.1)
29
+ activesupport (= 3.1.1)
30
+ activesupport (3.1.1)
32
31
  multi_json (~> 1.0)
33
32
  addressable (2.2.6)
34
33
  archive-tar-minitar (0.5.2)
35
34
  arel (2.2.1)
36
- bcrypt-ruby (3.0.0)
37
- bson (1.3.1)
38
- bson_ext (1.3.1)
35
+ bson (1.4.1)
36
+ bson_ext (1.4.1)
39
37
  builder (3.0.0)
40
38
  columnize (0.3.4)
41
39
  diff-lcs (1.1.3)
42
40
  erubis (2.7.0)
43
- faraday (0.7.4)
44
- addressable (~> 2.2.6)
41
+ faraday (0.6.1)
42
+ addressable (~> 2.2.4)
45
43
  multipart-post (~> 1.1.0)
46
- rack (< 2, >= 1.1.0)
44
+ rack (>= 1.1.0, < 2)
47
45
  git (1.2.5)
48
46
  hike (1.2.1)
49
47
  i18n (0.6.0)
@@ -51,7 +49,7 @@ GEM
51
49
  bundler (~> 1.0.0)
52
50
  git (>= 1.2.5)
53
51
  rake
54
- json (1.5.4)
52
+ json (1.6.1)
55
53
  linecache19 (0.5.12)
56
54
  ruby_core_source (>= 0.1.4)
57
55
  mail (2.3.0)
@@ -59,21 +57,27 @@ GEM
59
57
  mime-types (~> 1.16)
60
58
  treetop (~> 1.4.8)
61
59
  mime-types (1.16)
62
- mongo (1.3.1)
63
- bson (>= 1.3.1)
64
- mongoid (2.2.0)
60
+ mongo (1.4.1)
61
+ bson (= 1.4.1)
62
+ mongo_mapper (0.9.2)
65
63
  activemodel (~> 3.0)
66
- mongo (~> 1.3)
64
+ activesupport (~> 3.0)
65
+ plucky (~> 0.3.8)
66
+ mongoid (2.3.2)
67
+ activemodel (~> 3.1)
68
+ mongo (~> 1.4)
67
69
  tzinfo (~> 0.3.22)
68
70
  multi_json (1.0.3)
69
71
  multipart-post (1.1.3)
70
72
  oauth (0.4.5)
71
- oauth2 (0.5.1)
72
- faraday (~> 0.7.4)
73
- multi_json (~> 1.0.3)
73
+ oauth2 (0.4.1)
74
+ faraday (~> 0.6.1)
75
+ multi_json (>= 0.0.5)
76
+ plucky (0.3.8)
77
+ mongo (~> 1.3)
74
78
  polyglot (0.3.2)
75
- rack (1.3.3)
76
- rack-cache (1.0.3)
79
+ rack (1.3.5)
80
+ rack-cache (1.1)
77
81
  rack (>= 0.4)
78
82
  rack-mount (0.8.3)
79
83
  rack (>= 1.0.0)
@@ -81,23 +85,24 @@ GEM
81
85
  rack
82
86
  rack-test (0.6.1)
83
87
  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)
88
+ rails (3.1.1)
89
+ actionmailer (= 3.1.1)
90
+ actionpack (= 3.1.1)
91
+ activerecord (= 3.1.1)
92
+ activeresource (= 3.1.1)
93
+ activesupport (= 3.1.1)
90
94
  bundler (~> 1.0)
91
- railties (= 3.1.0)
92
- railties (3.1.0)
93
- actionpack (= 3.1.0)
94
- activesupport (= 3.1.0)
95
+ railties (= 3.1.1)
96
+ railties (3.1.1)
97
+ actionpack (= 3.1.1)
98
+ activesupport (= 3.1.1)
95
99
  rack-ssl (~> 1.3.2)
96
100
  rake (>= 0.8.7)
97
101
  rdoc (~> 3.4)
98
102
  thor (~> 0.14.6)
99
103
  rake (0.9.2)
100
- rdoc (3.9.4)
104
+ rdoc (3.11)
105
+ json (~> 1.4)
101
106
  rspec (2.5.0)
102
107
  rspec-core (~> 2.5.0)
103
108
  rspec-expectations (~> 2.5.0)
@@ -121,13 +126,14 @@ GEM
121
126
  ruby-debug-base19 (>= 0.11.19)
122
127
  ruby_core_source (0.1.5)
123
128
  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)
129
+ simplecov (0.5.4)
130
+ multi_json (~> 1.0.3)
131
+ simplecov-html (~> 0.5.3)
132
+ simplecov-html (0.5.3)
133
+ sprockets (2.0.3)
128
134
  hike (~> 1.2)
129
135
  rack (~> 1.0)
130
- tilt (!= 1.3.0, ~> 1.1)
136
+ tilt (~> 1.1, != 1.3.0)
131
137
  sqlite3 (1.3.4)
132
138
  sqlite3-ruby (1.3.3)
133
139
  sqlite3 (>= 1.3.3)
@@ -137,7 +143,7 @@ GEM
137
143
  treetop (1.4.10)
138
144
  polyglot
139
145
  polyglot (>= 0.3.1)
140
- tzinfo (0.3.29)
146
+ tzinfo (0.3.30)
141
147
  yard (0.6.8)
142
148
 
143
149
  PLATFORMS
@@ -148,9 +154,10 @@ DEPENDENCIES
148
154
  bundler (~> 1.0.0)
149
155
  jeweler (~> 1.5.2)
150
156
  json (>= 1.5.1)
157
+ mongo_mapper
151
158
  mongoid (~> 2.0)
152
159
  oauth (~> 0.4.4)
153
- oauth2 (~> 0.5.1)
160
+ oauth2 (~> 0.4.1)
154
161
  rails (>= 3.0.0)
155
162
  rspec (~> 2.5.0)
156
163
  rspec-rails (~> 2.5.0)
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = sorcery
2
- Magical Authentication for Rails 3 and Sinatra.
3
- Supports ActiveRecord and Mongoid.
2
+ Magical Authentication for Rails 3.
3
+ Supports ActiveRecord, Mongoid and MongoMapper.
4
4
 
5
5
  Inspired by restful_authentication, Authlogic and Devise.
6
6
  Crypto code taken almost unchanged from Authlogic.
@@ -28,9 +28,7 @@ Railscast: http://railscasts.com/episodes/283-authentication-with-sorcery
28
28
 
29
29
  Example Rails 3 app using sorcery: https://github.com/NoamB/sorcery-example-app
30
30
 
31
- Example Sinatra app using sorcery: https://github.com/NoamB/sorcery-example-app-sinatra
32
-
33
- Documentation: http://rubydoc.info/gems/sorcery/0.7.0/frames
31
+ Documentation: http://rubydoc.info/gems/sorcery/0.7.1/frames
34
32
 
35
33
  Check out the tutorials in the github wiki!
36
34
 
@@ -97,59 +95,26 @@ Otherwise simply
97
95
 
98
96
  == Rails 3 Configuration:
99
97
 
98
+ rails generate sorcery:install
100
99
 
101
- For Rails 3 create an initializer file using:
102
-
103
- rake sorcery:bootstrap
104
-
105
- This will create the file as config/initializers/sorcery.rb .
106
- Inside it the comments will tell you everything you need to know.
107
-
108
- For your convenience, Sorcery includes a migrations generator for Rails, which can be used like so:
109
-
110
- rails g sorcery_migration [list of submodules]
100
+ This will generate the core migration file, the initializer file and the 'User' model class.
111
101
 
112
- Note: There is no migration for the session_timeout module.
113
- For example, for only the core functionality use:
102
+ rails generate sorcery:install remember_me reset_password
114
103
 
115
- rails g sorcery_migration core
104
+ This will generate the migrations files for remember_me and reset_password submodules
105
+ and will create the initializer file (and add submodules to it), and create the 'User' model class.
116
106
 
117
- To generate migrations for both the core AND 'remember_me' submodule:
107
+ rails generate sorcery:install --model Person
118
108
 
119
- rails g sorcery_migration core remember_me
109
+ This will generate the core migration file, the initializer and change the model class
110
+ (in the initializer and migration files) to the class 'Person' (and its pluralized version, 'people')
120
111
 
121
- 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.
112
+ rails generate sorcery:install http_basic_auth external remember_me --migrations
122
113
 
123
- Finally, add sorcery to the the model that you will use for authentication:
124
-
125
- class User < ActiveRecord::Base
126
- authenticates_with_sorcery!
127
- end
114
+ This will generate only the migration files for the specified submodules and will
115
+ add them to the initializer file.
128
116
 
129
- == Sinatra Configuration:
130
-
131
-
132
- 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:
133
-
134
- Sorcery::Controller::Config.submodules = [] # specify here the submodules you want to include
135
-
136
- Sorcery::Controller::Config.configure do |config|
137
- config.session_timeout = 10.minutes
138
- ...
139
- ...
140
-
141
- config.user_config do |user|
142
- user.username_attribute_name = :email
143
- ...
144
- ...
145
-
146
- end
147
- end
148
-
149
- Finally, to make all the code above take effect, we'll need to re-include the sorcery controller module:
150
-
151
- include Sorcery::Controller::Adapters::Sinatra
152
- include Sorcery::Controller
117
+ Inside the initializer, the comments will tell you what each setting does.
153
118
 
154
119
 
155
120
  == Full Features List by module:
@@ -216,13 +181,6 @@ I've got some thoughts which include (unordered):
216
181
  Have an idea? Let me know, and it might get into the gem!
217
182
 
218
183
 
219
- Other stuff:
220
- * Improve specs speed
221
- * Provide an easy way to run specs after install
222
- * Improve documentation
223
- * Try to reduce the number of library methods, and find better names to some
224
-
225
-
226
184
  == Backward compatibility
227
185
 
228
186
 
@@ -238,11 +196,15 @@ The same cannot be said about upgrading to x.4.0 and above, however.
238
196
 
239
197
  Important notes while upgrading:
240
198
 
199
+ * If upgrading from <= 0.6.1 to >= 0.7.0 you need to change 'username_attribute_name' to 'username_attribute_names' in initializer.
241
200
  * If upgrading from <= v0.5.1 to >= v0.5.2 you need to explicitly set your user_class model in the initializer file.
242
201
 
243
202
  # This line must come after the 'user config' block.
244
203
  config.user_class = User
245
204
 
205
+ * Sinatra support existed until v0.7.0 (including), but was dropped later due to being a maintenance nightmare.
206
+
207
+
246
208
  == Contributing to sorcery
247
209
 
248
210
 
data/Rakefile CHANGED
@@ -27,7 +27,7 @@ Jeweler::Tasks.new do |gem|
27
27
  # gem.add_development_dependency 'rspec', '> 1.2.3'
28
28
  gem.add_runtime_dependency 'bcrypt-ruby', '~> 3.0.0'
29
29
  gem.add_runtime_dependency 'oauth', '~> 0.4.4'
30
- gem.add_runtime_dependency 'oauth2', '~> 0.5.1'
30
+ gem.add_runtime_dependency 'oauth2', '~> 0.4.1'
31
31
  end
32
32
  Jeweler::RubygemsDotOrgTasks.new
33
33
 
@@ -54,3 +54,29 @@ task :all_sorcery_specs do
54
54
  CMD
55
55
  end
56
56
  end
57
+
58
+ desc "Bundle all folders"
59
+ task :bundle do
60
+ sh "bundle"
61
+ Dir['spec', 'spec/**'].each do |dir|
62
+ if Dir.exists?(dir) && File.exists?(dir + "/Gemfile")
63
+ sh <<-CMD
64
+ cd #{dir}
65
+ bundle
66
+ CMD
67
+ end
68
+ end
69
+ end
70
+
71
+ desc "Bundle update all folders"
72
+ task :bundle_update do
73
+ sh "bundle update"
74
+ Dir['spec', 'spec/**'].each do |dir|
75
+ if Dir.exists?(dir) && File.exists?(dir + "/Gemfile")
76
+ sh <<-CMD
77
+ cd #{dir}
78
+ bundle update
79
+ CMD
80
+ end
81
+ end
82
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
@@ -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,71 @@
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
+ str = submodules.collect{ |submodule| ':' + submodule + ', ' }
28
+ str.last.delete!(", ")
29
+
30
+ gsub_file "config/initializers/sorcery.rb", /submodules = \[\]/, "submodules = [#{str.join()}]"
31
+ end
32
+
33
+ # Generate the model and add 'authenticates_with_sorcery!' unless you passed --migrations
34
+ unless options[:migrations]
35
+ generate "model #{model_class_name} --skip-migration"
36
+ insert_into_file "app/models/#{model_class_name}.rb", " authenticates_with_sorcery!\n", :after => "class #{model_class_name} < ActiveRecord::Base\n"
37
+ end
38
+ end
39
+
40
+ # Copy the migrations files to db/migrate folder
41
+ def copy_migration_files
42
+ if submodules
43
+ submodules.each do |submodule|
44
+ unless submodule == "http_basic_auth" || submodule == "session_timeout"
45
+ migration_template "migration/#{submodule}.rb", "db/migrate/sorcery_#{submodule}.rb"
46
+ end
47
+ end
48
+ end
49
+
50
+ # Copy core migration file in all cases except when you pass --migrations.
51
+ migration_template "migration/core.rb", "db/migrate/sorcery_core.rb" unless options[:migrations]
52
+ end
53
+
54
+ # Define the next_migration_number method (necessary for the migration_template method to work)
55
+ def self.next_migration_number(dirname)
56
+ if ActiveRecord::Base.timestamped_migrations
57
+ Time.new.utc.strftime("%Y%m%d%H%M%S")
58
+ else
59
+ "%.3d" % (current_migration_number(dirname) + 1)
60
+ end
61
+ end
62
+
63
+ private
64
+
65
+ # Either return the model passed in a capitalized form or return the default "User".
66
+ def model_class_name
67
+ options[:model] ? options[:model].capitalize : "User"
68
+ end
69
+ end
70
+ end
71
+ end