sorcery 0.8.1 → 0.9.1
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.
- checksums.yaml +7 -0
- data/.gitignore +56 -0
- data/.travis.yml +130 -1
- data/CHANGELOG.md +279 -0
- data/Gemfile +18 -23
- data/README.md +372 -0
- data/Rakefile +3 -78
- data/gemfiles/active_record-rails40.gemfile +7 -0
- data/gemfiles/active_record-rails41.gemfile +7 -0
- data/gemfiles/mongo_mapper-rails40.gemfile +9 -0
- data/gemfiles/mongo_mapper-rails41.gemfile +9 -0
- data/gemfiles/mongoid-rails40.gemfile +9 -0
- data/gemfiles/mongoid-rails41.gemfile +9 -0
- data/gemfiles/mongoid3-rails32.gemfile +9 -0
- data/lib/generators/sorcery/USAGE +1 -1
- data/lib/generators/sorcery/helpers.rb +40 -0
- data/lib/generators/sorcery/install_generator.rb +38 -20
- data/lib/generators/sorcery/templates/initializer.rb +53 -16
- data/lib/generators/sorcery/templates/migration/activity_logging.rb +3 -10
- data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +3 -7
- data/lib/generators/sorcery/templates/migration/core.rb +5 -8
- data/lib/generators/sorcery/templates/migration/external.rb +3 -5
- data/lib/generators/sorcery/templates/migration/remember_me.rb +2 -9
- data/lib/generators/sorcery/templates/migration/reset_password.rb +2 -10
- data/lib/generators/sorcery/templates/migration/user_activation.rb +2 -10
- data/lib/sorcery/adapters/active_record_adapter.rb +120 -0
- data/lib/sorcery/adapters/base_adapter.rb +30 -0
- data/lib/sorcery/adapters/data_mapper_adapter.rb +176 -0
- data/lib/sorcery/adapters/mongo_mapper_adapter.rb +110 -0
- data/lib/sorcery/adapters/mongoid_adapter.rb +97 -0
- data/lib/sorcery/controller/config.rb +65 -0
- data/lib/sorcery/controller/submodules/activity_logging.rb +27 -21
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +6 -6
- data/lib/sorcery/controller/submodules/external.rb +107 -75
- data/lib/sorcery/controller/submodules/remember_me.rb +5 -5
- data/lib/sorcery/controller/submodules/session_timeout.rb +11 -7
- data/lib/sorcery/controller.rb +27 -76
- data/lib/sorcery/model/config.rb +96 -0
- data/lib/sorcery/model/submodules/activity_logging.rb +32 -12
- data/lib/sorcery/model/submodules/brute_force_protection.rb +36 -36
- data/lib/sorcery/model/submodules/external.rb +53 -9
- data/lib/sorcery/model/submodules/remember_me.rb +15 -19
- data/lib/sorcery/model/submodules/reset_password.rb +36 -33
- data/lib/sorcery/model/submodules/user_activation.rb +51 -48
- data/lib/sorcery/model/temporary_token.rb +4 -4
- data/lib/sorcery/model.rb +85 -175
- data/lib/sorcery/protocols/oauth.rb +42 -0
- data/lib/sorcery/protocols/oauth2.rb +47 -0
- data/lib/sorcery/providers/base.rb +38 -0
- data/lib/sorcery/providers/facebook.rb +74 -0
- data/lib/sorcery/providers/github.rb +60 -0
- data/lib/sorcery/providers/google.rb +51 -0
- data/lib/sorcery/providers/heroku.rb +57 -0
- data/lib/sorcery/providers/jira.rb +77 -0
- data/lib/sorcery/providers/linkedin.rb +66 -0
- data/lib/sorcery/providers/liveid.rb +53 -0
- data/lib/sorcery/providers/salesforce.rb +50 -0
- data/lib/sorcery/providers/twitter.rb +59 -0
- data/lib/sorcery/providers/vk.rb +63 -0
- data/lib/sorcery/providers/xing.rb +64 -0
- data/lib/sorcery/railties/tasks.rake +1 -7
- data/lib/sorcery/test_helpers/internal/rails.rb +17 -6
- data/lib/sorcery/test_helpers/internal.rb +27 -6
- data/lib/sorcery/test_helpers/rails/controller.rb +21 -0
- data/lib/sorcery/test_helpers/rails/integration.rb +26 -0
- data/lib/sorcery/version.rb +3 -0
- data/lib/sorcery.rb +83 -57
- data/sorcery.gemspec +24 -363
- data/spec/active_record/user_activation_spec.rb +18 -0
- data/spec/active_record/user_activity_logging_spec.rb +17 -0
- data/spec/{rails3/spec → active_record}/user_brute_force_protection_spec.rb +6 -5
- data/spec/{rails3/spec → active_record}/user_oauth_spec.rb +6 -5
- data/spec/{rails3/spec → active_record}/user_remember_me_spec.rb +5 -4
- data/spec/{rails3/spec → active_record}/user_reset_password_spec.rb +7 -7
- data/spec/active_record/user_spec.rb +37 -0
- data/spec/controllers/controller_activity_logging_spec.rb +124 -0
- data/spec/controllers/controller_brute_force_protection_spec.rb +43 -0
- data/spec/controllers/controller_http_basic_auth_spec.rb +68 -0
- data/spec/controllers/controller_oauth2_spec.rb +429 -0
- data/spec/controllers/controller_oauth_spec.rb +240 -0
- data/spec/controllers/controller_remember_me_spec.rb +117 -0
- data/spec/controllers/controller_session_timeout_spec.rb +80 -0
- data/spec/controllers/controller_spec.rb +218 -0
- data/spec/data_mapper/user_activation_spec.rb +10 -0
- data/spec/data_mapper/user_activity_logging_spec.rb +14 -0
- data/spec/data_mapper/user_brute_force_protection_spec.rb +9 -0
- data/spec/data_mapper/user_oauth_spec.rb +9 -0
- data/spec/data_mapper/user_remember_me_spec.rb +8 -0
- data/spec/data_mapper/user_reset_password_spec.rb +8 -0
- data/spec/data_mapper/user_spec.rb +27 -0
- data/spec/mongo_mapper/user_activation_spec.rb +9 -0
- data/spec/mongo_mapper/user_activity_logging_spec.rb +8 -0
- data/spec/mongo_mapper/user_brute_force_protection_spec.rb +8 -0
- data/spec/mongo_mapper/user_oauth_spec.rb +8 -0
- data/spec/mongo_mapper/user_remember_me_spec.rb +8 -0
- data/spec/mongo_mapper/user_reset_password_spec.rb +8 -0
- data/spec/mongo_mapper/user_spec.rb +37 -0
- data/spec/mongoid/user_activation_spec.rb +9 -0
- data/spec/mongoid/user_activity_logging_spec.rb +8 -0
- data/spec/mongoid/user_brute_force_protection_spec.rb +8 -0
- data/spec/mongoid/user_oauth_spec.rb +8 -0
- data/spec/mongoid/user_remember_me_spec.rb +8 -0
- data/spec/mongoid/user_reset_password_spec.rb +8 -0
- data/spec/mongoid/user_spec.rb +51 -0
- data/spec/orm/active_record.rb +21 -0
- data/spec/orm/data_mapper.rb +48 -0
- data/spec/orm/mongo_mapper.rb +10 -0
- data/spec/orm/mongoid.rb +22 -0
- data/spec/{rails3/app/models → rails_app/app/active_record}/user.rb +1 -2
- data/spec/rails_app/app/active_record/user_provider.rb +3 -0
- data/spec/rails_app/app/controllers/sorcery_controller.rb +285 -0
- data/spec/rails_app/app/data_mapper/authentication.rb +8 -0
- data/spec/rails_app/app/data_mapper/user.rb +7 -0
- data/spec/{rails3_mongo_mapper/app/models → rails_app/app/mongo_mapper}/user.rb +2 -0
- data/spec/{rails3_mongoid/app/models → rails_app/app/mongoid}/user.rb +2 -0
- data/spec/rails_app/app/views/sorcery_mailer/send_unlock_token_email.text.erb +1 -0
- data/spec/{rails3_mongo_mapper → rails_app}/config/application.rb +13 -8
- data/spec/rails_app/config/boot.rb +4 -0
- data/spec/rails_app/config/database.yml +22 -0
- data/spec/{rails3_mongo_mapper → rails_app}/config/environments/test.rb +2 -0
- data/spec/{rails3_mongoid → rails_app}/config/initializers/session_store.rb +4 -0
- data/spec/rails_app/config/routes.rb +51 -0
- data/spec/{rails3_mongo_mapper → rails_app}/config.ru +1 -1
- data/spec/{rails3 → rails_app}/db/migrate/activation/20101224223622_add_activation_to_users.rb +3 -3
- data/spec/{rails3 → rails_app}/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +2 -0
- data/spec/{rails3 → rails_app}/db/migrate/core/20101224223620_create_users.rb +2 -2
- data/spec/rails_app/db/migrate/external/20101224223628_create_authentications_and_user_providers.rb +22 -0
- data/spec/rails_app/log/development.log +1791 -0
- data/spec/shared_examples/user_activation_shared_examples.rb +137 -98
- data/spec/shared_examples/user_activity_logging_shared_examples.rb +86 -13
- data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +140 -21
- data/spec/shared_examples/user_oauth_shared_examples.rb +21 -16
- data/spec/shared_examples/user_remember_me_shared_examples.rb +36 -24
- data/spec/shared_examples/user_reset_password_shared_examples.rb +163 -130
- data/spec/shared_examples/user_shared_examples.rb +370 -195
- data/spec/sorcery_crypto_providers_spec.rb +74 -72
- data/spec/spec_helper.rb +32 -4
- metadata +259 -425
- data/Gemfile.lock +0 -192
- data/README.rdoc +0 -261
- data/VERSION +0 -1
- data/lib/sorcery/controller/submodules/external/protocols/oauth1.rb +0 -35
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +0 -45
- data/lib/sorcery/controller/submodules/external/providers/facebook.rb +0 -97
- data/lib/sorcery/controller/submodules/external/providers/github.rb +0 -91
- data/lib/sorcery/controller/submodules/external/providers/google.rb +0 -90
- data/lib/sorcery/controller/submodules/external/providers/linkedin.rb +0 -101
- data/lib/sorcery/controller/submodules/external/providers/liveid.rb +0 -91
- data/lib/sorcery/controller/submodules/external/providers/twitter.rb +0 -92
- data/lib/sorcery/controller/submodules/external/providers/vk.rb +0 -99
- data/lib/sorcery/model/adapters/active_record.rb +0 -49
- data/lib/sorcery/model/adapters/mongo_mapper.rb +0 -56
- data/lib/sorcery/model/adapters/mongoid.rb +0 -88
- data/lib/sorcery/test_helpers/rails.rb +0 -16
- data/lib/sorcery/test_helpers.rb +0 -5
- data/spec/Gemfile +0 -12
- data/spec/Gemfile.lock +0 -129
- data/spec/README.md +0 -31
- data/spec/Rakefile +0 -12
- data/spec/rails3/.gitignore +0 -4
- data/spec/rails3/.rspec +0 -1
- data/spec/rails3/Gemfile +0 -15
- data/spec/rails3/Gemfile.lock +0 -162
- data/spec/rails3/README +0 -256
- data/spec/rails3/Rakefile +0 -11
- data/spec/rails3/app/controllers/application_controller.rb +0 -208
- data/spec/rails3/app/views/sorcery_mailer/send_unlock_token_email.text.erb +0 -1
- data/spec/rails3/config/application.rb +0 -46
- data/spec/rails3/config/boot.rb +0 -13
- data/spec/rails3/config/database.yml +0 -27
- data/spec/rails3/config/environments/development.rb +0 -26
- data/spec/rails3/config/environments/in_memory.rb +0 -35
- data/spec/rails3/config/environments/production.rb +0 -49
- data/spec/rails3/config/environments/test.rb +0 -35
- data/spec/rails3/config/initializers/session_store.rb +0 -8
- data/spec/rails3/config/routes.rb +0 -59
- data/spec/rails3/config.ru +0 -4
- data/spec/rails3/db/migrate/external/20101224223628_create_authentications.rb +0 -14
- data/spec/rails3/lib/tasks/.gitkeep +0 -0
- data/spec/rails3/public/404.html +0 -26
- data/spec/rails3/public/422.html +0 -26
- data/spec/rails3/public/500.html +0 -26
- data/spec/rails3/public/favicon.ico +0 -0
- data/spec/rails3/public/images/rails.png +0 -0
- data/spec/rails3/public/javascripts/application.js +0 -2
- data/spec/rails3/public/javascripts/controls.js +0 -965
- data/spec/rails3/public/javascripts/dragdrop.js +0 -974
- data/spec/rails3/public/javascripts/effects.js +0 -1123
- data/spec/rails3/public/javascripts/prototype.js +0 -6001
- data/spec/rails3/public/javascripts/rails.js +0 -175
- data/spec/rails3/public/robots.txt +0 -5
- data/spec/rails3/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3/script/rails +0 -6
- data/spec/rails3/spec/controller_activity_logging_spec.rb +0 -115
- data/spec/rails3/spec/controller_brute_force_protection_spec.rb +0 -88
- data/spec/rails3/spec/controller_http_basic_auth_spec.rb +0 -50
- data/spec/rails3/spec/controller_oauth2_spec.rb +0 -380
- data/spec/rails3/spec/controller_oauth_spec.rb +0 -206
- data/spec/rails3/spec/controller_remember_me_spec.rb +0 -96
- data/spec/rails3/spec/controller_session_timeout_spec.rb +0 -55
- data/spec/rails3/spec/controller_spec.rb +0 -177
- data/spec/rails3/spec/integration_spec.rb +0 -23
- data/spec/rails3/spec/spec.opts +0 -2
- data/spec/rails3/spec/spec_helper.orig.rb +0 -27
- data/spec/rails3/spec/spec_helper.rb +0 -71
- data/spec/rails3/spec/user_activation_spec.rb +0 -16
- data/spec/rails3/spec/user_activity_logging_spec.rb +0 -8
- data/spec/rails3/spec/user_spec.rb +0 -36
- data/spec/rails3/vendor/plugins/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/.gitignore +0 -4
- data/spec/rails3_mongo_mapper/.rspec +0 -1
- data/spec/rails3_mongo_mapper/Gemfile +0 -16
- data/spec/rails3_mongo_mapper/Gemfile.lock +0 -156
- data/spec/rails3_mongo_mapper/Rakefile +0 -11
- data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +0 -122
- data/spec/rails3_mongo_mapper/app/helpers/application_helper.rb +0 -2
- data/spec/rails3_mongo_mapper/app/mailers/sorcery_mailer.rb +0 -25
- data/spec/rails3_mongo_mapper/app/views/layouts/application.html.erb +0 -14
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.html.erb +0 -17
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.text.erb +0 -9
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.text.erb +0 -9
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.html.erb +0 -16
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.text.erb +0 -8
- data/spec/rails3_mongo_mapper/config/boot.rb +0 -13
- data/spec/rails3_mongo_mapper/config/environment.rb +0 -5
- data/spec/rails3_mongo_mapper/config/environments/development.rb +0 -30
- data/spec/rails3_mongo_mapper/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongo_mapper/config/environments/production.rb +0 -49
- data/spec/rails3_mongo_mapper/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails3_mongo_mapper/config/initializers/inflections.rb +0 -10
- data/spec/rails3_mongo_mapper/config/initializers/mime_types.rb +0 -5
- data/spec/rails3_mongo_mapper/config/initializers/mongo.rb +0 -2
- data/spec/rails3_mongo_mapper/config/initializers/secret_token.rb +0 -7
- data/spec/rails3_mongo_mapper/config/initializers/session_store.rb +0 -8
- data/spec/rails3_mongo_mapper/config/locales/en.yml +0 -5
- data/spec/rails3_mongo_mapper/config/routes.rb +0 -59
- data/spec/rails3_mongo_mapper/db/schema.rb +0 -23
- data/spec/rails3_mongo_mapper/db/seeds.rb +0 -7
- data/spec/rails3_mongo_mapper/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/public/404.html +0 -26
- data/spec/rails3_mongo_mapper/public/422.html +0 -26
- data/spec/rails3_mongo_mapper/public/500.html +0 -26
- 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 +0 -2
- data/spec/rails3_mongo_mapper/public/javascripts/controls.js +0 -965
- data/spec/rails3_mongo_mapper/public/javascripts/dragdrop.js +0 -974
- data/spec/rails3_mongo_mapper/public/javascripts/effects.js +0 -1123
- data/spec/rails3_mongo_mapper/public/javascripts/prototype.js +0 -6001
- data/spec/rails3_mongo_mapper/public/javascripts/rails.js +0 -175
- data/spec/rails3_mongo_mapper/public/robots.txt +0 -5
- data/spec/rails3_mongo_mapper/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/script/rails +0 -6
- data/spec/rails3_mongo_mapper/spec/controller_spec.rb +0 -170
- data/spec/rails3_mongo_mapper/spec/spec.opts +0 -2
- data/spec/rails3_mongo_mapper/spec/spec_helper.orig.rb +0 -27
- data/spec/rails3_mongo_mapper/spec/spec_helper.rb +0 -55
- data/spec/rails3_mongo_mapper/spec/user_activation_spec.rb +0 -9
- data/spec/rails3_mongo_mapper/spec/user_activity_logging_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_brute_force_protection_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_oauth_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_remember_me_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_reset_password_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_spec.rb +0 -37
- data/spec/rails3_mongo_mapper/vendor/plugins/.gitkeep +0 -0
- data/spec/rails3_mongoid/.gitignore +0 -4
- data/spec/rails3_mongoid/.rspec +0 -1
- data/spec/rails3_mongoid/Gemfile +0 -15
- data/spec/rails3_mongoid/Gemfile.lock +0 -146
- data/spec/rails3_mongoid/Rakefile +0 -11
- data/spec/rails3_mongoid/app/controllers/application_controller.rb +0 -127
- data/spec/rails3_mongoid/app/helpers/application_helper.rb +0 -2
- data/spec/rails3_mongoid/app/mailers/sorcery_mailer.rb +0 -25
- data/spec/rails3_mongoid/app/views/layouts/application.html.erb +0 -14
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.html.erb +0 -17
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.text.erb +0 -9
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.html.erb +0 -17
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.text.erb +0 -9
- data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.html.erb +0 -16
- data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.text.erb +0 -8
- data/spec/rails3_mongoid/config/application.rb +0 -51
- data/spec/rails3_mongoid/config/boot.rb +0 -13
- data/spec/rails3_mongoid/config/environment.rb +0 -5
- data/spec/rails3_mongoid/config/environments/development.rb +0 -26
- data/spec/rails3_mongoid/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongoid/config/environments/production.rb +0 -49
- data/spec/rails3_mongoid/config/environments/test.rb +0 -35
- data/spec/rails3_mongoid/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails3_mongoid/config/initializers/inflections.rb +0 -10
- data/spec/rails3_mongoid/config/initializers/mime_types.rb +0 -5
- data/spec/rails3_mongoid/config/initializers/secret_token.rb +0 -7
- data/spec/rails3_mongoid/config/locales/en.yml +0 -5
- data/spec/rails3_mongoid/config/mongoid.yml +0 -7
- data/spec/rails3_mongoid/config/routes.rb +0 -59
- data/spec/rails3_mongoid/config.ru +0 -4
- data/spec/rails3_mongoid/db/schema.rb +0 -23
- data/spec/rails3_mongoid/db/seeds.rb +0 -7
- data/spec/rails3_mongoid/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongoid/public/404.html +0 -26
- data/spec/rails3_mongoid/public/422.html +0 -26
- data/spec/rails3_mongoid/public/500.html +0 -26
- data/spec/rails3_mongoid/public/favicon.ico +0 -0
- data/spec/rails3_mongoid/public/images/rails.png +0 -0
- data/spec/rails3_mongoid/public/javascripts/application.js +0 -2
- data/spec/rails3_mongoid/public/javascripts/controls.js +0 -965
- data/spec/rails3_mongoid/public/javascripts/dragdrop.js +0 -974
- data/spec/rails3_mongoid/public/javascripts/effects.js +0 -1123
- data/spec/rails3_mongoid/public/javascripts/prototype.js +0 -6001
- data/spec/rails3_mongoid/public/javascripts/rails.js +0 -175
- data/spec/rails3_mongoid/public/robots.txt +0 -5
- data/spec/rails3_mongoid/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongoid/script/rails +0 -6
- data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +0 -105
- data/spec/rails3_mongoid/spec/controller_spec.rb +0 -181
- data/spec/rails3_mongoid/spec/spec.opts +0 -2
- data/spec/rails3_mongoid/spec/spec_helper.orig.rb +0 -27
- data/spec/rails3_mongoid/spec/spec_helper.rb +0 -55
- data/spec/rails3_mongoid/spec/user_activation_spec.rb +0 -9
- data/spec/rails3_mongoid/spec/user_activity_logging_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_brute_force_protection_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_oauth_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_remember_me_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_spec.rb +0 -38
- data/spec/rails3_mongoid/vendor/plugins/.gitkeep +0 -0
- data/spec/shared_examples/controller_oauth2_shared_examples.rb +0 -56
- data/spec/shared_examples/controller_oauth_shared_examples.rb +0 -55
- /data/lib/sorcery/{controller/submodules/external/protocols → protocols}/certs/ca-bundle.crt +0 -0
- /data/spec/{rails3/app/models → rails_app/app/active_record}/authentication.rb +0 -0
- /data/spec/{rails3 → rails_app}/app/helpers/application_helper.rb +0 -0
- /data/spec/{rails3 → rails_app}/app/mailers/sorcery_mailer.rb +0 -0
- /data/spec/{rails3_mongo_mapper/app/models → rails_app/app/mongo_mapper}/authentication.rb +0 -0
- /data/spec/{rails3_mongoid/app/models → rails_app/app/mongoid}/authentication.rb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/application/index.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/layouts/application.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_email.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_email.text.erb +0 -0
- /data/spec/{rails3/app/views/sorcery_mailer/activation_success_email.html.erb → rails_app/app/views/sorcery_mailer/activation_needed_email.html.erb} +0 -0
- /data/spec/{rails3_mongo_mapper → rails_app}/app/views/sorcery_mailer/activation_success_email.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_success_email.text.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/reset_password_email.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/reset_password_email.text.erb +0 -0
- /data/spec/{rails3 → rails_app}/config/environment.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/backtrace_silencers.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/inflections.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/mime_types.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/secret_token.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/locales/en.yml +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/schema.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/seeds.rb +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module Providers
|
|
3
|
+
|
|
4
|
+
# This class adds support for OAuth with heroku.com.
|
|
5
|
+
|
|
6
|
+
# config.heroku.key = <key>
|
|
7
|
+
# config.heroku.secret = <secret>
|
|
8
|
+
# config.heroku.callback_url = "<host>/oauth/callback?provider=heroku"
|
|
9
|
+
# config.heroku.scope = "read"
|
|
10
|
+
# config.heroku.user_info_mapping = {:email => "email", :name => "email" }
|
|
11
|
+
|
|
12
|
+
# NOTE:
|
|
13
|
+
# The full path must be set for OAuth Callback URL when configuring the API Client Information on Heroku.
|
|
14
|
+
|
|
15
|
+
class Heroku < Base
|
|
16
|
+
|
|
17
|
+
include Protocols::Oauth2
|
|
18
|
+
|
|
19
|
+
attr_accessor :auth_path, :scope, :token_url, :user_info_path
|
|
20
|
+
|
|
21
|
+
def initialize
|
|
22
|
+
super
|
|
23
|
+
|
|
24
|
+
@scope = nil
|
|
25
|
+
@site = 'https://id.heroku.com'
|
|
26
|
+
@user_info_path = 'https://api.heroku.com/account'
|
|
27
|
+
@auth_path = '/oauth/authorize'
|
|
28
|
+
@token_url = '/oauth/token'
|
|
29
|
+
@user_info_path = '/account'
|
|
30
|
+
@state = SecureRandom.hex(16)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def get_user_hash(access_token)
|
|
34
|
+
response = access_token.get(user_info_path)
|
|
35
|
+
body = JSON.parse(response.body)
|
|
36
|
+
auth_hash(access_token).tap do |h|
|
|
37
|
+
h[:user_info] = body
|
|
38
|
+
h[:uid] = body['id'].to_s
|
|
39
|
+
h[:email] = body['email'].to_s
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def login_url(params, session)
|
|
44
|
+
authorize_url({ authorize_url: auth_path })
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# tries to login the user from access token
|
|
48
|
+
def process_callback(params, session)
|
|
49
|
+
raise "Invalid state. Potential Cross Site Forgery" if params[:state] != state
|
|
50
|
+
args = { }.tap do |a|
|
|
51
|
+
a[:code] = params[:code] if params[:code]
|
|
52
|
+
end
|
|
53
|
+
get_access_token(args, token_url: token_url, token_method: :post)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module Providers
|
|
3
|
+
# This class adds support for OAuth with Jira
|
|
4
|
+
#
|
|
5
|
+
# config.jira.key = <key>
|
|
6
|
+
# config.jira.secret = <secret>
|
|
7
|
+
# ...
|
|
8
|
+
#
|
|
9
|
+
class Jira < Base
|
|
10
|
+
|
|
11
|
+
include Protocols::Oauth
|
|
12
|
+
|
|
13
|
+
attr_accessor :access_token_path, :authorize_path, :request_token_path,
|
|
14
|
+
:user_info_path, :site, :signature_method, :private_key_file, :callback_url
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def initialize
|
|
18
|
+
@configuration = {
|
|
19
|
+
authorize_path: '/authorize',
|
|
20
|
+
request_token_path: '/request-token',
|
|
21
|
+
access_token_path: '/access-token'
|
|
22
|
+
}
|
|
23
|
+
@user_info_path = '/users/me'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Override included get_consumer method to provide authorize_path
|
|
27
|
+
#read extra configurations
|
|
28
|
+
def get_consumer
|
|
29
|
+
@configuration = @configuration.merge({
|
|
30
|
+
site: site,
|
|
31
|
+
signature_method: signature_method,
|
|
32
|
+
consumer_key: key,
|
|
33
|
+
private_key_file: private_key_file
|
|
34
|
+
})
|
|
35
|
+
::OAuth::Consumer.new(@key, @secret, @configuration)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def get_user_hash(access_token)
|
|
39
|
+
response = access_token.get(user_info_path)
|
|
40
|
+
|
|
41
|
+
auth_hash(access_token).tap do |h|
|
|
42
|
+
h[:user_info] = JSON.parse(response.body)['users'].first
|
|
43
|
+
h[:uid] = user_hash[:user_info]['id'].to_s
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# calculates and returns the url to which the user should be redirected,
|
|
48
|
+
# to get authenticated at the external provider's site.
|
|
49
|
+
def login_url(params, session)
|
|
50
|
+
req_token = get_request_token
|
|
51
|
+
session[:request_token] = req_token.token
|
|
52
|
+
session[:request_token_secret] = req_token.secret
|
|
53
|
+
|
|
54
|
+
#it was like that -> redirect_to authorize_url({ request_token: req_token.token, request_token_secret: req_token.secret })
|
|
55
|
+
#for some reason Jira does not need these parameters
|
|
56
|
+
|
|
57
|
+
get_request_token(
|
|
58
|
+
session[:request_token],
|
|
59
|
+
session[:request_token_secret]
|
|
60
|
+
).authorize_url
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# tries to login the user from access token
|
|
64
|
+
def process_callback(params, session)
|
|
65
|
+
args = {
|
|
66
|
+
oauth_verifier: params[:oauth_verifier],
|
|
67
|
+
request_token: session[:request_token],
|
|
68
|
+
request_token_secret: session[:request_token_secret]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
args.merge!({ code: params[:code] }) if params[:code]
|
|
72
|
+
get_access_token(args)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module Providers
|
|
3
|
+
# This class adds support for OAuth with Linkedin.com.
|
|
4
|
+
#
|
|
5
|
+
# config.linkedin.key = <key>
|
|
6
|
+
# config.linkedin.secret = <secret>
|
|
7
|
+
# ...
|
|
8
|
+
#
|
|
9
|
+
class Linkedin < Base
|
|
10
|
+
|
|
11
|
+
include Protocols::Oauth
|
|
12
|
+
|
|
13
|
+
attr_accessor :authorize_path, :access_permissions, :access_token_path,
|
|
14
|
+
:request_token_path, :user_info_fields, :user_info_path
|
|
15
|
+
|
|
16
|
+
def initialize
|
|
17
|
+
@configuration = {
|
|
18
|
+
site: 'https://api.linkedin.com',
|
|
19
|
+
authorize_path: '/uas/oauth/authenticate',
|
|
20
|
+
request_token_path: '/uas/oauth/requestToken',
|
|
21
|
+
access_token_path: '/uas/oauth/accessToken'
|
|
22
|
+
}
|
|
23
|
+
@user_info_path = '/v1/people/~'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Override included get_consumer method to provide authorize_path
|
|
27
|
+
def get_consumer
|
|
28
|
+
# Add access permissions to request token path
|
|
29
|
+
@configuration[:request_token_path] += '?scope=' + access_permissions.join('+') unless access_permissions.blank? or @configuration[:request_token_path].include? '?scope='
|
|
30
|
+
::OAuth::Consumer.new(@key, @secret, @configuration)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def get_user_hash(access_token)
|
|
34
|
+
fields = self.user_info_fields.join(',')
|
|
35
|
+
response = access_token.get("#{@user_info_path}:(#{fields})", 'x-li-format' => 'json')
|
|
36
|
+
|
|
37
|
+
auth_hash(access_token).tap do |h|
|
|
38
|
+
h[:user_info] = JSON.parse(response.body)
|
|
39
|
+
h[:uid] = h[:user_info]['id'].to_s
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# calculates and returns the url to which the user should be redirected,
|
|
44
|
+
# to get authenticated at the external provider's site.
|
|
45
|
+
def login_url(params, session)
|
|
46
|
+
req_token = get_request_token
|
|
47
|
+
session[:request_token] = req_token.token
|
|
48
|
+
session[:request_token_secret] = req_token.secret
|
|
49
|
+
authorize_url({ request_token: req_token.token, request_token_secret: req_token.secret })
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# tries to login the user from access token
|
|
53
|
+
def process_callback(params, session)
|
|
54
|
+
args = {
|
|
55
|
+
oauth_verifier: params[:oauth_verifier],
|
|
56
|
+
request_token: session[:request_token],
|
|
57
|
+
request_token_secret: session[:request_token_secret]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
args.merge!({ code: params[:code] }) if params[:code]
|
|
61
|
+
get_access_token(args)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module Providers
|
|
3
|
+
# This class adds support for OAuth with microsoft liveid.
|
|
4
|
+
#
|
|
5
|
+
# config.liveid.key = <key>
|
|
6
|
+
# config.liveid.secret = <secret>
|
|
7
|
+
# ...
|
|
8
|
+
#
|
|
9
|
+
class Liveid < Base
|
|
10
|
+
|
|
11
|
+
include Protocols::Oauth2
|
|
12
|
+
|
|
13
|
+
attr_accessor :auth_url, :token_path, :user_info_url, :scope
|
|
14
|
+
|
|
15
|
+
def initialize
|
|
16
|
+
super
|
|
17
|
+
|
|
18
|
+
@site = 'https://oauth.live.com/'
|
|
19
|
+
@auth_url = '/authorize'
|
|
20
|
+
@token_path = '/token'
|
|
21
|
+
@user_info_url = 'https://apis.live.net/v5.0/me'
|
|
22
|
+
@scope = 'wl.basic wl.emails wl.offline_access'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def get_user_hash(access_token)
|
|
26
|
+
access_token.token_param = 'access_token'
|
|
27
|
+
response = access_token.get(user_info_url)
|
|
28
|
+
|
|
29
|
+
auth_hash(access_token).tap do |h|
|
|
30
|
+
h[:user_info] = JSON.parse(response.body)
|
|
31
|
+
h[:uid] = h[:user_info]['id']
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# calculates and returns the url to which the user should be redirected,
|
|
36
|
+
# to get authenticated at the external provider's site.
|
|
37
|
+
def login_url(params, session)
|
|
38
|
+
self.authorize_url({ authorize_url: auth_url })
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# tries to login the user from access token
|
|
42
|
+
def process_callback(params, session)
|
|
43
|
+
args = {}.tap do |a|
|
|
44
|
+
a[:code] = params[:code] if params[:code]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
get_access_token(args, access_token_path: token_path,
|
|
48
|
+
access_token_method: :post)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module Providers
|
|
3
|
+
# This class adds support for OAuth with salesforce.com.
|
|
4
|
+
#
|
|
5
|
+
# config.salesforce.key = <key>
|
|
6
|
+
# config.salesforce.secret = <secret>
|
|
7
|
+
# ...
|
|
8
|
+
#
|
|
9
|
+
class Salesforce < Base
|
|
10
|
+
|
|
11
|
+
include Protocols::Oauth2
|
|
12
|
+
|
|
13
|
+
attr_accessor :auth_url, :token_url, :scope
|
|
14
|
+
|
|
15
|
+
def initialize
|
|
16
|
+
super
|
|
17
|
+
|
|
18
|
+
@site = 'https://login.salesforce.com'
|
|
19
|
+
@auth_url = '/services/oauth2/authorize'
|
|
20
|
+
@token_url = '/services/oauth2/token'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get_user_hash(access_token)
|
|
24
|
+
user_info_url = access_token.params['id']
|
|
25
|
+
response = access_token.get(user_info_url)
|
|
26
|
+
|
|
27
|
+
auth_hash(access_token).tap do |h|
|
|
28
|
+
h[:user_info] = JSON.parse(response.body)
|
|
29
|
+
h[:uid] = h[:user_info]['user_id']
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# calculates and returns the url to which the user should be redirected,
|
|
34
|
+
# to get authenticated at the external provider's site.
|
|
35
|
+
def login_url(params, session)
|
|
36
|
+
authorize_url({ authorize_url: auth_url })
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# tries to login the user from access token
|
|
40
|
+
def process_callback(params, session)
|
|
41
|
+
args = {}.tap do |a|
|
|
42
|
+
a[:code] = params[:code] if params[:code]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
get_access_token(args, token_url: token_url, token_method: :post)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module Providers
|
|
3
|
+
# This class adds support for OAuth with Twitter.com.
|
|
4
|
+
#
|
|
5
|
+
# config.twitter.key = <key>
|
|
6
|
+
# config.twitter.secret = <secret>
|
|
7
|
+
# ...
|
|
8
|
+
#
|
|
9
|
+
class Twitter < Base
|
|
10
|
+
|
|
11
|
+
include Protocols::Oauth
|
|
12
|
+
|
|
13
|
+
attr_accessor :state, :user_info_path
|
|
14
|
+
|
|
15
|
+
def initialize
|
|
16
|
+
super
|
|
17
|
+
|
|
18
|
+
@site = 'https://api.twitter.com'
|
|
19
|
+
@user_info_path = '/1.1/account/verify_credentials.json'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Override included get_consumer method to provide authorize_path
|
|
23
|
+
def get_consumer
|
|
24
|
+
::OAuth::Consumer.new(@key, secret, site: site, authorize_path: '/oauth/authenticate')
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def get_user_hash(access_token)
|
|
28
|
+
response = access_token.get(user_info_path)
|
|
29
|
+
|
|
30
|
+
auth_hash(access_token).tap do |h|
|
|
31
|
+
h[:user_info] = JSON.parse(response.body)
|
|
32
|
+
h[:uid] = h[:user_info]['id'].to_s
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# calculates and returns the url to which the user should be redirected,
|
|
37
|
+
# to get authenticated at the external provider's site.
|
|
38
|
+
def login_url(params, session)
|
|
39
|
+
req_token = self.get_request_token
|
|
40
|
+
session[:request_token] = req_token.token
|
|
41
|
+
session[:request_token_secret] = req_token.secret
|
|
42
|
+
self.authorize_url({ request_token: req_token.token, request_token_secret: req_token.secret })
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# tries to login the user from access token
|
|
46
|
+
def process_callback(params, session)
|
|
47
|
+
args = {
|
|
48
|
+
oauth_verifier: params[:oauth_verifier],
|
|
49
|
+
request_token: session[:request_token],
|
|
50
|
+
request_token_secret: session[:request_token_secret]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
args.merge!({ code: params[:code] }) if params[:code]
|
|
54
|
+
get_access_token(args)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module Providers
|
|
3
|
+
# This class adds support for OAuth with vk.com.
|
|
4
|
+
#
|
|
5
|
+
# config.vk.key = <key>
|
|
6
|
+
# config.vk.secret = <secret>
|
|
7
|
+
# ...
|
|
8
|
+
#
|
|
9
|
+
class Vk < Base
|
|
10
|
+
|
|
11
|
+
include Protocols::Oauth2
|
|
12
|
+
|
|
13
|
+
attr_accessor :auth_path, :token_path, :user_info_url, :scope
|
|
14
|
+
|
|
15
|
+
def initialize
|
|
16
|
+
super
|
|
17
|
+
|
|
18
|
+
@site = 'https://oauth.vk.com/'
|
|
19
|
+
@user_info_url = 'https://api.vk.com/method/getProfiles'
|
|
20
|
+
@auth_path = '/authorize'
|
|
21
|
+
@token_path = '/access_token'
|
|
22
|
+
@scope = 'email'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def get_user_hash(access_token)
|
|
26
|
+
user_hash = auth_hash(access_token)
|
|
27
|
+
|
|
28
|
+
params = {
|
|
29
|
+
access_token: access_token.token,
|
|
30
|
+
uids: access_token.params['user_id'],
|
|
31
|
+
fields: user_info_mapping.values.join(','),
|
|
32
|
+
scope: scope
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
response = access_token.get(user_info_url, params: params)
|
|
36
|
+
if user_hash[:user_info] = JSON.parse(response.body)
|
|
37
|
+
user_hash[:user_info] = user_hash[:user_info]['response'][0]
|
|
38
|
+
user_hash[:user_info]['full_name'] = [user_hash[:user_info]['first_name'], user_hash[:user_info]['last_name']].join(' ')
|
|
39
|
+
|
|
40
|
+
user_hash[:uid] = user_hash[:user_info]['uid']
|
|
41
|
+
user_hash[:user_info]['email'] = access_token.params['email']
|
|
42
|
+
end
|
|
43
|
+
user_hash
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# calculates and returns the url to which the user should be redirected,
|
|
47
|
+
# to get authenticated at the external provider's site.
|
|
48
|
+
def login_url(params, session)
|
|
49
|
+
self.authorize_url({ authorize_url: auth_path })
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# tries to login the user from access token
|
|
53
|
+
def process_callback(params, session)
|
|
54
|
+
args = {}.tap do |a|
|
|
55
|
+
a[:code] = params[:code] if params[:code]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
get_access_token(args, token_url: token_path, token_method: :post)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module Providers
|
|
3
|
+
# This class adds support for OAuth with xing.com.
|
|
4
|
+
#
|
|
5
|
+
# config.xing.key = <key>
|
|
6
|
+
# config.xing.secret = <secret>
|
|
7
|
+
# ...
|
|
8
|
+
#
|
|
9
|
+
class Xing < Base
|
|
10
|
+
|
|
11
|
+
include Protocols::Oauth
|
|
12
|
+
|
|
13
|
+
attr_accessor :access_token_path, :authorize_path, :request_token_path,
|
|
14
|
+
:user_info_path
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def initialize
|
|
18
|
+
@configuration = {
|
|
19
|
+
site: 'https://api.xing.com/v1',
|
|
20
|
+
authorize_path: '/authorize',
|
|
21
|
+
request_token_path: '/request_token',
|
|
22
|
+
access_token_path: '/access_token'
|
|
23
|
+
}
|
|
24
|
+
@user_info_path = '/users/me'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Override included get_consumer method to provide authorize_path
|
|
28
|
+
def get_consumer
|
|
29
|
+
::OAuth::Consumer.new(@key, @secret, @configuration)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def get_user_hash(access_token)
|
|
33
|
+
response = access_token.get(user_info_path)
|
|
34
|
+
|
|
35
|
+
auth_hash(access_token).tap do |h|
|
|
36
|
+
h[:user_info] = JSON.parse(response.body)['users'].first
|
|
37
|
+
h[:uid] = h[:user_info]['id'].to_s
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# calculates and returns the url to which the user should be redirected,
|
|
42
|
+
# to get authenticated at the external provider's site.
|
|
43
|
+
def login_url(params, session)
|
|
44
|
+
req_token = get_request_token
|
|
45
|
+
session[:request_token] = req_token.token
|
|
46
|
+
session[:request_token_secret] = req_token.secret
|
|
47
|
+
authorize_url({ request_token: req_token.token, request_token_secret: req_token.secret })
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# tries to login the user from access token
|
|
51
|
+
def process_callback(params, session)
|
|
52
|
+
args = {
|
|
53
|
+
oauth_verifier: params[:oauth_verifier],
|
|
54
|
+
request_token: session[:request_token],
|
|
55
|
+
request_token_secret: session[:request_token_secret]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
args.merge!({ code: params[:code] }) if params[:code]
|
|
59
|
+
get_access_token(args)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
require 'fileutils'
|
|
2
|
-
|
|
3
1
|
namespace :sorcery do
|
|
4
2
|
desc "Adds sorcery's initializer file"
|
|
5
3
|
task :bootstrap do
|
|
6
4
|
warn "This task is obsolete.\nUse \"rails g sorcery:install\" now.\nSee README for more information."
|
|
7
|
-
|
|
8
|
-
src = File.join(File.dirname(__FILE__), '..', 'initializers', 'initializer.rb')
|
|
9
|
-
target = File.join(Rails.root, "config", "initializers", "sorcery.rb")
|
|
10
|
-
FileUtils.cp(src, target)
|
|
11
5
|
end
|
|
12
|
-
end
|
|
6
|
+
end
|
|
@@ -2,17 +2,17 @@ module Sorcery
|
|
|
2
2
|
module TestHelpers
|
|
3
3
|
module Internal
|
|
4
4
|
module Rails
|
|
5
|
-
include ::Sorcery::TestHelpers::Rails
|
|
5
|
+
include ::Sorcery::TestHelpers::Rails::Controller
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
:register_last_activity_time_to_db,
|
|
9
|
-
:deny_banned_user,
|
|
7
|
+
SUBMODULES_AUTO_ADDED_CONTROLLER_FILTERS = [
|
|
8
|
+
:register_last_activity_time_to_db,
|
|
9
|
+
:deny_banned_user,
|
|
10
10
|
:validate_session
|
|
11
11
|
]
|
|
12
12
|
|
|
13
13
|
def sorcery_reload!(submodules = [], options = {})
|
|
14
14
|
reload_user_class
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
# return to no-module configuration
|
|
17
17
|
::Sorcery::Controller::Config.init!
|
|
18
18
|
::Sorcery::Controller::Config.reset!
|
|
@@ -20,7 +20,13 @@ module Sorcery
|
|
|
20
20
|
# remove all plugin before_filters so they won't fail other tests.
|
|
21
21
|
# I don't like this way, but I didn't find another.
|
|
22
22
|
# hopefully it won't break until Rails 4.
|
|
23
|
-
|
|
23
|
+
chain = if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("4.1.0")
|
|
24
|
+
SorceryController._process_action_callbacks.send :chain
|
|
25
|
+
else
|
|
26
|
+
SorceryController._process_action_callbacks
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
chain.delete_if {|c| SUBMODULES_AUTO_ADDED_CONTROLLER_FILTERS.include?(c.filter) }
|
|
24
30
|
|
|
25
31
|
# configure
|
|
26
32
|
::Sorcery::Controller::Config.submodules = submodules
|
|
@@ -34,6 +40,11 @@ module Sorcery
|
|
|
34
40
|
end
|
|
35
41
|
end
|
|
36
42
|
User.authenticates_with_sorcery!
|
|
43
|
+
if defined?(DataMapper) and User.ancestors.include?(DataMapper::Resource)
|
|
44
|
+
DataMapper.auto_migrate!
|
|
45
|
+
User.finalize
|
|
46
|
+
Authentication.finalize
|
|
47
|
+
end
|
|
37
48
|
end
|
|
38
49
|
|
|
39
50
|
def sorcery_controller_property_set(property, value)
|
|
@@ -15,7 +15,7 @@ module Sorcery
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
# a patch to fix a bug in testing that happens when you 'destroy' a session twice.
|
|
18
|
-
# After the first destroy, the session is an ordinary hash, and then when destroy
|
|
18
|
+
# After the first destroy, the session is an ordinary hash, and then when destroy
|
|
19
19
|
# is called again there's an exception.
|
|
20
20
|
class ::Hash
|
|
21
21
|
def destroy
|
|
@@ -23,35 +23,56 @@ module Sorcery
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def
|
|
26
|
+
def build_new_user(attributes_hash = nil)
|
|
27
27
|
user_attributes_hash = attributes_hash || {:username => 'gizmo', :email => "bla@bla.com", :password => 'secret'}
|
|
28
28
|
@user = User.new(user_attributes_hash)
|
|
29
|
-
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def create_new_user(attributes_hash = nil)
|
|
32
|
+
@user = build_new_user(attributes_hash)
|
|
33
|
+
@user.sorcery_adapter.save(:raise_on_failure => true)
|
|
30
34
|
@user
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
def create_new_external_user(provider, attributes_hash = nil)
|
|
34
38
|
user_attributes_hash = attributes_hash || {:username => 'gizmo'}
|
|
35
39
|
@user = User.new(user_attributes_hash)
|
|
36
|
-
@user.save
|
|
40
|
+
@user.sorcery_adapter.save(:raise_on_failure => true)
|
|
37
41
|
@user.authentications.create!({:provider => provider, :uid => 123})
|
|
38
42
|
@user
|
|
39
43
|
end
|
|
40
44
|
|
|
45
|
+
def custom_create_new_external_user(provider, authentication_class, attributes_hash = nil)
|
|
46
|
+
authentication_association = authentication_class.name.underscore.pluralize
|
|
47
|
+
|
|
48
|
+
user_attributes_hash = attributes_hash || {:username => 'gizmo'}
|
|
49
|
+
@user = User.new(user_attributes_hash)
|
|
50
|
+
@user.sorcery_adapter.save(:raise_on_failure => true)
|
|
51
|
+
@user.send(authentication_association).create!({:provider => provider, :uid => 123})
|
|
52
|
+
@user
|
|
53
|
+
end
|
|
54
|
+
|
|
41
55
|
def sorcery_model_property_set(property, *values)
|
|
42
56
|
User.class_eval do
|
|
43
57
|
sorcery_config.send(:"#{property}=", *values)
|
|
44
58
|
end
|
|
45
59
|
end
|
|
46
60
|
|
|
61
|
+
def update_model(&block)
|
|
62
|
+
User.class_exec(&block)
|
|
63
|
+
end
|
|
64
|
+
|
|
47
65
|
private
|
|
48
66
|
|
|
49
67
|
# reload user class between specs
|
|
50
68
|
# so it will be possible to test the different submodules in isolation
|
|
51
69
|
def reload_user_class
|
|
52
|
-
Object.send(:remove_const
|
|
70
|
+
Object.send(:remove_const, "User")
|
|
53
71
|
load 'user.rb'
|
|
72
|
+
if User.respond_to?(:reset_column_information)
|
|
73
|
+
User.reset_column_information
|
|
74
|
+
end
|
|
54
75
|
end
|
|
55
76
|
end
|
|
56
77
|
end
|
|
57
|
-
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module TestHelpers
|
|
3
|
+
module Rails
|
|
4
|
+
module Controller
|
|
5
|
+
def login_user(user = nil, test_context = {})
|
|
6
|
+
user ||= @user
|
|
7
|
+
@controller.send(:auto_login, user)
|
|
8
|
+
@controller.send(:after_login!, user, [user.send(user.sorcery_config.username_attribute_names.first), 'secret'])
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def logout_user
|
|
12
|
+
@controller.send(:logout)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def logged_in?
|
|
16
|
+
@controller.send(:logged_in?)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Sorcery
|
|
2
|
+
module TestHelpers
|
|
3
|
+
module Rails
|
|
4
|
+
module Integration
|
|
5
|
+
|
|
6
|
+
#Accepts arguments for user to login, route to use and HTTP method
|
|
7
|
+
#Defaults - @user, 'sessions_url' and POST
|
|
8
|
+
def login_user(user = nil, route = nil, http_method = :post)
|
|
9
|
+
user ||= @user
|
|
10
|
+
route ||= sessions_url
|
|
11
|
+
|
|
12
|
+
username_attr = user.sorcery_config.username_attribute_names.first
|
|
13
|
+
username = user.send(username_attr)
|
|
14
|
+
page.driver.send(http_method, route, { :"#{username_attr}" => username, :password => 'secret' })
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#Accepts route and HTTP method arguments
|
|
18
|
+
#Default - 'logout_url' and GET
|
|
19
|
+
def logout_user(route = nil, http_method = :get)
|
|
20
|
+
route ||= logout_url
|
|
21
|
+
page.driver.send(http_method, route)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|