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.
- data/.travis.yml +2 -0
- data/Gemfile +2 -23
- data/Gemfile.lock +105 -77
- data/README.rdoc +32 -59
- data/Rakefile +29 -1
- 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 +406 -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 +3 -3
- 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 +24 -10
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +3 -2
- data/lib/sorcery/controller/submodules/external/protocols/certs/ca-bundle.crt +5182 -0
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +28 -9
- data/lib/sorcery/controller/submodules/external/providers/facebook.rb +12 -4
- data/lib/sorcery/controller/submodules/external/providers/github.rb +89 -0
- data/lib/sorcery/controller/submodules/external/providers/google.rb +90 -0
- data/lib/sorcery/controller/submodules/external/providers/liveid.rb +91 -0
- data/lib/sorcery/controller/submodules/external/providers/twitter.rb +8 -2
- data/lib/sorcery/controller/submodules/external.rb +17 -4
- 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 +4 -4
- data/lib/sorcery/controller.rb +61 -38
- data/lib/sorcery/crypto_providers/aes256.rb +7 -3
- data/lib/sorcery/engine.rb +1 -0
- data/lib/sorcery/model/adapters/active_record.rb +17 -1
- data/lib/sorcery/model/adapters/mongo_mapper.rb +54 -0
- data/lib/sorcery/model/adapters/mongoid.rb +22 -4
- data/lib/sorcery/model/submodules/activity_logging.rb +4 -4
- data/lib/sorcery/model/submodules/brute_force_protection.rb +53 -14
- data/lib/sorcery/model/submodules/remember_me.rb +10 -3
- data/lib/sorcery/model/submodules/reset_password.rb +26 -11
- data/lib/sorcery/model/submodules/user_activation.rb +28 -10
- data/lib/sorcery/model/temporary_token.rb +8 -1
- data/lib/sorcery/model.rb +51 -19
- data/lib/sorcery/test_helpers/internal/rails.rb +1 -1
- data/lib/sorcery/test_helpers/rails.rb +2 -2
- data/lib/sorcery.rb +8 -7
- data/sorcery.gemspec +110 -223
- data/spec/Gemfile +1 -1
- data/spec/Gemfile.lock +26 -26
- data/spec/README.md +31 -0
- data/spec/rails3/Gemfile +5 -3
- data/spec/rails3/Gemfile.lock +74 -48
- data/spec/rails3/app/controllers/application_controller.rb +70 -23
- data/spec/rails3/app/mailers/sorcery_mailer.rb +7 -0
- data/spec/rails3/app/views/application/index.html.erb +17 -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 +33 -3
- data/spec/rails3/spec/controller_brute_force_protection_spec.rb +25 -3
- data/spec/rails3/spec/controller_oauth2_spec.rb +170 -25
- data/spec/rails3/spec/controller_remember_me_spec.rb +37 -6
- data/spec/rails3/spec/controller_session_timeout_spec.rb +4 -4
- data/spec/rails3/spec/controller_spec.rb +60 -2
- data/spec/rails3/spec/integration_spec.rb +23 -0
- data/spec/rails3/spec/spec_helper.rb +6 -5
- 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 +154 -0
- data/spec/{sinatra → rails3_mongo_mapper}/Rakefile +3 -3
- data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +108 -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 +163 -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 +46 -45
- data/spec/rails3_mongoid/app/controllers/application_controller.rb +5 -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 +174 -0
- data/spec/rails3_mongoid/spec/user_spec.rb +1 -0
- data/spec/shared_examples/user_activation_shared_examples.rb +72 -42
- data/spec/shared_examples/user_remember_me_shared_examples.rb +2 -1
- data/spec/shared_examples/user_reset_password_shared_examples.rb +81 -28
- data/spec/shared_examples/user_shared_examples.rb +36 -8
- data/spec/sorcery_crypto_providers_spec.rb +5 -1
- metadata +239 -346
- 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 -13
- data/lib/generators/sorcery_migration/templates/user_activation.rb +0 -17
- data/lib/sorcery/controller/adapters/sinatra.rb +0 -104
- data/lib/sorcery/initializers/initializer.rb +0 -178
- 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/rails3/public/index.html +0 -239
- data/spec/sinatra/Gemfile +0 -15
- data/spec/sinatra/Gemfile.lock +0 -117
- 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 -99
- 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 -120
- 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 -117
- 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 -99
- 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,3 @@
|
|
|
1
|
-
source
|
|
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
|
-
|
|
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.
|
|
5
|
-
actionpack (= 3.
|
|
6
|
-
mail (~> 2.
|
|
7
|
-
actionpack (3.
|
|
8
|
-
activemodel (= 3.
|
|
9
|
-
activesupport (= 3.
|
|
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
|
-
|
|
13
|
-
rack (~> 1.
|
|
14
|
-
rack-cache (~> 1.
|
|
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.
|
|
18
|
-
activemodel (3.
|
|
19
|
-
activesupport (= 3.
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.
|
|
29
|
-
activemodel (= 3.
|
|
30
|
-
activesupport (= 3.
|
|
31
|
-
activesupport (3.
|
|
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.
|
|
41
|
+
addressable (2.2.7)
|
|
34
42
|
archive-tar-minitar (0.5.2)
|
|
35
|
-
arel (
|
|
36
|
-
bcrypt-ruby (3.0.
|
|
37
|
-
bson (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
|
-
|
|
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
|
|
44
|
-
addressable (~> 2.2
|
|
45
|
-
multipart-post (~> 1.1
|
|
46
|
-
rack (
|
|
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.
|
|
51
|
-
bundler (~> 1.0
|
|
67
|
+
jeweler (1.8.3)
|
|
68
|
+
bundler (~> 1.0)
|
|
52
69
|
git (>= 1.2.5)
|
|
53
70
|
rake
|
|
54
|
-
|
|
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.
|
|
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.
|
|
62
|
-
mongo (1.
|
|
63
|
-
bson (
|
|
64
|
-
mongoid (2.
|
|
65
|
-
activemodel (~> 3.
|
|
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
|
|
69
|
-
multipart-post (1.1.
|
|
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.
|
|
72
|
-
faraday (~> 0.
|
|
73
|
-
multi_json (
|
|
74
|
-
polyglot (0.3.
|
|
75
|
-
rack (1.
|
|
76
|
-
rack-cache (1.
|
|
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.
|
|
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,25 +163,27 @@ 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
|
-
bundler (
|
|
149
|
-
|
|
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.
|
|
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
|
|
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
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
|
-
|
|
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
|
-
|
|
86
|
+
gem "sorcery"
|
|
85
87
|
|
|
86
|
-
And run
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
And run
|
|
89
|
+
|
|
90
|
+
bundle install
|
|
89
91
|
|
|
90
92
|
Otherwise simply
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
gem install sorcery
|
|
93
95
|
|
|
94
96
|
|
|
95
97
|
== Rails 3 Configuration:
|
|
96
98
|
|
|
99
|
+
rails generate sorcery:install
|
|
97
100
|
|
|
98
|
-
|
|
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
|
-
|
|
103
|
+
rails generate sorcery:install remember_me reset_password
|
|
110
104
|
|
|
111
|
-
|
|
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
|
-
|
|
108
|
+
rails generate sorcery:install --model Person
|
|
114
109
|
|
|
115
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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
|