sorcery 0.7.6 → 0.8.0

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 (63) hide show
  1. data/.travis.yml +3 -0
  2. data/Gemfile +9 -4
  3. data/Gemfile.lock +99 -58
  4. data/README.rdoc +33 -8
  5. data/Rakefile +6 -7
  6. data/VERSION +1 -1
  7. data/lib/generators/sorcery/install_generator.rb +9 -7
  8. data/lib/generators/sorcery/templates/initializer.rb +324 -127
  9. data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +2 -0
  10. data/lib/sorcery/controller/submodules/brute_force_protection.rb +1 -2
  11. data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +2 -2
  12. data/lib/sorcery/controller/submodules/external/providers/facebook.rb +16 -4
  13. data/lib/sorcery/controller/submodules/external/providers/github.rb +6 -4
  14. data/lib/sorcery/controller/submodules/external/providers/google.rb +4 -4
  15. data/lib/sorcery/controller/submodules/external/providers/linkedin.rb +101 -0
  16. data/lib/sorcery/controller/submodules/external/providers/liveid.rb +1 -1
  17. data/lib/sorcery/controller/submodules/external/providers/vkontakte.rb +94 -0
  18. data/lib/sorcery/controller/submodules/external.rb +83 -15
  19. data/lib/sorcery/controller/submodules/http_basic_auth.rb +1 -1
  20. data/lib/sorcery/controller/submodules/remember_me.rb +11 -2
  21. data/lib/sorcery/controller.rb +14 -6
  22. data/lib/sorcery/crypto_providers/bcrypt.rb +1 -0
  23. data/lib/sorcery/model/adapters/active_record.rb +9 -4
  24. data/lib/sorcery/model/adapters/mongo_mapper.rb +16 -14
  25. data/lib/sorcery/model/adapters/mongoid.rb +12 -6
  26. data/lib/sorcery/model/submodules/brute_force_protection.rb +44 -13
  27. data/lib/sorcery/model/submodules/remember_me.rb +4 -6
  28. data/lib/sorcery/model/submodules/reset_password.rb +14 -7
  29. data/lib/sorcery/model/submodules/user_activation.rb +14 -6
  30. data/lib/sorcery/model.rb +40 -39
  31. data/lib/sorcery/railties/tasks.rake +2 -0
  32. data/lib/sorcery.rb +3 -1
  33. data/sorcery.gemspec +31 -141
  34. data/spec/Gemfile +1 -1
  35. data/spec/Gemfile.lock +20 -19
  36. data/spec/README.md +8 -8
  37. data/spec/rails3/Gemfile +1 -0
  38. data/spec/rails3/Gemfile.lock +27 -24
  39. data/spec/rails3/app/controllers/application_controller.rb +54 -0
  40. data/spec/rails3/app/mailers/sorcery_mailer.rb +7 -0
  41. data/spec/rails3/app/views/sorcery_mailer/send_unlock_token_email.text.erb +1 -0
  42. data/spec/rails3/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +2 -0
  43. data/spec/rails3/spec/controller_activity_logging_spec.rb +3 -0
  44. data/spec/rails3/spec/controller_brute_force_protection_spec.rb +23 -1
  45. data/spec/rails3/spec/controller_oauth2_spec.rb +162 -24
  46. data/spec/rails3/spec/controller_oauth_spec.rb +111 -6
  47. data/spec/rails3/spec/controller_spec.rb +7 -0
  48. data/spec/rails3_mongo_mapper/Gemfile +2 -1
  49. data/spec/rails3_mongo_mapper/Gemfile.lock +37 -39
  50. data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +14 -0
  51. data/spec/rails3_mongo_mapper/spec/controller_spec.rb +7 -0
  52. data/spec/rails3_mongoid/Gemfile +1 -0
  53. data/spec/rails3_mongoid/Gemfile.lock +28 -25
  54. data/spec/rails3_mongoid/app/controllers/application_controller.rb +14 -0
  55. data/spec/rails3_mongoid/config/mongoid.yml +1 -1
  56. data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +11 -11
  57. data/spec/rails3_mongoid/spec/controller_spec.rb +7 -0
  58. data/spec/shared_examples/controller_oauth2_shared_examples.rb +20 -1
  59. data/spec/shared_examples/controller_oauth_shared_examples.rb +18 -0
  60. data/spec/shared_examples/user_activation_shared_examples.rb +71 -41
  61. data/spec/shared_examples/user_reset_password_shared_examples.rb +76 -31
  62. data/spec/sorcery_crypto_providers_spec.rb +9 -0
  63. metadata +159 -246
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
data/Gemfile CHANGED
@@ -1,13 +1,15 @@
1
- source "http://rubygems.org"
1
+ source :rubygems
2
2
  # Add dependencies required to use your gem here.
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.8.0"
7
+ gem 'bcrypt-ruby', "~> 3.0.0"
7
8
 
8
9
  # Add dependencies to develop your gem here.
9
10
  # Include everything needed to run rake, tests, features, etc.
10
11
  group :development do
12
+ gem 'abstract', '>= 1.0.0'
11
13
  gem "rails", ">= 3.0.0"
12
14
  gem 'json', ">= 1.5.1"
13
15
  gem "rspec", "~> 2.5.0"
@@ -15,8 +17,11 @@ group :development do
15
17
  gem 'ruby-debug19'
16
18
  gem 'sqlite3-ruby', :require => 'sqlite3'
17
19
  gem "yard", "~> 0.6.0"
18
- gem "bundler", "~> 1.0.0"
19
- gem "jeweler", "~> 1.5.2"
20
+ gem "bundler", ">= 1.1.0"
21
+ gem "jeweler", "~> 1.8.3"
20
22
  gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
21
23
  gem 'timecop'
24
+ gem 'capybara'
25
+ gem 'mongo_mapper'
26
+ gem 'mongoid', "~> 2.4.4"
22
27
  end
data/Gemfile.lock CHANGED
@@ -1,87 +1,115 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionmailer (3.1.3)
5
- actionpack (= 3.1.3)
6
- mail (~> 2.3.0)
7
- actionpack (3.1.3)
8
- activemodel (= 3.1.3)
9
- activesupport (= 3.1.3)
4
+ abstract (1.0.0)
5
+ actionmailer (3.2.2)
6
+ actionpack (= 3.2.2)
7
+ mail (~> 2.4.0)
8
+ actionpack (3.2.2)
9
+ activemodel (= 3.2.2)
10
+ activesupport (= 3.2.2)
10
11
  builder (~> 3.0.0)
11
12
  erubis (~> 2.7.0)
12
- i18n (~> 0.6)
13
- rack (~> 1.3.5)
13
+ journey (~> 1.0.1)
14
+ rack (~> 1.4.0)
14
15
  rack-cache (~> 1.1)
15
- rack-mount (~> 0.8.2)
16
16
  rack-test (~> 0.6.1)
17
- sprockets (~> 2.0.3)
18
- activemodel (3.1.3)
19
- activesupport (= 3.1.3)
17
+ sprockets (~> 2.1.2)
18
+ activemodel (3.2.2)
19
+ activesupport (= 3.2.2)
20
20
  builder (~> 3.0.0)
21
- i18n (~> 0.6)
22
- activerecord (3.1.3)
23
- activemodel (= 3.1.3)
24
- activesupport (= 3.1.3)
25
- arel (~> 2.2.1)
21
+ activerecord (3.2.2)
22
+ activemodel (= 3.2.2)
23
+ activesupport (= 3.2.2)
24
+ arel (~> 3.0.2)
26
25
  tzinfo (~> 0.3.29)
27
- activeresource (3.1.3)
28
- activemodel (= 3.1.3)
29
- activesupport (= 3.1.3)
30
- activesupport (3.1.3)
26
+ activeresource (3.2.2)
27
+ activemodel (= 3.2.2)
28
+ activesupport (= 3.2.2)
29
+ activesupport (3.2.2)
30
+ i18n (~> 0.6)
31
31
  multi_json (~> 1.0)
32
- addressable (2.2.6)
33
32
  archive-tar-minitar (0.5.2)
34
- arel (2.2.1)
33
+ arel (3.0.2)
34
+ bcrypt-ruby (3.0.1)
35
+ bson (1.6.1)
35
36
  builder (3.0.0)
37
+ capybara (1.1.2)
38
+ mime-types (>= 1.16)
39
+ nokogiri (>= 1.3.3)
40
+ rack (>= 1.0.0)
41
+ rack-test (>= 0.5.4)
42
+ selenium-webdriver (~> 2.0)
43
+ xpath (~> 0.1.4)
44
+ childprocess (0.3.1)
45
+ ffi (~> 1.0.6)
36
46
  columnize (0.3.6)
37
47
  diff-lcs (1.1.3)
38
48
  erubis (2.7.0)
39
- faraday (0.7.5)
40
- addressable (~> 2.2.6)
41
- multipart-post (~> 1.1.3)
42
- rack (>= 1.1.0, < 2)
49
+ faraday (0.8.4)
50
+ multipart-post (~> 1.1)
51
+ ffi (1.0.11)
43
52
  git (1.2.5)
44
53
  hike (1.2.1)
54
+ httpauth (0.2.0)
45
55
  i18n (0.6.0)
46
- jeweler (1.5.2)
47
- bundler (~> 1.0.0)
56
+ jeweler (1.8.3)
57
+ bundler (~> 1.0)
48
58
  git (>= 1.2.5)
49
59
  rake
50
- json (1.6.3)
60
+ rdoc
61
+ journey (1.0.3)
62
+ json (1.6.6)
63
+ jwt (0.1.5)
64
+ multi_json (>= 1.0)
51
65
  linecache19 (0.5.12)
52
66
  ruby_core_source (>= 0.1.4)
53
- mail (2.3.0)
67
+ mail (2.4.4)
54
68
  i18n (>= 0.4.0)
55
69
  mime-types (~> 1.16)
56
70
  treetop (~> 1.4.8)
57
- mime-types (1.17.2)
58
- multi_json (1.0.4)
59
- multipart-post (1.1.4)
71
+ mime-types (1.18)
72
+ mongo (1.6.1)
73
+ bson (~> 1.6.1)
74
+ mongo_mapper (0.11.1)
75
+ activemodel (~> 3.0)
76
+ activesupport (~> 3.0)
77
+ plucky (~> 0.4.0)
78
+ mongoid (2.4.7)
79
+ activemodel (~> 3.1)
80
+ mongo (~> 1.3)
81
+ tzinfo (~> 0.3.22)
82
+ multi_json (1.3.2)
83
+ multipart-post (1.1.5)
84
+ nokogiri (1.5.2)
60
85
  oauth (0.4.5)
61
- oauth2 (0.5.1)
62
- faraday (~> 0.7.4)
63
- multi_json (~> 1.0.3)
86
+ oauth2 (0.8.0)
87
+ faraday (~> 0.8)
88
+ httpauth (~> 0.1)
89
+ jwt (~> 0.1.4)
90
+ multi_json (~> 1.0)
91
+ rack (~> 1.2)
92
+ plucky (0.4.4)
93
+ mongo (~> 1.5)
64
94
  polyglot (0.3.3)
65
- rack (1.3.5)
66
- rack-cache (1.1)
95
+ rack (1.4.1)
96
+ rack-cache (1.2)
67
97
  rack (>= 0.4)
68
- rack-mount (0.8.3)
69
- rack (>= 1.0.0)
70
98
  rack-ssl (1.3.2)
71
99
  rack
72
100
  rack-test (0.6.1)
73
101
  rack (>= 1.0)
74
- rails (3.1.3)
75
- actionmailer (= 3.1.3)
76
- actionpack (= 3.1.3)
77
- activerecord (= 3.1.3)
78
- activeresource (= 3.1.3)
79
- activesupport (= 3.1.3)
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)
80
108
  bundler (~> 1.0)
81
- railties (= 3.1.3)
82
- railties (3.1.3)
83
- actionpack (= 3.1.3)
84
- activesupport (= 3.1.3)
109
+ railties (= 3.2.2)
110
+ railties (3.2.2)
111
+ actionpack (= 3.2.2)
112
+ activesupport (= 3.2.2)
85
113
  rack-ssl (~> 1.3.2)
86
114
  rake (>= 0.8.7)
87
115
  rdoc (~> 3.4)
@@ -112,11 +140,17 @@ GEM
112
140
  ruby-debug-base19 (>= 0.11.19)
113
141
  ruby_core_source (0.1.5)
114
142
  archive-tar-minitar (>= 0.5.2)
115
- simplecov (0.5.4)
116
- multi_json (~> 1.0.3)
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)
117
151
  simplecov-html (~> 0.5.3)
118
152
  simplecov-html (0.5.3)
119
- sprockets (2.0.3)
153
+ sprockets (2.1.2)
120
154
  hike (~> 1.2)
121
155
  rack (~> 1.0)
122
156
  tilt (~> 1.1, != 1.3.0)
@@ -129,18 +163,25 @@ GEM
129
163
  treetop (1.4.10)
130
164
  polyglot
131
165
  polyglot (>= 0.3.1)
132
- tzinfo (0.3.31)
166
+ tzinfo (0.3.32)
167
+ xpath (0.1.4)
168
+ nokogiri (~> 1.3)
133
169
  yard (0.6.8)
134
170
 
135
171
  PLATFORMS
136
172
  ruby
137
173
 
138
174
  DEPENDENCIES
139
- bundler (~> 1.0.0)
140
- jeweler (~> 1.5.2)
175
+ abstract (>= 1.0.0)
176
+ bcrypt-ruby (~> 3.0.0)
177
+ bundler (>= 1.1.0)
178
+ capybara
179
+ jeweler (~> 1.8.3)
141
180
  json (>= 1.5.1)
181
+ mongo_mapper
182
+ mongoid (~> 2.4.4)
142
183
  oauth (~> 0.4.4)
143
- oauth2 (~> 0.5.1)
184
+ oauth2 (~> 0.8.0)
144
185
  rails (>= 3.0.0)
145
186
  rspec (~> 2.5.0)
146
187
  rspec-rails (~> 2.5.0)
data/README.rdoc CHANGED
@@ -1,3 +1,5 @@
1
+ {<img src="https://secure.travis-ci.org/NoamB/sorcery.png" />}[http://travis-ci.org/NoamB/sorcery]
2
+
1
3
  = sorcery
2
4
  Magical Authentication for Rails 3.
3
5
  Supports ActiveRecord, Mongoid and MongoMapper.
@@ -5,7 +7,6 @@ Supports ActiveRecord, Mongoid and MongoMapper.
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
-
9
10
 
10
11
  == Philosophy
11
12
 
@@ -28,7 +29,7 @@ Railscast: http://railscasts.com/episodes/283-authentication-with-sorcery
28
29
 
29
30
  Example Rails 3 app using sorcery: https://github.com/NoamB/sorcery-example-app
30
31
 
31
- Documentation: http://rubydoc.info/gems/sorcery/0.7.6/frames
32
+ Documentation: http://rubydoc.info/gems/sorcery/0.8.0/frames
32
33
 
33
34
  Check out the tutorials in the github wiki!
34
35
 
@@ -82,15 +83,15 @@ Please see the tutorials in the github wiki for detailed usage information.
82
83
 
83
84
  If using bundler, first add 'sorcery' to your Gemfile:
84
85
 
85
- gem "sorcery"
86
+ gem "sorcery"
86
87
 
87
- And run
88
-
89
- bundle install
88
+ And run
89
+
90
+ bundle install
90
91
 
91
92
  Otherwise simply
92
93
 
93
- gem install sorcery
94
+ gem install sorcery
94
95
 
95
96
 
96
97
  == Rails 3 Configuration:
@@ -113,10 +114,34 @@ This will generate the core migration file, the initializer and change the model
113
114
 
114
115
  This will generate only the migration files for the specified submodules and will
115
116
  add them to the initializer file.
116
-
117
+
117
118
  Inside the initializer, the comments will tell you what each setting does.
118
119
 
119
120
 
121
+ == DelayedJob Integration
122
+
123
+ By default emails are sent synchronously. You can send them asynchronously by using the
124
+ [delayed_job gem](https://github.com/collectiveidea/delayed_job).
125
+
126
+ After implementing the `delayed_job` into your project add the code below at the end of
127
+ the `config/initializers/sorcery.rb` file. After that all emails will be sent asynchronously.
128
+
129
+ module Sorcery
130
+ module Model
131
+ module InstanceMethods
132
+ def generic_send_email(method, mailer)
133
+ config = sorcery_config
134
+ mail = config.send(mailer).delay.send(config.send(method), self)
135
+ end
136
+ end
137
+ end
138
+ end
139
+
140
+
141
+ == Single Table Inheritance (STI) Support
142
+ STI is supported via a single setting in config/initializers/sorcery.rb.
143
+
144
+
120
145
  == Full Features List by module:
121
146
 
122
147
 
data/Rakefile CHANGED
@@ -25,9 +25,6 @@ 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 'bcrypt-ruby', '~> 3.0.0'
29
- gem.add_runtime_dependency 'oauth', '~> 0.4.4'
30
- gem.add_runtime_dependency 'oauth2', '~> 0.5.1'
31
28
  end
32
29
  Jeweler::RubygemsDotOrgTasks.new
33
30
 
@@ -46,12 +43,14 @@ task :default => :all_sorcery_specs
46
43
 
47
44
  desc "Run all sorcery specs"
48
45
  task :all_sorcery_specs do
46
+ # we need to be empty, otherwise bundler will use parent bundler.
47
+ env = {
48
+ 'BUNDLE_GEMFILE' => nil,
49
+ 'GEM_HOME' => nil
50
+ }
49
51
  Dir['spec/**/Rakefile'].each do |rakefile|
50
52
  directory_name = File.dirname(rakefile)
51
- sh <<-CMD
52
- cd #{directory_name}
53
- bundle exec rake
54
- CMD
53
+ system(env, "cd #{directory_name} && bundle && bundle exec rake")
55
54
  end
56
55
  end
57
56
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.6
1
+ 0.8.0
@@ -24,16 +24,18 @@ module Sorcery
24
24
  def configure_initializer_file
25
25
  # Add submodules to the initializer file.
26
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()}]"
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
31
33
  end
32
34
 
33
35
  # Generate the model and add 'authenticates_with_sorcery!' unless you passed --migrations
34
36
  unless options[:migrations]
35
37
  generate "model #{model_class_name} --skip-migration"
36
- insert_into_file "app/models/#{model_class_name.downcase}.rb", " authenticates_with_sorcery!\n", :after => "class #{model_class_name} < ActiveRecord::Base\n"
38
+ insert_into_file "app/models/#{model_class_name.underscore}.rb", " authenticates_with_sorcery!\n", :after => "class #{model_class_name} < ActiveRecord::Base\n"
37
39
  end
38
40
  end
39
41
 
@@ -66,9 +68,9 @@ module Sorcery
66
68
 
67
69
  private
68
70
 
69
- # Either return the model passed in a capitalized form or return the default "User".
71
+ # Either return the model passed in a classified form or return the default "User".
70
72
  def model_class_name
71
- options[:model] ? options[:model].capitalize : "User"
73
+ options[:model] ? options[:model].classify : "User"
72
74
  end
73
75
  end
74
76
  end