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
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
module Sorcery
|
|
2
|
-
module Controller
|
|
3
|
-
module Submodules
|
|
4
|
-
module External
|
|
5
|
-
module Providers
|
|
6
|
-
# This module adds support for OAuth with github.com.
|
|
7
|
-
# When included in the 'config.providers' option, it adds a new option, 'config.github'.
|
|
8
|
-
# Via this new option you can configure Github specific settings like your app's key and secret.
|
|
9
|
-
#
|
|
10
|
-
# config.github.key = <key>
|
|
11
|
-
# config.github.secret = <secret>
|
|
12
|
-
# ...
|
|
13
|
-
#
|
|
14
|
-
module Github
|
|
15
|
-
def self.included(base)
|
|
16
|
-
base.module_eval do
|
|
17
|
-
class << self
|
|
18
|
-
attr_reader :github # access to github_client.
|
|
19
|
-
|
|
20
|
-
def merge_github_defaults!
|
|
21
|
-
@defaults.merge!(:@github => GithubClient)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
merge_github_defaults!
|
|
25
|
-
update!
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
module GithubClient
|
|
30
|
-
class << self
|
|
31
|
-
attr_accessor :key,
|
|
32
|
-
:secret,
|
|
33
|
-
:callback_url,
|
|
34
|
-
:auth_path,
|
|
35
|
-
:token_path,
|
|
36
|
-
:site,
|
|
37
|
-
:scope,
|
|
38
|
-
:user_info_path,
|
|
39
|
-
:user_info_mapping
|
|
40
|
-
attr_reader :access_token
|
|
41
|
-
|
|
42
|
-
include Protocols::Oauth2
|
|
43
|
-
|
|
44
|
-
def init
|
|
45
|
-
@site = "https://github.com/"
|
|
46
|
-
@user_info_path = "https://api.github.com/user"
|
|
47
|
-
@scope = nil
|
|
48
|
-
@auth_path = "/login/oauth/authorize"
|
|
49
|
-
@token_path = "/login/oauth/access_token"
|
|
50
|
-
@user_info_mapping = {}
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def get_user_hash
|
|
54
|
-
user_hash = {}
|
|
55
|
-
response = @access_token.get(@user_info_path)
|
|
56
|
-
user_hash[:user_info] = JSON.parse(response.body)
|
|
57
|
-
user_hash[:uid] = user_hash[:user_info]['id']
|
|
58
|
-
user_hash
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def has_callback?
|
|
62
|
-
true
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# calculates and returns the url to which the user should be redirected,
|
|
66
|
-
# to get authenticated at the external provider's site.
|
|
67
|
-
def login_url(params,session)
|
|
68
|
-
self.authorize_url({:authorize_url => @auth_path})
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# tries to login the user from access token
|
|
72
|
-
def process_callback(params,session)
|
|
73
|
-
args = {}
|
|
74
|
-
args.merge!({:code => params[:code]}) if params[:code]
|
|
75
|
-
options = {
|
|
76
|
-
:token_url => @token_path,
|
|
77
|
-
:token_method => :post
|
|
78
|
-
}
|
|
79
|
-
@access_token = self.get_access_token(args, options)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
end
|
|
83
|
-
init
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
module Sorcery
|
|
2
|
-
module Controller
|
|
3
|
-
module Submodules
|
|
4
|
-
module External
|
|
5
|
-
module Providers
|
|
6
|
-
# This module adds support for OAuth with google.com.
|
|
7
|
-
# When included in the 'config.providers' option, it adds a new option, 'config.google'.
|
|
8
|
-
# Via this new option you can configure Google specific settings like your app's key and secret.
|
|
9
|
-
#
|
|
10
|
-
# config.google.key = <key>
|
|
11
|
-
# config.google.secret = <secret>
|
|
12
|
-
# ...
|
|
13
|
-
#
|
|
14
|
-
module Google
|
|
15
|
-
def self.included(base)
|
|
16
|
-
base.module_eval do
|
|
17
|
-
class << self
|
|
18
|
-
attr_reader :google # access to google_client.
|
|
19
|
-
|
|
20
|
-
def merge_google_defaults!
|
|
21
|
-
@defaults.merge!(:@google => GoogleClient)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
merge_google_defaults!
|
|
25
|
-
update!
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
module GoogleClient
|
|
30
|
-
class << self
|
|
31
|
-
attr_accessor :key,
|
|
32
|
-
:secret,
|
|
33
|
-
:callback_url,
|
|
34
|
-
:site,
|
|
35
|
-
:auth_url,
|
|
36
|
-
:token_path,
|
|
37
|
-
:user_info_url,
|
|
38
|
-
:scope,
|
|
39
|
-
:user_info_mapping
|
|
40
|
-
attr_reader :access_token
|
|
41
|
-
|
|
42
|
-
include Protocols::Oauth2
|
|
43
|
-
|
|
44
|
-
def init
|
|
45
|
-
@site = "https://accounts.google.com"
|
|
46
|
-
@auth_url = "/o/oauth2/auth"
|
|
47
|
-
@token_url = "/o/oauth2/token"
|
|
48
|
-
@user_info_url = "https://www.googleapis.com/oauth2/v1/userinfo"
|
|
49
|
-
@scope = "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
|
|
50
|
-
@user_info_mapping = {}
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def get_user_hash
|
|
54
|
-
user_hash = {}
|
|
55
|
-
response = @access_token.get(@user_info_url)
|
|
56
|
-
user_hash[:user_info] = JSON.parse(response.body)
|
|
57
|
-
user_hash[:uid] = user_hash[:user_info]['id']
|
|
58
|
-
user_hash
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def has_callback?
|
|
62
|
-
true
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# calculates and returns the url to which the user should be redirected,
|
|
66
|
-
# to get authenticated at the external provider's site.
|
|
67
|
-
def login_url(params,session)
|
|
68
|
-
self.authorize_url({:authorize_url => @auth_url})
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# tries to login the user from access token
|
|
72
|
-
def process_callback(params,session)
|
|
73
|
-
args = {}
|
|
74
|
-
args.merge!({:code => params[:code]}) if params[:code]
|
|
75
|
-
options = {
|
|
76
|
-
:token_url => @token_url,
|
|
77
|
-
:token_method => :post
|
|
78
|
-
}
|
|
79
|
-
@access_token = self.get_access_token(args, options)
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
init
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
module Sorcery
|
|
2
|
-
module Controller
|
|
3
|
-
module Submodules
|
|
4
|
-
module External
|
|
5
|
-
module Providers
|
|
6
|
-
# This module adds support for OAuth with Linkedin.com.
|
|
7
|
-
# When included in the 'config.providers' option, it adds a new option, 'config.linkedin'.
|
|
8
|
-
# Via this new option you can configure Linkedin specific settings like your app's key and secret.
|
|
9
|
-
#
|
|
10
|
-
# config.linkedin.key = <key>
|
|
11
|
-
# config.linkedin.secret = <secret>
|
|
12
|
-
# ...
|
|
13
|
-
#
|
|
14
|
-
module Linkedin
|
|
15
|
-
def self.included(base)
|
|
16
|
-
base.module_eval do
|
|
17
|
-
class << self
|
|
18
|
-
attr_reader :linkedin
|
|
19
|
-
|
|
20
|
-
def merge_linkedin_defaults!
|
|
21
|
-
@defaults.merge!(:@linkedin => LinkedinClient)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
merge_linkedin_defaults!
|
|
25
|
-
update!
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
module LinkedinClient
|
|
30
|
-
class << self
|
|
31
|
-
attr_accessor :key,
|
|
32
|
-
:secret,
|
|
33
|
-
:callback_url,
|
|
34
|
-
:site,
|
|
35
|
-
:authorize_path,
|
|
36
|
-
:request_token_path,
|
|
37
|
-
:access_token_path,
|
|
38
|
-
:user_info_path,
|
|
39
|
-
:user_info_mapping,
|
|
40
|
-
:user_info_fields,
|
|
41
|
-
:access_permissions
|
|
42
|
-
attr_reader :access_token
|
|
43
|
-
|
|
44
|
-
include Protocols::Oauth1
|
|
45
|
-
|
|
46
|
-
# Override included get_consumer method to provide authorize_path
|
|
47
|
-
def get_consumer
|
|
48
|
-
# Add access permissions to request token path
|
|
49
|
-
@configuration[:request_token_path] += "?scope=" + self.access_permissions.join('+') unless self.access_permissions.blank? or @configuration[:request_token_path].include? "?scope="
|
|
50
|
-
::OAuth::Consumer.new(@key, @secret, @configuration)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def init
|
|
54
|
-
@configuration = {
|
|
55
|
-
site: "https://api.linkedin.com",
|
|
56
|
-
authorize_path: '/uas/oauth/authenticate',
|
|
57
|
-
request_token_path: '/uas/oauth/requestToken',
|
|
58
|
-
access_token_path: '/uas/oauth/accessToken'
|
|
59
|
-
}
|
|
60
|
-
@user_info_path = "/v1/people/~"
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def get_user_hash
|
|
64
|
-
user_hash = {}
|
|
65
|
-
fields = self.user_info_fields.join(',')
|
|
66
|
-
response = @access_token.get("#{@user_info_path}:(#{fields})", 'x-li-format' => 'json')
|
|
67
|
-
user_hash[:user_info] = JSON.parse(response.body)
|
|
68
|
-
user_hash[:uid] = user_hash[:user_info]['id'].to_s
|
|
69
|
-
user_hash
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def has_callback?
|
|
73
|
-
true
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# calculates and returns the url to which the user should be redirected,
|
|
77
|
-
# to get authenticated at the external provider's site.
|
|
78
|
-
def login_url(params,session)
|
|
79
|
-
req_token = self.get_request_token
|
|
80
|
-
session[:request_token] = req_token.token
|
|
81
|
-
session[:request_token_secret] = req_token.secret
|
|
82
|
-
self.authorize_url({:request_token => req_token.token, :request_token_secret => req_token.secret})
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# tries to login the user from access token
|
|
86
|
-
def process_callback(params,session)
|
|
87
|
-
args = {}
|
|
88
|
-
args.merge!({:oauth_verifier => params[:oauth_verifier], :request_token => session[:request_token], :request_token_secret => session[:request_token_secret]})
|
|
89
|
-
args.merge!({:code => params[:code]}) if params[:code]
|
|
90
|
-
@access_token = self.get_access_token(args)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
end
|
|
94
|
-
init
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
module Sorcery
|
|
2
|
-
module Controller
|
|
3
|
-
module Submodules
|
|
4
|
-
module External
|
|
5
|
-
module Providers
|
|
6
|
-
# This module adds support for OAuth with microsoft liveid
|
|
7
|
-
# When included in the 'config.providers' option, it adds a new option, 'config.liveid'.
|
|
8
|
-
# Via this new option you can configure LiveId specific settings like your app's key and secret.
|
|
9
|
-
#
|
|
10
|
-
# config.liveid.key = <key>
|
|
11
|
-
# config.liveid.secret = <secret>
|
|
12
|
-
# ...
|
|
13
|
-
#
|
|
14
|
-
module Liveid
|
|
15
|
-
def self.included(base)
|
|
16
|
-
base.module_eval do
|
|
17
|
-
class << self
|
|
18
|
-
attr_reader :liveid # access to liveid_client.
|
|
19
|
-
|
|
20
|
-
def merge_liveid_defaults!
|
|
21
|
-
@defaults.merge!(:@liveid => LiveidClient)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
merge_liveid_defaults!
|
|
25
|
-
update!
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
module LiveidClient
|
|
30
|
-
class << self
|
|
31
|
-
attr_accessor :key,
|
|
32
|
-
:secret,
|
|
33
|
-
:callback_url,
|
|
34
|
-
:site,
|
|
35
|
-
:auth_url,
|
|
36
|
-
:token_path,
|
|
37
|
-
:user_info_url,
|
|
38
|
-
:scope,
|
|
39
|
-
:user_info_mapping
|
|
40
|
-
attr_reader :access_token
|
|
41
|
-
|
|
42
|
-
include Protocols::Oauth2
|
|
43
|
-
|
|
44
|
-
def init
|
|
45
|
-
@site = "https://oauth.live.com/"
|
|
46
|
-
@auth_url = "/authorize"
|
|
47
|
-
@token_path = "/token"
|
|
48
|
-
@user_info_url = "https://apis.live.net/v5.0/me"
|
|
49
|
-
@scope = "wl.basic wl.emails wl.offline_access"
|
|
50
|
-
@user_info_mapping = {}
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def get_user_hash
|
|
54
|
-
user_hash = {}
|
|
55
|
-
@access_token.token_param = "access_token"
|
|
56
|
-
response = @access_token.get(@user_info_url)
|
|
57
|
-
user_hash[:user_info] = JSON.parse(response.body)
|
|
58
|
-
user_hash[:uid] = user_hash[:user_info]['id']
|
|
59
|
-
user_hash
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def has_callback?
|
|
63
|
-
true
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# calculates and returns the url to which the user should be redirected,
|
|
67
|
-
# to get authenticated at the external provider's site.
|
|
68
|
-
def login_url(params,session)
|
|
69
|
-
self.authorize_url({:authorize_url => @auth_url})
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# tries to login the user from access token
|
|
73
|
-
def process_callback(params,session)
|
|
74
|
-
args = {}
|
|
75
|
-
args.merge!({:code => params[:code]}) if params[:code]
|
|
76
|
-
options = {
|
|
77
|
-
:access_token_path => @token_path,
|
|
78
|
-
:access_token_method => :post
|
|
79
|
-
}
|
|
80
|
-
@access_token = self.get_access_token(args, options)
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
init
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
module Sorcery
|
|
2
|
-
module Controller
|
|
3
|
-
module Submodules
|
|
4
|
-
module External
|
|
5
|
-
module Providers
|
|
6
|
-
# This module adds support for OAuth with Twitter.com.
|
|
7
|
-
# When included in the 'config.providers' option, it adds a new option, 'config.twitter'.
|
|
8
|
-
# Via this new option you can configure Twitter specific settings like your app's key and secret.
|
|
9
|
-
#
|
|
10
|
-
# config.twitter.key = <key>
|
|
11
|
-
# config.twitter.secret = <secret>
|
|
12
|
-
# ...
|
|
13
|
-
#
|
|
14
|
-
module Twitter
|
|
15
|
-
def self.included(base)
|
|
16
|
-
base.module_eval do
|
|
17
|
-
class << self
|
|
18
|
-
attr_reader :twitter
|
|
19
|
-
# def twitter(&blk) # allows block syntax.
|
|
20
|
-
# yield @twitter
|
|
21
|
-
# end
|
|
22
|
-
|
|
23
|
-
def merge_twitter_defaults!
|
|
24
|
-
@defaults.merge!(:@twitter => TwitterClient)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
merge_twitter_defaults!
|
|
28
|
-
update!
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
module TwitterClient
|
|
33
|
-
class << self
|
|
34
|
-
attr_accessor :key,
|
|
35
|
-
:secret,
|
|
36
|
-
:callback_url,
|
|
37
|
-
:site,
|
|
38
|
-
:user_info_path,
|
|
39
|
-
:user_info_mapping
|
|
40
|
-
attr_reader :access_token
|
|
41
|
-
|
|
42
|
-
include Protocols::Oauth1
|
|
43
|
-
|
|
44
|
-
# Override included get_consumer method to provide authorize_path
|
|
45
|
-
def get_consumer
|
|
46
|
-
::OAuth::Consumer.new(@key, @secret, :site => @site, :authorize_path => "/oauth/authenticate")
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def init
|
|
50
|
-
@site = "https://api.twitter.com"
|
|
51
|
-
@user_info_path = "/1/account/verify_credentials.json"
|
|
52
|
-
@user_info_mapping = {}
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def get_user_hash
|
|
56
|
-
user_hash = {}
|
|
57
|
-
response = @access_token.get(@user_info_path)
|
|
58
|
-
user_hash[:user_info] = JSON.parse(response.body)
|
|
59
|
-
user_hash[:uid] = user_hash[:user_info]['id'].to_s
|
|
60
|
-
user_hash
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def has_callback?
|
|
64
|
-
true
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# calculates and returns the url to which the user should be redirected,
|
|
68
|
-
# to get authenticated at the external provider's site.
|
|
69
|
-
def login_url(params,session)
|
|
70
|
-
req_token = self.get_request_token
|
|
71
|
-
session[:request_token] = req_token.token
|
|
72
|
-
session[:request_token_secret] = req_token.secret
|
|
73
|
-
self.authorize_url({:request_token => req_token.token, :request_token_secret => req_token.secret})
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# tries to login the user from access token
|
|
77
|
-
def process_callback(params,session)
|
|
78
|
-
args = {}
|
|
79
|
-
args.merge!({:oauth_verifier => params[:oauth_verifier], :request_token => session[:request_token], :request_token_secret => session[:request_token_secret]})
|
|
80
|
-
args.merge!({:code => params[:code]}) if params[:code]
|
|
81
|
-
@access_token = self.get_access_token(args)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
end
|
|
85
|
-
init
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
module Sorcery
|
|
2
|
-
module Controller
|
|
3
|
-
module Submodules
|
|
4
|
-
module External
|
|
5
|
-
module Providers
|
|
6
|
-
# This module adds support for OAuth with vk.com.
|
|
7
|
-
# When included in the 'config.providers' option, it adds a new option, 'config.vk'.
|
|
8
|
-
# Via this new option you can configure Vk specific settings like your app's key and secret.
|
|
9
|
-
#
|
|
10
|
-
# config.vk.key = <key>
|
|
11
|
-
# config.vk.secret = <secret>
|
|
12
|
-
# ...
|
|
13
|
-
#
|
|
14
|
-
module Vk
|
|
15
|
-
def self.included(base)
|
|
16
|
-
base.module_eval do
|
|
17
|
-
class << self
|
|
18
|
-
attr_reader :vk # access to vk_client.
|
|
19
|
-
|
|
20
|
-
def merge_vk_defaults!
|
|
21
|
-
@defaults.merge!(:@vk => VkClient)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
merge_vk_defaults!
|
|
25
|
-
update!
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
module VkClient
|
|
30
|
-
class << self
|
|
31
|
-
attr_accessor :key,
|
|
32
|
-
:secret,
|
|
33
|
-
:callback_url,
|
|
34
|
-
:auth_path,
|
|
35
|
-
:token_path,
|
|
36
|
-
:site,
|
|
37
|
-
:user_info_mapping
|
|
38
|
-
attr_reader :access_token
|
|
39
|
-
|
|
40
|
-
include Protocols::Oauth2
|
|
41
|
-
|
|
42
|
-
def init
|
|
43
|
-
@site = "https://oauth.vk.com/"
|
|
44
|
-
@user_info_url = "https://api.vk.com/method/getProfiles"
|
|
45
|
-
@auth_path = "/authorize"
|
|
46
|
-
@token_path = "/access_token"
|
|
47
|
-
@user_info_mapping = {}
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def get_user_hash
|
|
51
|
-
user_hash = {}
|
|
52
|
-
|
|
53
|
-
params = {
|
|
54
|
-
:access_token => @access_token.token,
|
|
55
|
-
:uids => @access_token.params["user_id"],
|
|
56
|
-
:fields => @user_info_mapping.values.join(",")
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
response = @access_token.get(@user_info_url, :params => params)
|
|
60
|
-
if user_hash[:user_info] = JSON.parse(response.body)
|
|
61
|
-
user_hash[:user_info] = user_hash[:user_info]["response"][0]
|
|
62
|
-
# add full_name - useful if you do not store it in separate fields
|
|
63
|
-
user_hash[:user_info]["full_name"] = [user_hash[:user_info]["first_name"], user_hash[:user_info]["last_name"]].join(" ")
|
|
64
|
-
user_hash[:uid] = user_hash[:user_info]["uid"]
|
|
65
|
-
end
|
|
66
|
-
user_hash
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def has_callback?
|
|
70
|
-
true
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
# calculates and returns the url to which the user should be redirected,
|
|
74
|
-
# to get authenticated at the external provider's site.
|
|
75
|
-
def login_url(params,session)
|
|
76
|
-
self.authorize_url({:authorize_url => @auth_path})
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# tries to login the user from access token
|
|
80
|
-
def process_callback(params,session)
|
|
81
|
-
args = {}
|
|
82
|
-
args.merge!({:code => params[:code]}) if params[:code]
|
|
83
|
-
options = {
|
|
84
|
-
:token_url => @token_path,
|
|
85
|
-
:token_method => :post
|
|
86
|
-
}
|
|
87
|
-
@access_token = self.get_access_token(args, options)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
end
|
|
91
|
-
init
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
module Sorcery
|
|
2
|
-
module Model
|
|
3
|
-
module Adapters
|
|
4
|
-
module ActiveRecord
|
|
5
|
-
def self.included(klass)
|
|
6
|
-
klass.extend ClassMethods
|
|
7
|
-
klass.send(:include, InstanceMethods)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
module InstanceMethods
|
|
11
|
-
def update_many_attributes(attrs)
|
|
12
|
-
attrs.each do |name, value|
|
|
13
|
-
self.send(:"#{name}=", value)
|
|
14
|
-
end
|
|
15
|
-
primary_key = self.class.primary_key
|
|
16
|
-
self.class.where(:"#{primary_key}" => self.send(:"#{primary_key}")).update_all(attrs)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def update_single_attribute(name, value)
|
|
20
|
-
update_many_attributes(name => value)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
module ClassMethods
|
|
25
|
-
def column_name(attribute)
|
|
26
|
-
return "LOWER(#{attribute})" if (@sorcery_config.downcase_username_before_authenticating)
|
|
27
|
-
return "#{attribute}"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def find_by_credentials(credentials)
|
|
31
|
-
sql = @sorcery_config.username_attribute_names.map{|attribute| column_name(attribute) + " = :login"}
|
|
32
|
-
where(sql.join(' OR '), :login => credentials[0]).first
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def find_by_sorcery_token(token_attr_name, token)
|
|
36
|
-
where("#{token_attr_name} = ?", token).first
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def get_current_users
|
|
40
|
-
config = sorcery_config
|
|
41
|
-
where("#{config.last_activity_at_attribute_name} IS NOT NULL") \
|
|
42
|
-
.where("#{config.last_logout_at_attribute_name} IS NULL OR #{config.last_activity_at_attribute_name} > #{config.last_logout_at_attribute_name}") \
|
|
43
|
-
.where("#{config.last_activity_at_attribute_name} > ? ", config.activity_timeout.seconds.ago.utc.to_s(:db))
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
module Sorcery
|
|
2
|
-
module Model
|
|
3
|
-
module Adapters
|
|
4
|
-
module MongoMapper
|
|
5
|
-
extend ActiveSupport::Concern
|
|
6
|
-
|
|
7
|
-
included do
|
|
8
|
-
include Sorcery::Model
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def increment(attr)
|
|
12
|
-
self.class.increment(id, attr => 1)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def save!(options = {})
|
|
16
|
-
save(options)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def update_many_attributes(attrs)
|
|
20
|
-
update_attributes(attrs)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
module ClassMethods
|
|
24
|
-
def credential_regex(credential)
|
|
25
|
-
return { :$regex => /^#{credential}$/i } if (@sorcery_config.downcase_username_before_authenticating)
|
|
26
|
-
return credential
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def find_by_credentials(credentials)
|
|
30
|
-
@sorcery_config.username_attribute_names.each do |attribute|
|
|
31
|
-
@user = where(attribute => credential_regex(credentials[0])).first
|
|
32
|
-
break if @user
|
|
33
|
-
end
|
|
34
|
-
@user
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def find_by_id(id)
|
|
38
|
-
find(id)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def find_by_activation_token(token)
|
|
42
|
-
where(sorcery_config.activation_token_attribute_name => token).first
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def transaction(&blk)
|
|
46
|
-
tap(&blk)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def find_by_sorcery_token(token_attr_name, token)
|
|
50
|
-
where(token_attr_name => token).first
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|