sorcery 0.7.0 → 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.
- data/.travis.yml +3 -0
- data/Gemfile +9 -6
- data/Gemfile.lock +106 -75
- data/README.rdoc +42 -55
- data/Rakefile +32 -7
- data/VERSION +1 -1
- data/lib/generators/sorcery/USAGE +22 -0
- data/lib/generators/sorcery/install_generator.rb +77 -0
- data/lib/generators/sorcery/templates/initializer.rb +417 -0
- data/lib/generators/sorcery/templates/migration/activity_logging.rb +17 -0
- data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +13 -0
- data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/core.rb +2 -2
- data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/external.rb +1 -1
- data/lib/generators/sorcery/templates/migration/remember_me.rb +15 -0
- data/lib/generators/sorcery/templates/migration/reset_password.rb +17 -0
- data/lib/generators/sorcery/templates/migration/user_activation.rb +17 -0
- data/lib/sorcery/controller/submodules/activity_logging.rb +8 -11
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +2 -3
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +25 -10
- data/lib/sorcery/controller/submodules/external/providers/facebook.rb +20 -5
- data/lib/sorcery/controller/submodules/external/providers/github.rb +15 -4
- data/lib/sorcery/controller/submodules/external/providers/google.rb +90 -0
- data/lib/sorcery/controller/submodules/external/providers/linkedin.rb +101 -0
- data/lib/sorcery/controller/submodules/external/providers/liveid.rb +91 -0
- data/lib/sorcery/controller/submodules/external/providers/twitter.rb +3 -2
- data/lib/sorcery/controller/submodules/external/providers/vkontakte.rb +94 -0
- data/lib/sorcery/controller/submodules/external.rb +89 -15
- data/lib/sorcery/controller/submodules/http_basic_auth.rb +1 -1
- data/lib/sorcery/controller/submodules/remember_me.rb +26 -15
- data/lib/sorcery/controller/submodules/session_timeout.rb +3 -3
- data/lib/sorcery/controller.rb +55 -46
- data/lib/sorcery/crypto_providers/bcrypt.rb +1 -0
- data/lib/sorcery/model/adapters/active_record.rb +21 -1
- data/lib/sorcery/model/adapters/mongo_mapper.rb +56 -0
- data/lib/sorcery/model/adapters/mongoid.rb +23 -4
- data/lib/sorcery/model/submodules/activity_logging.rb +4 -4
- data/lib/sorcery/model/submodules/brute_force_protection.rb +54 -15
- data/lib/sorcery/model/submodules/remember_me.rb +12 -7
- data/lib/sorcery/model/submodules/reset_password.rb +27 -11
- data/lib/sorcery/model/submodules/user_activation.rb +27 -8
- data/lib/sorcery/model/temporary_token.rb +4 -2
- data/lib/sorcery/model.rb +78 -47
- data/lib/sorcery/railties/tasks.rake +2 -0
- data/lib/sorcery.rb +10 -8
- data/sorcery.gemspec +107 -228
- data/spec/Gemfile +1 -1
- data/spec/Gemfile.lock +27 -23
- data/spec/README.md +12 -7
- data/spec/rails3/Gemfile +3 -3
- data/spec/rails3/Gemfile.lock +62 -55
- data/spec/rails3/app/controllers/application_controller.rb +85 -2
- data/spec/rails3/app/mailers/sorcery_mailer.rb +7 -0
- data/spec/rails3/app/views/sorcery_mailer/send_unlock_token_email.text.erb +1 -0
- data/spec/rails3/config/environments/in_memory.rb +35 -0
- data/spec/rails3/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +2 -0
- data/spec/rails3/spec/controller_activity_logging_spec.rb +16 -6
- data/spec/rails3/spec/controller_brute_force_protection_spec.rb +25 -3
- data/spec/rails3/spec/controller_oauth2_spec.rb +260 -20
- data/spec/rails3/spec/controller_oauth_spec.rb +111 -6
- data/spec/rails3/spec/controller_session_timeout_spec.rb +4 -4
- data/spec/rails3/spec/controller_spec.rb +37 -2
- data/spec/rails3/spec/integration_spec.rb +15 -15
- data/spec/rails3/spec/spec_helper.rb +0 -2
- data/spec/rails3_mongo_mapper/.gitignore +4 -0
- data/spec/rails3_mongo_mapper/.rspec +1 -0
- data/spec/{sinatra_modular → rails3_mongo_mapper}/Gemfile +6 -5
- data/spec/rails3_mongo_mapper/Gemfile.lock +156 -0
- data/spec/{sinatra → rails3_mongo_mapper}/Rakefile +3 -3
- data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +122 -0
- data/spec/rails3_mongo_mapper/app/helpers/application_helper.rb +2 -0
- data/spec/rails3_mongo_mapper/app/models/authentication.rb +6 -0
- data/spec/rails3_mongo_mapper/app/models/user.rb +5 -0
- data/spec/rails3_mongo_mapper/app/views/layouts/application.html.erb +14 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.html.erb +17 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.text.erb +9 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.html.erb +17 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.text.erb +9 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.html.erb +16 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.text.erb +8 -0
- data/spec/rails3_mongo_mapper/config/application.rb +51 -0
- data/spec/rails3_mongo_mapper/config/boot.rb +13 -0
- data/spec/rails3_mongo_mapper/config/environment.rb +5 -0
- data/spec/rails3_mongo_mapper/config/environments/development.rb +30 -0
- data/spec/rails3_mongo_mapper/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongo_mapper/config/environments/production.rb +49 -0
- data/spec/rails3_mongo_mapper/config/environments/test.rb +35 -0
- data/spec/rails3_mongo_mapper/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails3_mongo_mapper/config/initializers/inflections.rb +10 -0
- data/spec/rails3_mongo_mapper/config/initializers/mime_types.rb +5 -0
- data/spec/rails3_mongo_mapper/config/initializers/mongo.rb +2 -0
- data/spec/rails3_mongo_mapper/config/initializers/secret_token.rb +7 -0
- data/spec/rails3_mongo_mapper/config/initializers/session_store.rb +8 -0
- data/spec/rails3_mongo_mapper/config/locales/en.yml +5 -0
- data/spec/rails3_mongo_mapper/config/routes.rb +59 -0
- data/spec/rails3_mongo_mapper/config.ru +4 -0
- data/spec/rails3_mongo_mapper/db/schema.rb +23 -0
- data/spec/rails3_mongo_mapper/db/seeds.rb +7 -0
- data/spec/rails3_mongo_mapper/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/public/404.html +26 -0
- data/spec/rails3_mongo_mapper/public/422.html +26 -0
- data/spec/rails3_mongo_mapper/public/500.html +26 -0
- data/spec/rails3_mongo_mapper/public/favicon.ico +0 -0
- data/spec/rails3_mongo_mapper/public/images/rails.png +0 -0
- data/spec/rails3_mongo_mapper/public/javascripts/application.js +2 -0
- data/spec/rails3_mongo_mapper/public/javascripts/controls.js +965 -0
- data/spec/rails3_mongo_mapper/public/javascripts/dragdrop.js +974 -0
- data/spec/rails3_mongo_mapper/public/javascripts/effects.js +1123 -0
- data/spec/rails3_mongo_mapper/public/javascripts/prototype.js +6001 -0
- data/spec/rails3_mongo_mapper/public/javascripts/rails.js +175 -0
- data/spec/rails3_mongo_mapper/public/robots.txt +5 -0
- data/spec/rails3_mongo_mapper/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/script/rails +6 -0
- data/spec/rails3_mongo_mapper/spec/controller_spec.rb +170 -0
- data/spec/rails3_mongo_mapper/spec/spec_helper.orig.rb +27 -0
- data/spec/rails3_mongo_mapper/spec/spec_helper.rb +55 -0
- data/spec/rails3_mongo_mapper/spec/user_activation_spec.rb +9 -0
- data/spec/rails3_mongo_mapper/spec/user_activity_logging_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_brute_force_protection_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_oauth_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_remember_me_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_reset_password_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_spec.rb +37 -0
- data/spec/rails3_mongo_mapper/vendor/plugins/.gitkeep +0 -0
- data/spec/rails3_mongoid/Gemfile +2 -1
- data/spec/rails3_mongoid/Gemfile.lock +47 -42
- data/spec/rails3_mongoid/app/controllers/application_controller.rb +19 -0
- data/spec/rails3_mongoid/config/mongoid.yml +1 -1
- data/spec/rails3_mongoid/script/rails +0 -0
- data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +105 -0
- data/spec/rails3_mongoid/spec/controller_spec.rb +52 -1
- data/spec/rails3_mongoid/spec/user_spec.rb +1 -0
- data/spec/shared_examples/controller_oauth2_shared_examples.rb +20 -1
- data/spec/shared_examples/controller_oauth_shared_examples.rb +18 -0
- data/spec/shared_examples/user_activation_shared_examples.rb +72 -42
- data/spec/shared_examples/user_remember_me_shared_examples.rb +1 -1
- data/spec/shared_examples/user_reset_password_shared_examples.rb +81 -28
- data/spec/shared_examples/user_shared_examples.rb +29 -1
- data/spec/sorcery_crypto_providers_spec.rb +14 -1
- metadata +111 -229
- data/lib/generators/sorcery_migration/sorcery_migration_generator.rb +0 -24
- data/lib/generators/sorcery_migration/templates/activity_logging.rb +0 -17
- data/lib/generators/sorcery_migration/templates/brute_force_protection.rb +0 -11
- data/lib/generators/sorcery_migration/templates/remember_me.rb +0 -15
- data/lib/generators/sorcery_migration/templates/reset_password.rb +0 -17
- data/lib/generators/sorcery_migration/templates/user_activation.rb +0 -17
- data/lib/sorcery/controller/adapters/sinatra.rb +0 -115
- data/lib/sorcery/initializers/initializer.rb +0 -199
- data/lib/sorcery/sinatra.rb +0 -4
- data/lib/sorcery/test_helpers/internal/sinatra.rb +0 -74
- data/lib/sorcery/test_helpers/internal/sinatra_modular.rb +0 -74
- data/lib/sorcery/test_helpers/sinatra.rb +0 -88
- data/spec/rails3/Rakefile.unused +0 -7
- data/spec/sinatra/Gemfile +0 -15
- data/spec/sinatra/Gemfile.lock +0 -115
- data/spec/sinatra/authentication.rb +0 -3
- data/spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
- data/spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
- data/spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
- data/spec/sinatra/db/migrate/core/20101224223620_create_users.rb +0 -16
- data/spec/sinatra/db/migrate/external/20101224223628_create_authentications.rb +0 -14
- data/spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
- data/spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
- data/spec/sinatra/filters.rb +0 -27
- data/spec/sinatra/modular.rb +0 -157
- data/spec/sinatra/myapp.rb +0 -133
- data/spec/sinatra/spec/controller_activity_logging_spec.rb +0 -85
- data/spec/sinatra/spec/controller_brute_force_protection_spec.rb +0 -70
- data/spec/sinatra/spec/controller_http_basic_auth_spec.rb +0 -53
- data/spec/sinatra/spec/controller_oauth2_spec.rb +0 -96
- data/spec/sinatra/spec/controller_oauth_spec.rb +0 -100
- data/spec/sinatra/spec/controller_remember_me_spec.rb +0 -64
- data/spec/sinatra/spec/controller_session_timeout_spec.rb +0 -57
- data/spec/sinatra/spec/controller_spec.rb +0 -127
- data/spec/sinatra/spec/spec_helper.rb +0 -45
- data/spec/sinatra/user.rb +0 -6
- data/spec/sinatra/views/test_login.erb +0 -4
- data/spec/sinatra_modular/Gemfile.lock +0 -115
- data/spec/sinatra_modular/Rakefile +0 -11
- data/spec/sinatra_modular/authentication.rb +0 -3
- data/spec/sinatra_modular/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
- data/spec/sinatra_modular/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
- data/spec/sinatra_modular/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
- data/spec/sinatra_modular/db/migrate/core/20101224223620_create_users.rb +0 -16
- data/spec/sinatra_modular/db/migrate/external/20101224223628_create_authentications.rb +0 -14
- data/spec/sinatra_modular/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
- data/spec/sinatra_modular/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
- data/spec/sinatra_modular/filters.rb +0 -27
- data/spec/sinatra_modular/modular.rb +0 -157
- data/spec/sinatra_modular/myapp.rb +0 -133
- data/spec/sinatra_modular/sorcery_mailer.rb +0 -25
- data/spec/sinatra_modular/spec_modular/controller_activity_logging_spec.rb +0 -85
- data/spec/sinatra_modular/spec_modular/controller_brute_force_protection_spec.rb +0 -70
- data/spec/sinatra_modular/spec_modular/controller_http_basic_auth_spec.rb +0 -53
- data/spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb +0 -96
- data/spec/sinatra_modular/spec_modular/controller_oauth_spec.rb +0 -100
- data/spec/sinatra_modular/spec_modular/controller_remember_me_spec.rb +0 -64
- data/spec/sinatra_modular/spec_modular/controller_session_timeout_spec.rb +0 -57
- data/spec/sinatra_modular/spec_modular/controller_spec.rb +0 -116
- data/spec/sinatra_modular/spec_modular/spec.opts +0 -2
- data/spec/sinatra_modular/spec_modular/spec_helper.rb +0 -51
- data/spec/sinatra_modular/user.rb +0 -6
- data/spec/sinatra_modular/views/test_login.erb +0 -4
- /data/spec/{sinatra → rails3_mongo_mapper/app/mailers}/sorcery_mailer.rb +0 -0
- /data/spec/{sinatra → rails3_mongo_mapper}/spec/spec.opts +0 -0
data/.travis.yml
ADDED
data/Gemfile
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
source
|
|
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.
|
|
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
|
-
gem "mongoid", "~> 2.0"
|
|
14
|
-
gem "bson_ext", "~> 1.3"
|
|
15
15
|
gem "rspec", "~> 2.5.0"
|
|
16
16
|
gem 'rspec-rails', "~> 2.5.0"
|
|
17
17
|
gem 'ruby-debug19'
|
|
18
18
|
gem 'sqlite3-ruby', :require => 'sqlite3'
|
|
19
19
|
gem "yard", "~> 0.6.0"
|
|
20
|
-
gem "bundler", "
|
|
21
|
-
gem "jeweler", "~> 1.
|
|
20
|
+
gem "bundler", ">= 1.1.0"
|
|
21
|
+
gem "jeweler", "~> 1.8.3"
|
|
22
22
|
gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
|
|
23
23
|
gem 'timecop'
|
|
24
|
+
gem 'capybara'
|
|
25
|
+
gem 'mongo_mapper'
|
|
26
|
+
gem 'mongoid', "~> 2.4.4"
|
|
24
27
|
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,103 +1,122 @@
|
|
|
1
1
|
GEM
|
|
2
2
|
remote: http://rubygems.org/
|
|
3
3
|
specs:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
13
|
-
rack (~> 1.
|
|
14
|
-
rack-cache (~> 1.
|
|
15
|
-
rack-mount (~> 0.8.2)
|
|
13
|
+
journey (~> 1.0.1)
|
|
14
|
+
rack (~> 1.4.0)
|
|
15
|
+
rack-cache (~> 1.1)
|
|
16
16
|
rack-test (~> 0.6.1)
|
|
17
|
-
sprockets (~> 2.
|
|
18
|
-
activemodel (3.
|
|
19
|
-
activesupport (= 3.
|
|
20
|
-
bcrypt-ruby (~> 3.0.0)
|
|
17
|
+
sprockets (~> 2.1.2)
|
|
18
|
+
activemodel (3.2.2)
|
|
19
|
+
activesupport (= 3.2.2)
|
|
21
20
|
builder (~> 3.0.0)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
arel (~> 2.2.1)
|
|
21
|
+
activerecord (3.2.2)
|
|
22
|
+
activemodel (= 3.2.2)
|
|
23
|
+
activesupport (= 3.2.2)
|
|
24
|
+
arel (~> 3.0.2)
|
|
27
25
|
tzinfo (~> 0.3.29)
|
|
28
|
-
activeresource (3.
|
|
29
|
-
activemodel (= 3.
|
|
30
|
-
activesupport (= 3.
|
|
31
|
-
activesupport (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)
|
|
32
31
|
multi_json (~> 1.0)
|
|
33
|
-
addressable (2.2.6)
|
|
34
32
|
archive-tar-minitar (0.5.2)
|
|
35
|
-
arel (
|
|
36
|
-
bcrypt-ruby (3.0.
|
|
37
|
-
bson (1.
|
|
38
|
-
bson_ext (1.3.1)
|
|
33
|
+
arel (3.0.2)
|
|
34
|
+
bcrypt-ruby (3.0.1)
|
|
35
|
+
bson (1.6.1)
|
|
39
36
|
builder (3.0.0)
|
|
40
|
-
|
|
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)
|
|
46
|
+
columnize (0.3.6)
|
|
41
47
|
diff-lcs (1.1.3)
|
|
42
48
|
erubis (2.7.0)
|
|
43
|
-
faraday (0.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
rack (< 2, >= 1.1.0)
|
|
49
|
+
faraday (0.8.4)
|
|
50
|
+
multipart-post (~> 1.1)
|
|
51
|
+
ffi (1.0.11)
|
|
47
52
|
git (1.2.5)
|
|
48
53
|
hike (1.2.1)
|
|
54
|
+
httpauth (0.2.0)
|
|
49
55
|
i18n (0.6.0)
|
|
50
|
-
jeweler (1.
|
|
51
|
-
bundler (~> 1.0
|
|
56
|
+
jeweler (1.8.3)
|
|
57
|
+
bundler (~> 1.0)
|
|
52
58
|
git (>= 1.2.5)
|
|
53
59
|
rake
|
|
54
|
-
|
|
60
|
+
rdoc
|
|
61
|
+
journey (1.0.3)
|
|
62
|
+
json (1.6.6)
|
|
63
|
+
jwt (0.1.5)
|
|
64
|
+
multi_json (>= 1.0)
|
|
55
65
|
linecache19 (0.5.12)
|
|
56
66
|
ruby_core_source (>= 0.1.4)
|
|
57
|
-
mail (2.
|
|
67
|
+
mail (2.4.4)
|
|
58
68
|
i18n (>= 0.4.0)
|
|
59
69
|
mime-types (~> 1.16)
|
|
60
70
|
treetop (~> 1.4.8)
|
|
61
|
-
mime-types (1.
|
|
62
|
-
mongo (1.
|
|
63
|
-
bson (
|
|
64
|
-
|
|
71
|
+
mime-types (1.18)
|
|
72
|
+
mongo (1.6.1)
|
|
73
|
+
bson (~> 1.6.1)
|
|
74
|
+
mongo_mapper (0.11.1)
|
|
65
75
|
activemodel (~> 3.0)
|
|
76
|
+
activesupport (~> 3.0)
|
|
77
|
+
plucky (~> 0.4.0)
|
|
78
|
+
mongoid (2.4.7)
|
|
79
|
+
activemodel (~> 3.1)
|
|
66
80
|
mongo (~> 1.3)
|
|
67
81
|
tzinfo (~> 0.3.22)
|
|
68
|
-
multi_json (1.
|
|
69
|
-
multipart-post (1.1.
|
|
82
|
+
multi_json (1.3.2)
|
|
83
|
+
multipart-post (1.1.5)
|
|
84
|
+
nokogiri (1.5.2)
|
|
70
85
|
oauth (0.4.5)
|
|
71
|
-
oauth2 (0.
|
|
72
|
-
faraday (~> 0.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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)
|
|
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.
|
|
85
|
-
actionmailer (= 3.
|
|
86
|
-
actionpack (= 3.
|
|
87
|
-
activerecord (= 3.
|
|
88
|
-
activeresource (= 3.
|
|
89
|
-
activesupport (= 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)
|
|
90
108
|
bundler (~> 1.0)
|
|
91
|
-
railties (= 3.
|
|
92
|
-
railties (3.
|
|
93
|
-
actionpack (= 3.
|
|
94
|
-
activesupport (= 3.
|
|
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.
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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 (
|
|
131
|
-
sqlite3 (1.3.
|
|
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,20 +163,25 @@ GEM
|
|
|
137
163
|
treetop (1.4.10)
|
|
138
164
|
polyglot
|
|
139
165
|
polyglot (>= 0.3.1)
|
|
140
|
-
tzinfo (0.3.
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
175
|
+
abstract (>= 1.0.0)
|
|
176
|
+
bcrypt-ruby (~> 3.0.0)
|
|
177
|
+
bundler (>= 1.1.0)
|
|
178
|
+
capybara
|
|
179
|
+
jeweler (~> 1.8.3)
|
|
150
180
|
json (>= 1.5.1)
|
|
151
|
-
|
|
181
|
+
mongo_mapper
|
|
182
|
+
mongoid (~> 2.4.4)
|
|
152
183
|
oauth (~> 0.4.4)
|
|
153
|
-
oauth2 (~> 0.
|
|
184
|
+
oauth2 (~> 0.8.0)
|
|
154
185
|
rails (>= 3.0.0)
|
|
155
186
|
rspec (~> 2.5.0)
|
|
156
187
|
rspec-rails (~> 2.5.0)
|
data/README.rdoc
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
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
|
|
3
|
-
Supports ActiveRecord and
|
|
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
|
-
|
|
9
10
|
|
|
10
11
|
== Philosophy
|
|
11
12
|
|
|
@@ -28,9 +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
|
-
|
|
32
|
-
|
|
33
|
-
Documentation: http://rubydoc.info/gems/sorcery/0.7.0/frames
|
|
32
|
+
Documentation: http://rubydoc.info/gems/sorcery/0.8.0/frames
|
|
34
33
|
|
|
35
34
|
Check out the tutorials in the github wiki!
|
|
36
35
|
|
|
@@ -84,72 +83,63 @@ Please see the tutorials in the github wiki for detailed usage information.
|
|
|
84
83
|
|
|
85
84
|
If using bundler, first add 'sorcery' to your Gemfile:
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
gem "sorcery"
|
|
88
87
|
|
|
89
|
-
And run
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
And run
|
|
89
|
+
|
|
90
|
+
bundle install
|
|
92
91
|
|
|
93
92
|
Otherwise simply
|
|
94
93
|
|
|
95
|
-
|
|
94
|
+
gem install sorcery
|
|
96
95
|
|
|
97
96
|
|
|
98
97
|
== Rails 3 Configuration:
|
|
99
98
|
|
|
99
|
+
rails generate sorcery:install
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
This will generate the core migration file, the initializer file and the 'User' model class.
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
rails generate sorcery:install remember_me reset_password
|
|
104
104
|
|
|
105
|
-
This will
|
|
106
|
-
|
|
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.
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
rails generate sorcery:install --model Person
|
|
109
109
|
|
|
110
|
-
|
|
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')
|
|
111
112
|
|
|
112
|
-
|
|
113
|
-
For example, for only the core functionality use:
|
|
113
|
+
rails generate sorcery:install http_basic_auth external remember_me --migrations
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
This will generate only the migration files for the specified submodules and will
|
|
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
|
-
rails g sorcery_migration core remember_me
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
== DelayedJob Integration
|
|
122
122
|
|
|
123
|
-
|
|
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).
|
|
124
125
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
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
|
|
146
136
|
end
|
|
147
137
|
end
|
|
138
|
+
end
|
|
148
139
|
|
|
149
|
-
Finally, to make all the code above take effect, we'll need to re-include the sorcery controller module:
|
|
150
140
|
|
|
151
|
-
|
|
152
|
-
|
|
141
|
+
== Single Table Inheritance (STI) Support
|
|
142
|
+
STI is supported via a single setting in config/initializers/sorcery.rb.
|
|
153
143
|
|
|
154
144
|
|
|
155
145
|
== Full Features List by module:
|
|
@@ -216,13 +206,6 @@ I've got some thoughts which include (unordered):
|
|
|
216
206
|
Have an idea? Let me know, and it might get into the gem!
|
|
217
207
|
|
|
218
208
|
|
|
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
209
|
== Backward compatibility
|
|
227
210
|
|
|
228
211
|
|
|
@@ -238,11 +221,15 @@ The same cannot be said about upgrading to x.4.0 and above, however.
|
|
|
238
221
|
|
|
239
222
|
Important notes while upgrading:
|
|
240
223
|
|
|
224
|
+
* If upgrading from <= 0.6.1 to >= 0.7.0 you need to change 'username_attribute_name' to 'username_attribute_names' in initializer.
|
|
241
225
|
* If upgrading from <= v0.5.1 to >= v0.5.2 you need to explicitly set your user_class model in the initializer file.
|
|
242
226
|
|
|
243
227
|
# This line must come after the 'user config' block.
|
|
244
228
|
config.user_class = User
|
|
245
229
|
|
|
230
|
+
* Sinatra support existed until v0.7.0 (including), but was dropped later due to being a maintenance nightmare.
|
|
231
|
+
|
|
232
|
+
|
|
246
233
|
== Contributing to sorcery
|
|
247
234
|
|
|
248
235
|
|
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,11 +43,39 @@ 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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
system(env, "cd #{directory_name} && bundle && bundle exec rake")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
desc "Bundle all folders"
|
|
58
|
+
task :bundle do
|
|
59
|
+
sh "bundle"
|
|
60
|
+
Dir['spec', 'spec/**'].each do |dir|
|
|
61
|
+
if Dir.exists?(dir) && File.exists?(dir + "/Gemfile")
|
|
62
|
+
sh <<-CMD
|
|
63
|
+
cd #{dir}
|
|
64
|
+
bundle
|
|
65
|
+
CMD
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
desc "Bundle update all folders"
|
|
71
|
+
task :bundle_update do
|
|
72
|
+
sh "bundle update"
|
|
73
|
+
Dir['spec', 'spec/**'].each do |dir|
|
|
74
|
+
if Dir.exists?(dir) && File.exists?(dir + "/Gemfile")
|
|
75
|
+
sh <<-CMD
|
|
76
|
+
cd #{dir}
|
|
77
|
+
bundle update
|
|
78
|
+
CMD
|
|
79
|
+
end
|
|
55
80
|
end
|
|
56
81
|
end
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.8.0
|
|
@@ -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
|