From cc73281406882b65a1f311004a7dab202856e56f Mon Sep 17 00:00:00 2001 From: Michael Bleigh Date: Sat, 3 Sep 2011 21:26:57 -0300 Subject: [PATCH] Clearing out everything to move towards the new 1.0 independent gems strategy. --- Gemfile | 13 +- Guardfile | 27 - LICENSE.md | 19 - Rakefile | 55 +- lib/omniauth.rb | 6 - {oa-core/lib => lib}/omniauth/auth_hash.rb | 0 lib/omniauth/core.rb | 1 + lib/omniauth/form.rb | 7 +- lib/omniauth/strategy.rb | 24 +- oa-core/oa-core.gemspec => oa-core.gemspec | 0 oa-core/.gemtest | 0 oa-core/.rspec | 3 - oa-core/.yardopts | 4 - oa-core/Gemfile | 3 - oa-core/LICENSE | 19 - oa-core/Rakefile | 6 - oa-core/autotest/discover.rb | 1 - oa-core/lib/oa-core.rb | 1 - oa-core/lib/omniauth/builder.rb | 33 - oa-core/lib/omniauth/core.rb | 141 -- oa-core/lib/omniauth/form.rb | 191 --- oa-core/lib/omniauth/strategy.rb | 242 ---- oa-core/lib/omniauth/test.rb | 12 - oa-core/lib/omniauth/test/phony_session.rb | 8 - oa-core/lib/omniauth/test/strategy_macros.rb | 34 - .../lib/omniauth/test/strategy_test_case.rb | 49 - oa-core/lib/omniauth/version.rb | 19 - oa-core/spec/omniauth/builder_spec.rb | 20 - oa-core/spec/omniauth/core_spec.rb | 79 -- oa-core/spec/omniauth/strategy_spec.rb | 397 ------ oa-core/spec/spec_helper.rb | 12 - oa-enterprise/.gemtest | 0 oa-enterprise/.rspec | 3 - oa-enterprise/.yardopts | 4 - oa-enterprise/Gemfile | 11 - oa-enterprise/LICENSE | 19 - oa-enterprise/README.rdoc | 115 -- oa-enterprise/Rakefile | 6 - oa-enterprise/lib/oa-enterprise.rb | 1 - oa-enterprise/lib/omniauth/enterprise.rb | 9 - oa-enterprise/lib/omniauth/strategies/cas.rb | 47 - .../omniauth/strategies/cas/configuration.rb | 98 -- .../cas/service_ticket_validator.rb | 91 -- oa-enterprise/lib/omniauth/strategies/ldap.rb | 124 -- .../lib/omniauth/strategies/ldap/adaptor.rb | 276 ---- oa-enterprise/lib/omniauth/strategies/saml.rb | 50 - .../omniauth/strategies/saml/auth_request.rb | 38 - .../omniauth/strategies/saml/auth_response.rb | 141 -- .../strategies/saml/validation_error.rb | 8 - .../omniauth/strategies/saml/xml_security.rb | 126 -- oa-enterprise/lib/omniauth/version.rb | 19 - oa-enterprise/oa-enterprise.gemspec | 31 - oa-enterprise/spec/fixtures/cas_failure.xml | 4 - oa-enterprise/spec/fixtures/cas_success.xml | 8 - .../spec/omniauth/strategies/cas_spec.rb | 94 -- .../spec/omniauth/strategies/ldap_spec.rb | 41 - .../spec/omniauth/strategies/saml_spec.rb | 37 - oa-enterprise/spec/spec_helper.rb | 14 - oa-identity/.rspec | 2 - oa-identity/README.markdown | 90 -- oa-identity/Rakefile | 8 - oa-identity/lib/oa-identity.rb | 1 - oa-identity/lib/omniauth/identity.rb | 17 - oa-identity/lib/omniauth/identity/model.rb | 119 -- .../omniauth/identity/models/active_record.rb | 24 - .../lib/omniauth/identity/secure_password.rb | 78 -- .../lib/omniauth/strategies/identity.rb | 96 -- oa-identity/oa-identity.gemspec | 27 - .../spec/omniauth/identity/model_spec.rb | 123 -- .../identity/models/active_record_spec.rb | 16 - .../omniauth/identity/secure_password_spec.rb | 27 - .../spec/omniauth/strategies/identity_spec.rb | 130 -- oa-identity/spec/spec_helper.rb | 14 - oa-more/.gemtest | 0 oa-more/.rspec | 3 - oa-more/.yardopts | 4 - oa-more/Gemfile | 11 - oa-more/LICENSE | 19 - oa-more/README.rdoc | 22 - oa-more/Rakefile | 6 - oa-more/lib/oa-more.rb | 1 - oa-more/lib/omniauth/more.rb | 12 - oa-more/lib/omniauth/strategies/draugiem.rb | 104 -- oa-more/lib/omniauth/strategies/http_basic.rb | 56 - oa-more/lib/omniauth/strategies/ign.rb | 93 -- oa-more/lib/omniauth/strategies/last_fm.rb | 93 -- .../lib/omniauth/strategies/windows_live.rb | 39 - .../windows_live/windowslivelogin.rb | 1143 ----------------- oa-more/lib/omniauth/strategies/yupoo.rb | 67 - oa-more/lib/omniauth/version.rb | 19 - oa-more/oa-more.gemspec | 27 - .../spec/omniauth/strategies/draugiem_spec.rb | 51 - .../omniauth/strategies/http_basic_spec.rb | 7 - .../spec/omniauth/strategies/last_fm_spec.rb | 7 - oa-more/spec/spec_helper.rb | 11 - oa-oauth/.gemtest | 0 oa-oauth/.rspec | 3 - oa-oauth/.yardopts | 4 - oa-oauth/Gemfile | 11 - oa-oauth/LICENSE | 19 - oa-oauth/README.rdoc | 35 - oa-oauth/Rakefile | 6 - oa-oauth/autotest/discover.rb | 1 - oa-oauth/lib/oa-oauth.rb | 1 - oa-oauth/lib/omniauth/oauth.rb | 74 -- .../lib/omniauth/strategies/google_oauth2.rb | 59 - oa-oauth/lib/omniauth/strategies/oauth.rb | 89 -- .../lib/omniauth/strategies/oauth/blogger.rb | 58 - .../lib/omniauth/strategies/oauth/dopplr.rb | 51 - .../lib/omniauth/strategies/oauth/douban.rb | 60 - .../lib/omniauth/strategies/oauth/dropbox.rb | 40 - .../lib/omniauth/strategies/oauth/evernote.rb | 52 - .../lib/omniauth/strategies/oauth/flattr.rb | 47 - .../lib/omniauth/strategies/oauth/flickr.rb | 39 - .../omniauth/strategies/oauth/goodreads.rb | 44 - .../lib/omniauth/strategies/oauth/google.rb | 79 -- .../strategies/oauth/google_health.rb | 71 - .../strategies/oauth/google_health_sandbox.rb | 74 -- .../lib/omniauth/strategies/oauth/hyves.rb | 69 - .../lib/omniauth/strategies/oauth/identica.rb | 53 - .../omniauth/strategies/oauth/linked_in.rb | 56 - .../lib/omniauth/strategies/oauth/meetup.rb | 58 - .../lib/omniauth/strategies/oauth/miso.rb | 48 - .../lib/omniauth/strategies/oauth/netflix.rb | 67 - .../lib/omniauth/strategies/oauth/orkut.rb | 63 - .../lib/omniauth/strategies/oauth/plurk.rb | 57 - .../lib/omniauth/strategies/oauth/qzone.rb | 72 -- .../lib/omniauth/strategies/oauth/rdio.rb | 48 - .../lib/omniauth/strategies/oauth/smug_mug.rb | 47 - .../lib/omniauth/strategies/oauth/t163.rb | 57 - oa-oauth/lib/omniauth/strategies/oauth/tqq.rb | 63 - .../lib/omniauth/strategies/oauth/trade_me.rb | 50 - .../lib/omniauth/strategies/oauth/trip_it.rb | 24 - .../lib/omniauth/strategies/oauth/tsina.rb | 85 -- .../lib/omniauth/strategies/oauth/tsohu.rb | 55 - .../lib/omniauth/strategies/oauth/tumblr.rb | 58 - .../lib/omniauth/strategies/oauth/twitter.rb | 58 - .../lib/omniauth/strategies/oauth/type_pad.rb | 67 - .../lib/omniauth/strategies/oauth/vimeo.rb | 58 - .../lib/omniauth/strategies/oauth/yahoo.rb | 60 - .../lib/omniauth/strategies/oauth/yammer.rb | 48 - .../lib/omniauth/strategies/oauth/you_tube.rb | 75 -- oa-oauth/lib/omniauth/strategies/oauth2.rb | 93 -- .../omniauth/strategies/oauth2/angellist.rb | 57 - .../lib/omniauth/strategies/oauth2/bitly.rb | 43 - .../lib/omniauth/strategies/oauth2/cobot.rb | 54 - .../omniauth/strategies/oauth2/dailymile.rb | 63 - .../lib/omniauth/strategies/oauth2/doit.rb | 60 - .../omniauth/strategies/oauth2/facebook.rb | 87 -- .../omniauth/strategies/oauth2/foursquare.rb | 63 - .../lib/omniauth/strategies/oauth2/github.rb | 52 - .../lib/omniauth/strategies/oauth2/glitch.rb | 45 - .../lib/omniauth/strategies/oauth2/gowalla.rb | 72 -- .../omniauth/strategies/oauth2/instagram.rb | 58 - .../lib/omniauth/strategies/oauth2/liveid.rb | 67 - .../omniauth/strategies/oauth2/mailchimp.rb | 39 - .../lib/omniauth/strategies/oauth2/mailru.rb | 75 -- .../lib/omniauth/strategies/oauth2/mixi.rb | 64 - .../lib/omniauth/strategies/oauth2/renren.rb | 89 -- .../omniauth/strategies/oauth2/salesforce.rb | 48 - .../omniauth/strategies/oauth2/sound_cloud.rb | 60 - .../lib/omniauth/strategies/oauth2/taobao.rb | 81 -- .../lib/omniauth/strategies/oauth2/teambox.rb | 51 - .../strategies/oauth2/thirty_seven_signals.rb | 41 - .../lib/omniauth/strategies/oauth2/viadeo.rb | 72 -- .../omniauth/strategies/oauth2/vkontakte.rb | 104 -- .../lib/omniauth/strategies/oauth2/we_pay.rb | 48 - oa-oauth/lib/omniauth/strategies/xauth.rb | 67 - .../omniauth/strategies/xauth/instapaper.rb | 37 - oa-oauth/lib/omniauth/version.rb | 19 - oa-oauth/oa-oauth.gemspec | 31 - oa-oauth/spec/fixtures/basecamp_200.xml | 24 - oa-oauth/spec/fixtures/campfire_200.json | 10 - .../omniauth/strategies/google_oauth2_spec.rb | 5 - .../omniauth/strategies/oauth/dopplr_spec.rb | 5 - .../omniauth/strategies/oauth/douban_spec.rb | 5 - .../omniauth/strategies/oauth/dropbox_spec.rb | 5 - .../strategies/oauth/evernote_spec.rb | 5 - .../omniauth/strategies/oauth/flattr_spec.rb | 5 - .../omniauth/strategies/oauth/flickr_spec.rb | 6 - .../strategies/oauth/goodreads_spec.rb | 6 - .../oauth/google_health_sandbox_spec.rb | 5 - .../strategies/oauth/google_health_spec.rb | 5 - .../omniauth/strategies/oauth/google_spec.rb | 5 - .../omniauth/strategies/oauth/hyves_spec.rb | 5 - .../strategies/oauth/identica_spec.rb | 5 - .../strategies/oauth/linked_in_spec.rb | 5 - .../omniauth/strategies/oauth/meetup_spec.rb | 14 - .../omniauth/strategies/oauth/miso_spec.rb | 5 - .../omniauth/strategies/oauth/netflix_spec.rb | 5 - .../omniauth/strategies/oauth/oauth_spec.rb | 131 -- .../omniauth/strategies/oauth/orkut_spec.rb | 5 - .../omniauth/strategies/oauth/plurk_spec.rb | 5 - .../omniauth/strategies/oauth/rdio_spec.rb | 5 - .../strategies/oauth/smug_mug_spec.rb | 5 - .../omniauth/strategies/oauth/t163_spec.rb | 5 - .../strategies/oauth/trade_me_spec.rb | 5 - .../omniauth/strategies/oauth/trip_it_spec.rb | 5 - .../omniauth/strategies/oauth/tsina_spec.rb | 5 - .../omniauth/strategies/oauth/tumblr_spec.rb | 5 - .../omniauth/strategies/oauth/twitter_spec.rb | 43 - .../strategies/oauth/type_pad_spec.rb | 5 - .../omniauth/strategies/oauth/vimeo_spec.rb | 5 - .../omniauth/strategies/oauth/yahoo_spec.rb | 5 - .../omniauth/strategies/oauth/yammer_spec.rb | 5 - .../strategies/oauth/you_tube_spec.rb | 5 - .../strategies/oauth2/angellist_spec.rb | 5 - .../omniauth/strategies/oauth2/bitly_spec.rb | 5 - .../omniauth/strategies/oauth2/cobot_spec.rb | 5 - .../strategies/oauth2/dailymile_spec.rb | 5 - .../omniauth/strategies/oauth2/doit_spec.rb | 5 - .../strategies/oauth2/facebook_spec.rb | 5 - .../strategies/oauth2/foursquare_spec.rb | 18 - .../omniauth/strategies/oauth2/github_spec.rb | 5 - .../omniauth/strategies/oauth2/glitch_spec.rb | 5 - .../strategies/oauth2/gowalla_spec.rb | 5 - .../strategies/oauth2/instagram_spec.rb | 5 - .../omniauth/strategies/oauth2/liveid_spec.rb | 5 - .../strategies/oauth2/mailchimp_spec.rb | 6 - .../omniauth/strategies/oauth2/mailru_spec.rb | 5 - .../strategies/oauth2/salesforce_spec.rb | 5 - .../strategies/oauth2/sound_cloud_spec.rb | 5 - .../omniauth/strategies/oauth2/taobao_spec.rb | 5 - .../strategies/oauth2/teambox_spec.rb | 5 - .../oauth2/thirty_seven_signals_spec.rb | 5 - .../omniauth/strategies/oauth2/viadeo_spec.rb | 5 - .../strategies/oauth2/vkontakte_spec.rb | 5 - .../omniauth/strategies/oauth2/we_pay_spec.rb | 5 - oa-oauth/spec/spec_helper.rb | 31 - oa-oauth/spec/support/shared_examples.rb | 29 - oa-openid/.gemtest | 0 oa-openid/.rspec | 3 - oa-openid/.yardopts | 4 - oa-openid/Gemfile | 12 - oa-openid/LICENSE | 19 - oa-openid/README.rdoc | 51 - oa-openid/Rakefile | 6 - oa-openid/lib/oa-openid.rb | 1 - oa-openid/lib/omniauth/openid.rb | 61 - oa-openid/lib/omniauth/openid/gapps.rb | 32 - .../lib/omniauth/strategies/google_apps.rb | 23 - .../lib/omniauth/strategies/google_hybrid.rb | 55 - oa-openid/lib/omniauth/strategies/open_id.rb | 134 -- oa-openid/lib/omniauth/strategies/steam.rb | 55 - oa-openid/lib/omniauth/version.rb | 19 - oa-openid/oa-openid.gemspec | 26 - .../omniauth/strategies/google_hybrid_spec.rb | 63 - .../spec/omniauth/strategies/open_id_spec.rb | 87 -- oa-openid/spec/spec_helper.rb | 14 - omniauth.gemspec | 18 - .../spec => spec}/omniauth/auth_hash_spec.rb | 0 spec/omniauth/strategy_spec.rb | 29 + tasks/all.rb | 134 -- 253 files changed, 60 insertions(+), 10805 deletions(-) delete mode 100644 Guardfile delete mode 100644 LICENSE.md mode change 100755 => 100644 Rakefile delete mode 100644 lib/omniauth.rb rename {oa-core/lib => lib}/omniauth/auth_hash.rb (100%) rename oa-core/oa-core.gemspec => oa-core.gemspec (100%) delete mode 100644 oa-core/.gemtest delete mode 100644 oa-core/.rspec delete mode 100644 oa-core/.yardopts delete mode 100644 oa-core/Gemfile delete mode 100644 oa-core/LICENSE delete mode 100644 oa-core/Rakefile delete mode 100644 oa-core/autotest/discover.rb delete mode 100644 oa-core/lib/oa-core.rb delete mode 100644 oa-core/lib/omniauth/builder.rb delete mode 100644 oa-core/lib/omniauth/core.rb delete mode 100644 oa-core/lib/omniauth/form.rb delete mode 100644 oa-core/lib/omniauth/strategy.rb delete mode 100644 oa-core/lib/omniauth/test.rb delete mode 100644 oa-core/lib/omniauth/test/phony_session.rb delete mode 100644 oa-core/lib/omniauth/test/strategy_macros.rb delete mode 100644 oa-core/lib/omniauth/test/strategy_test_case.rb delete mode 100644 oa-core/lib/omniauth/version.rb delete mode 100644 oa-core/spec/omniauth/builder_spec.rb delete mode 100644 oa-core/spec/omniauth/core_spec.rb delete mode 100644 oa-core/spec/omniauth/strategy_spec.rb delete mode 100644 oa-core/spec/spec_helper.rb delete mode 100644 oa-enterprise/.gemtest delete mode 100644 oa-enterprise/.rspec delete mode 100644 oa-enterprise/.yardopts delete mode 100644 oa-enterprise/Gemfile delete mode 100644 oa-enterprise/LICENSE delete mode 100644 oa-enterprise/README.rdoc delete mode 100644 oa-enterprise/Rakefile delete mode 100644 oa-enterprise/lib/oa-enterprise.rb delete mode 100644 oa-enterprise/lib/omniauth/enterprise.rb delete mode 100644 oa-enterprise/lib/omniauth/strategies/cas.rb delete mode 100644 oa-enterprise/lib/omniauth/strategies/cas/configuration.rb delete mode 100644 oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb delete mode 100644 oa-enterprise/lib/omniauth/strategies/ldap.rb delete mode 100644 oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb delete mode 100644 oa-enterprise/lib/omniauth/strategies/saml.rb delete mode 100644 oa-enterprise/lib/omniauth/strategies/saml/auth_request.rb delete mode 100644 oa-enterprise/lib/omniauth/strategies/saml/auth_response.rb delete mode 100644 oa-enterprise/lib/omniauth/strategies/saml/validation_error.rb delete mode 100644 oa-enterprise/lib/omniauth/strategies/saml/xml_security.rb delete mode 100644 oa-enterprise/lib/omniauth/version.rb delete mode 100644 oa-enterprise/oa-enterprise.gemspec delete mode 100644 oa-enterprise/spec/fixtures/cas_failure.xml delete mode 100644 oa-enterprise/spec/fixtures/cas_success.xml delete mode 100644 oa-enterprise/spec/omniauth/strategies/cas_spec.rb delete mode 100644 oa-enterprise/spec/omniauth/strategies/ldap_spec.rb delete mode 100644 oa-enterprise/spec/omniauth/strategies/saml_spec.rb delete mode 100644 oa-enterprise/spec/spec_helper.rb delete mode 100644 oa-identity/.rspec delete mode 100644 oa-identity/README.markdown delete mode 100644 oa-identity/Rakefile delete mode 100644 oa-identity/lib/oa-identity.rb delete mode 100644 oa-identity/lib/omniauth/identity.rb delete mode 100644 oa-identity/lib/omniauth/identity/model.rb delete mode 100644 oa-identity/lib/omniauth/identity/models/active_record.rb delete mode 100644 oa-identity/lib/omniauth/identity/secure_password.rb delete mode 100644 oa-identity/lib/omniauth/strategies/identity.rb delete mode 100644 oa-identity/oa-identity.gemspec delete mode 100644 oa-identity/spec/omniauth/identity/model_spec.rb delete mode 100644 oa-identity/spec/omniauth/identity/models/active_record_spec.rb delete mode 100644 oa-identity/spec/omniauth/identity/secure_password_spec.rb delete mode 100644 oa-identity/spec/omniauth/strategies/identity_spec.rb delete mode 100644 oa-identity/spec/spec_helper.rb delete mode 100644 oa-more/.gemtest delete mode 100644 oa-more/.rspec delete mode 100644 oa-more/.yardopts delete mode 100644 oa-more/Gemfile delete mode 100644 oa-more/LICENSE delete mode 100644 oa-more/README.rdoc delete mode 100644 oa-more/Rakefile delete mode 100644 oa-more/lib/oa-more.rb delete mode 100644 oa-more/lib/omniauth/more.rb delete mode 100644 oa-more/lib/omniauth/strategies/draugiem.rb delete mode 100644 oa-more/lib/omniauth/strategies/http_basic.rb delete mode 100644 oa-more/lib/omniauth/strategies/ign.rb delete mode 100644 oa-more/lib/omniauth/strategies/last_fm.rb delete mode 100644 oa-more/lib/omniauth/strategies/windows_live.rb delete mode 100644 oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb delete mode 100644 oa-more/lib/omniauth/strategies/yupoo.rb delete mode 100644 oa-more/lib/omniauth/version.rb delete mode 100644 oa-more/oa-more.gemspec delete mode 100644 oa-more/spec/omniauth/strategies/draugiem_spec.rb delete mode 100644 oa-more/spec/omniauth/strategies/http_basic_spec.rb delete mode 100644 oa-more/spec/omniauth/strategies/last_fm_spec.rb delete mode 100644 oa-more/spec/spec_helper.rb delete mode 100644 oa-oauth/.gemtest delete mode 100644 oa-oauth/.rspec delete mode 100644 oa-oauth/.yardopts delete mode 100644 oa-oauth/Gemfile delete mode 100644 oa-oauth/LICENSE delete mode 100644 oa-oauth/README.rdoc delete mode 100644 oa-oauth/Rakefile delete mode 100644 oa-oauth/autotest/discover.rb delete mode 100644 oa-oauth/lib/oa-oauth.rb delete mode 100644 oa-oauth/lib/omniauth/oauth.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/google_oauth2.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/blogger.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/dopplr.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/douban.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/dropbox.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/evernote.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/flattr.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/flickr.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/google.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/google_health.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/google_health_sandbox.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/hyves.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/identica.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/linked_in.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/meetup.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/miso.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/netflix.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/orkut.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/plurk.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/qzone.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/rdio.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/smug_mug.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/t163.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/tqq.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/trade_me.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/trip_it.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/tsina.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/tsohu.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/tumblr.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/twitter.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/type_pad.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/vimeo.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/yahoo.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/yammer.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth/you_tube.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/angellist.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/bitly.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/cobot.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/dailymile.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/doit.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/foursquare.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/github.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/glitch.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/gowalla.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/instagram.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/liveid.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/mailchimp.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/mailru.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/mixi.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/renren.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/salesforce.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/sound_cloud.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/taobao.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/teambox.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/thirty_seven_signals.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/viadeo.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/vkontakte.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/oauth2/we_pay.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/xauth.rb delete mode 100644 oa-oauth/lib/omniauth/strategies/xauth/instapaper.rb delete mode 100644 oa-oauth/lib/omniauth/version.rb delete mode 100644 oa-oauth/oa-oauth.gemspec delete mode 100644 oa-oauth/spec/fixtures/basecamp_200.xml delete mode 100644 oa-oauth/spec/fixtures/campfire_200.json delete mode 100644 oa-oauth/spec/omniauth/strategies/google_oauth2_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/dopplr_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/douban_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/dropbox_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/evernote_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/flattr_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/flickr_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/goodreads_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/google_health_sandbox_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/google_health_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/google_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/hyves_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/identica_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/linked_in_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/meetup_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/miso_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/netflix_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/oauth_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/orkut_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/plurk_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/rdio_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/smug_mug_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/t163_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/trade_me_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/trip_it_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/tsina_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/tumblr_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/twitter_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/type_pad_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/vimeo_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/yahoo_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/yammer_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth/you_tube_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/angellist_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/bitly_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/cobot_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/dailymile_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/doit_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/facebook_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/foursquare_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/github_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/glitch_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/gowalla_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/instagram_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/liveid_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/mailchimp_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/mailru_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/salesforce_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/sound_cloud_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/taobao_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/teambox_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/thirty_seven_signals_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/viadeo_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/vkontakte_spec.rb delete mode 100644 oa-oauth/spec/omniauth/strategies/oauth2/we_pay_spec.rb delete mode 100644 oa-oauth/spec/spec_helper.rb delete mode 100644 oa-oauth/spec/support/shared_examples.rb delete mode 100644 oa-openid/.gemtest delete mode 100644 oa-openid/.rspec delete mode 100644 oa-openid/.yardopts delete mode 100644 oa-openid/Gemfile delete mode 100644 oa-openid/LICENSE delete mode 100644 oa-openid/README.rdoc delete mode 100644 oa-openid/Rakefile delete mode 100644 oa-openid/lib/oa-openid.rb delete mode 100644 oa-openid/lib/omniauth/openid.rb delete mode 100644 oa-openid/lib/omniauth/openid/gapps.rb delete mode 100644 oa-openid/lib/omniauth/strategies/google_apps.rb delete mode 100644 oa-openid/lib/omniauth/strategies/google_hybrid.rb delete mode 100644 oa-openid/lib/omniauth/strategies/open_id.rb delete mode 100644 oa-openid/lib/omniauth/strategies/steam.rb delete mode 100644 oa-openid/lib/omniauth/version.rb delete mode 100644 oa-openid/oa-openid.gemspec delete mode 100644 oa-openid/spec/omniauth/strategies/google_hybrid_spec.rb delete mode 100644 oa-openid/spec/omniauth/strategies/open_id_spec.rb delete mode 100644 oa-openid/spec/spec_helper.rb delete mode 100644 omniauth.gemspec rename {oa-core/spec => spec}/omniauth/auth_hash_spec.rb (100%) delete mode 100644 tasks/all.rb diff --git a/Gemfile b/Gemfile index bbc40d2..d65e2a6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,14 +1,3 @@ source 'http://rubygems.org' -platforms :jruby do - gem 'jruby-openssl', '~> 0.7' -end - -gemspec :path => 'oa-core' -gemspec :path => 'oa-enterprise' -gemspec :path => 'oa-more' -gemspec :path => 'oa-oauth' -gemspec :path => 'oa-openid' - -gem 'activerecord', '3.1.0.rc1' - +gemspec diff --git a/Guardfile b/Guardfile deleted file mode 100644 index 1a3d01a..0000000 --- a/Guardfile +++ /dev/null @@ -1,27 +0,0 @@ -# A sample Guardfile -# More info at https://github.com/guard/guard#readme - -guard 'rspec', :version => 2 do - watch(%r{^spec/.+_spec\.rb$}) - watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } - watch('spec/spec_helper.rb') { "spec/" } - - # Rails example - watch(%r{^spec/.+_spec\.rb$}) - watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } - watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } - watch(%r{^spec/support/(.+)\.rb$}) { "spec/" } - watch('spec/spec_helper.rb') { "spec/" } - watch('config/routes.rb') { "spec/routing" } - watch('app/controllers/application_controller.rb') { "spec/controllers" } - # Capybara request specs - watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } -end - - -guard 'bundler' do - watch('Gemfile') - # Uncomment next line if Gemfile contain `gemspec' command - # watch(/^.+\.gemspec/) -end diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 143f9d4..0000000 --- a/LICENSE.md +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010-2011 Michael Bleigh, Erik Michaels-Ober, and Intridea, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/Rakefile b/Rakefile old mode 100755 new mode 100644 index 6a538e9..69797fc --- a/Rakefile +++ b/Rakefile @@ -1,51 +1,6 @@ -#!/usr/bin/env rake - -$:.unshift File.expand_path('..', __FILE__) -require 'tasks/all' - -desc 'Clean up temporary files' -task :clean => 'all:clean' - -desc 'Build gem files for all projects into the package directory' -task :build => 'all:build' - -desc 'Build and install gems for all projects' -task :install => 'all:install' - -desc 'Write version with MAJOR, MINOR, PATCH, and PRE environment variables' -task 'version:write' => 'all:version:write' - -desc 'Display the current version for all projects' -task :version => 'all:version' -desc 'Increment the major version for all projects' -task 'version:bump:major' => 'all:version:bump:major' -desc 'Increment the minor version for all projects' -task 'version:bump:minor' => 'all:version:bump:minor' -desc 'Increment the patch version for all projects' -task 'version:bump:patch' => 'all:version:bump:patch' - -desc 'Run specs for all projects' -task :spec => 'all:spec' +require 'bundler' +Bundler::GemHelper.install_tasks +require 'rspec/core/rake_task' +RSpec::Core::RakeTask.new(:spec) +task :default => :spec task :test => :spec -task :default => :test - -desc 'Generate docs for all projects' -task 'doc:yard' => 'all:doc:yard' - -task :tag do - sh "git tag -a -m \"Version #{version}\" v#{version}" - sh "git push" - sh "git push --tags" -end - -task :push => 'all:push' - -desc 'Build, tag, and push gems for all projects to Rubygems' -task :release => [:build, :tag, :push] - -namespace :doc do - require 'yard' - YARD::Rake::YardocTask.new do |task| - task.files = PROJECTS.map{|project| "#{root}/#{project}/lib/**/*.rb"} + ['README.markdown', 'LICENSE'] - end -end diff --git a/lib/omniauth.rb b/lib/omniauth.rb deleted file mode 100644 index 8c75730..0000000 --- a/lib/omniauth.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'omniauth/core' -require 'omniauth/oauth' -require 'omniauth/openid' -require 'omniauth/enterprise' -require 'omniauth/more' -require 'omniauth/identity' diff --git a/oa-core/lib/omniauth/auth_hash.rb b/lib/omniauth/auth_hash.rb similarity index 100% rename from oa-core/lib/omniauth/auth_hash.rb rename to lib/omniauth/auth_hash.rb diff --git a/lib/omniauth/core.rb b/lib/omniauth/core.rb index 2c9bd24..5a2201a 100644 --- a/lib/omniauth/core.rb +++ b/lib/omniauth/core.rb @@ -8,6 +8,7 @@ module OmniAuth autoload :Strategy, 'omniauth/strategy' autoload :Test, 'omniauth/test' autoload :Form, 'omniauth/form' + autoload :AuthHash, 'omniauth/auth_hash' def self.strategies @@strategies ||= [] diff --git a/lib/omniauth/form.rb b/lib/omniauth/form.rb index 20eebd0..99b7427 100644 --- a/lib/omniauth/form.rb +++ b/lib/omniauth/form.rb @@ -99,7 +99,12 @@ module OmniAuth def self.build(title=nil,&block) form = OmniAuth::Form.new(title) - form.instance_eval(&block) + if block.arity > 0 + yield form + else + form.instance_eval(&block) + end + form end def label_field(text, target) diff --git a/lib/omniauth/strategy.rb b/lib/omniauth/strategy.rb index 28d1ef8..41576e0 100644 --- a/lib/omniauth/strategy.rb +++ b/lib/omniauth/strategy.rb @@ -38,12 +38,19 @@ module OmniAuth return mock_call!(env) if OmniAuth.config.test_mode + return options_call if on_auth_path? && options_request? return request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym) return callback_call if on_callback_path? return other_phase if respond_to?(:other_phase) @app.call(env) end + # Responds to an OPTIONS request. + def options_call + verbs = OmniAuth.config.allowed_request_methods.map(&:to_s).map(&:upcase).join(', ') + return [ 200, { 'Allow' => verbs }, [] ] + end + # Performs the steps necessary to run the request phase of a strategy. def request_call setup_phase @@ -73,11 +80,19 @@ module OmniAuth end def on_request_path? - current_path.casecmp(request_path) == 0 + on_path?(request_path) end def on_callback_path? - current_path.casecmp(callback_path) == 0 + on_path?(callback_path) + end + + def on_path?(path) + current_path.casecmp(path) == 0 + end + + def options_request? + request.request_method == 'OPTIONS' end def mock_call!(env) @@ -168,10 +183,7 @@ module OmniAuth end def auth_hash - { - 'provider' => name.to_s, - 'uid' => nil - } + AuthHash.new(:provider => name.to_s) end def full_host diff --git a/oa-core/oa-core.gemspec b/oa-core.gemspec similarity index 100% rename from oa-core/oa-core.gemspec rename to oa-core.gemspec diff --git a/oa-core/.gemtest b/oa-core/.gemtest deleted file mode 100644 index e69de29..0000000 diff --git a/oa-core/.rspec b/oa-core/.rspec deleted file mode 100644 index bb259fe..0000000 --- a/oa-core/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---color ---format=nested ---backtrace diff --git a/oa-core/.yardopts b/oa-core/.yardopts deleted file mode 100644 index 7a69ee4..0000000 --- a/oa-core/.yardopts +++ /dev/null @@ -1,4 +0,0 @@ ---markup markdown ---markup-provider maruku -- -LICENSE diff --git a/oa-core/Gemfile b/oa-core/Gemfile deleted file mode 100644 index d65e2a6..0000000 --- a/oa-core/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source 'http://rubygems.org' - -gemspec diff --git a/oa-core/LICENSE b/oa-core/LICENSE deleted file mode 100644 index 811fa0e..0000000 --- a/oa-core/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/oa-core/Rakefile b/oa-core/Rakefile deleted file mode 100644 index 69797fc..0000000 --- a/oa-core/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require 'bundler' -Bundler::GemHelper.install_tasks -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) -task :default => :spec -task :test => :spec diff --git a/oa-core/autotest/discover.rb b/oa-core/autotest/discover.rb deleted file mode 100644 index cd6892c..0000000 --- a/oa-core/autotest/discover.rb +++ /dev/null @@ -1 +0,0 @@ -Autotest.add_discovery { "rspec2" } diff --git a/oa-core/lib/oa-core.rb b/oa-core/lib/oa-core.rb deleted file mode 100644 index cf3f19d..0000000 --- a/oa-core/lib/oa-core.rb +++ /dev/null @@ -1 +0,0 @@ -require 'omniauth/core' diff --git a/oa-core/lib/omniauth/builder.rb b/oa-core/lib/omniauth/builder.rb deleted file mode 100644 index 49dfddc..0000000 --- a/oa-core/lib/omniauth/builder.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'omniauth/core' - -module OmniAuth - class Builder < ::Rack::Builder - def initialize(app, &block) - @app = app - super(&block) - end - - def on_failure(&block) - OmniAuth.config.on_failure = block - end - - def configure(&block) - OmniAuth.configure(&block) - end - - def provider(klass, *args, &block) - if klass.is_a?(Class) - middleware = klass - else - middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}") - end - - use middleware, *args, &block - end - - def call(env) - @ins << @app unless @ins.include?(@app) - to_app.call(env) - end - end -end diff --git a/oa-core/lib/omniauth/core.rb b/oa-core/lib/omniauth/core.rb deleted file mode 100644 index 5a2201a..0000000 --- a/oa-core/lib/omniauth/core.rb +++ /dev/null @@ -1,141 +0,0 @@ -require 'rack' -require 'singleton' - -module OmniAuth - module Strategies; end - - autoload :Builder, 'omniauth/builder' - autoload :Strategy, 'omniauth/strategy' - autoload :Test, 'omniauth/test' - autoload :Form, 'omniauth/form' - autoload :AuthHash, 'omniauth/auth_hash' - - def self.strategies - @@strategies ||= [] - end - - class Configuration - include Singleton - - @@defaults = { - :path_prefix => '/auth', - :on_failure => Proc.new do |env| - message_key = env['omniauth.error.type'] - new_path = "#{OmniAuth.config.path_prefix}/failure?message=#{message_key}" - [302, {'Location' => new_path, 'Content-Type'=> 'text/html'}, []] - end, - :form_css => Form::DEFAULT_CSS, - :test_mode => false, - :allowed_request_methods => [:get, :post], - :mock_auth => { - :default => { - 'provider' => 'default', - 'uid' => '1234', - 'user_info' => { - 'name' => 'Bob Example' - } - } - } - } - - def self.defaults - @@defaults - end - - def initialize - @@defaults.each_pair{|k,v| self.send("#{k}=",v)} - end - - def on_failure(&block) - if block_given? - @on_failure = block - else - @on_failure - end - end - - def add_mock(provider, mock={}) - # Stringify keys recursively one level. - mock.keys.each do |key| - mock[key.to_s] = mock.delete(key) - end - mock.each_pair do |key, val| - if val.is_a? Hash - val.keys.each do |subkey| - val[subkey.to_s] = val.delete(subkey) - end - end - end - - # Merge with the default mock and ensure provider is correct. - mock = self.mock_auth[:default].dup.merge(mock) - mock["provider"] = provider.to_s - - # Add it to the mocks. - self.mock_auth[provider.to_sym] = mock - end - - attr_writer :on_failure - attr_accessor :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host - end - - def self.config - Configuration.instance - end - - def self.configure - yield config - end - - def self.mock_auth_for(provider) - config.mock_auth[provider.to_sym] || config.mock_auth[:default] - end - - module Utils - CAMELIZE_SPECIAL = { - 'oauth' => 'OAuth', - 'oauth2' => 'OAuth2', - 'openid' => 'OpenID', - 'open_id' => 'OpenID', - 'github' => 'GitHub', - 'tripit' => 'TripIt', - 'soundcloud' => 'SoundCloud', - 'smugmug' => 'SmugMug', - 'cas' => 'CAS', - 'trademe' => 'TradeMe', - 'ldap' => 'LDAP', - 'google_oauth2' => 'GoogleOAuth2' - } - - module_function - - def form_css - "" - end - - def deep_merge(hash, other_hash) - target = hash.dup - - other_hash.keys.each do |key| - if other_hash[key].is_a? ::Hash and hash[key].is_a? ::Hash - target[key] = deep_merge(target[key],other_hash[key]) - next - end - - target[key] = other_hash[key] - end - - target - end - - def camelize(word, first_letter_in_uppercase = true) - return CAMELIZE_SPECIAL[word.to_s] if CAMELIZE_SPECIAL[word.to_s] - - if first_letter_in_uppercase - word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase } - else - word.first + camelize(word)[1..-1] - end - end - end -end diff --git a/oa-core/lib/omniauth/form.rb b/oa-core/lib/omniauth/form.rb deleted file mode 100644 index 99b7427..0000000 --- a/oa-core/lib/omniauth/form.rb +++ /dev/null @@ -1,191 +0,0 @@ -require 'omniauth/core' - -module OmniAuth - class Form - DEFAULT_CSS = <<-CSS - body { - background: #ccc; - font-family: "Lucida Grande", "Lucida Sans", Helvetica, Arial, sans-serif; - } - - h1 { - text-align: center; - margin: 30px auto 0px; - font-size: 18px; - padding: 10px 10px 15px; - background: #555; - color: white; - width: 320px; - border: 10px solid #444; - border-bottom: 0; - -moz-border-radius-topleft: 10px; - -moz-border-radius-topright: 10px; - -webkit-border-top-left-radius: 10px; - -webkit-border-top-right-radius: 10px; - border-top-left-radius: 10px; - border-top-right-radius: 10px; - } - - h1, form { - -moz-box-shadow: 2px 2px 7px rgba(0,0,0,0.3); - -webkit-box-shadow: 2px 2px 7px rgba(0,0,0,0.3); - } - - form { - background: white; - border: 10px solid #eee; - border-top: 0; - padding: 20px; - margin: 0px auto 40px; - width: 300px; - -moz-border-radius-bottomleft: 10px; - -moz-border-radius-bottomright: 10px; - -webkit-border-bottom-left-radius: 10px; - -webkit-border-bottom-right-radius: 10px; - border-bottom-left-radius: 10px; - border-bottom-right-radius: 10px; - } - - label { - display: block; - font-weight: bold; - margin-bottom: 5px; - } - - input { - font-size: 18px; - padding: 4px 8px; - display: block; - margin-bottom: 10px; - width: 280px; - } - - input#identifier, input#openid_url { - background: url(http://openid.net/login-bg.gif) no-repeat; - background-position: 0 50%; - padding-left: 18px; - } - - button { - font-size: 22px; - padding: 4px 8px; - display: block; - margin: 20px auto 0; - } - - fieldset { - border: 1px solid #ccc; - border-left: 0; - border-right: 0; - padding: 10px 0; - } - - fieldset input { - width: 260px; - font-size: 16px; - } - CSS - - attr_accessor :options - - def initialize(options = {}) - options[:title] ||= "Authentication Info Required" - options[:header_info] ||= "" - self.options = options - - @html = "" - header(options[:title],options[:header_info]) - end - - def self.build(title=nil,&block) - form = OmniAuth::Form.new(title) - if block.arity > 0 - yield form - else - form.instance_eval(&block) - end - form - end - - def label_field(text, target) - @html << "\n" - self - end - - def input_field(type, name) - @html << "\n" - self - end - - def text_field(label, name) - label_field(label, name) - input_field('text', name) - self - end - - def password_field(label, name) - label_field(label, name) - input_field('password', name) - self - end - - def button(text) - @html << "\n" - end - - def html(html) - @html << html - end - - def fieldset(legend, options = {}, &block) - @html << "\n\n #{legend}\n" - self.instance_eval &block - @html << "\n" - self - end - - def header(title,header_info) - @html << <<-HTML - - - - #{title} - #{css} - #{header_info} - - -

#{title}

-
- HTML - self - end - - def footer - return self if @footer - @html << <<-HTML - -
- - - HTML - @footer = true - self - end - - def to_html - footer - @html - end - - def to_response - footer - Rack::Response.new(@html).finish - end - - protected - - def css - "\n" - end - end -end diff --git a/oa-core/lib/omniauth/strategy.rb b/oa-core/lib/omniauth/strategy.rb deleted file mode 100644 index 41576e0..0000000 --- a/oa-core/lib/omniauth/strategy.rb +++ /dev/null @@ -1,242 +0,0 @@ -require 'omniauth/core' - -module OmniAuth - class NoSessionError < StandardError; end - # The Strategy is the base unit of OmniAuth's ability to - # wrangle multiple providers. Each strategy provided by - # OmniAuth includes this mixin to gain the default functionality - # necessary to be compatible with the OmniAuth library. - module Strategy - def self.included(base) - OmniAuth.strategies << base - base.class_eval do - attr_reader :app, :name, :env, :options, :response - end - end - - def initialize(app, name, *args, &block) - @app = app - @name = name.to_sym - @options = args.last.is_a?(Hash) ? args.pop : {} - - yield self if block_given? - end - - def inspect - "#<#{self.class.to_s}>" - end - - def call(env) - dup.call!(env) - end - - def call!(env) - raise OmniAuth::NoSessionError.new("You must provide a session to use OmniAuth.") unless env['rack.session'] - - @env = env - @env['omniauth.strategy'] = self if on_auth_path? - - return mock_call!(env) if OmniAuth.config.test_mode - - return options_call if on_auth_path? && options_request? - return request_call if on_request_path? && OmniAuth.config.allowed_request_methods.include?(request.request_method.downcase.to_sym) - return callback_call if on_callback_path? - return other_phase if respond_to?(:other_phase) - @app.call(env) - end - - # Responds to an OPTIONS request. - def options_call - verbs = OmniAuth.config.allowed_request_methods.map(&:to_s).map(&:upcase).join(', ') - return [ 200, { 'Allow' => verbs }, [] ] - end - - # Performs the steps necessary to run the request phase of a strategy. - def request_call - setup_phase - if response = call_through_to_app - response - else - if request.params['origin'] - @env['rack.session']['omniauth.origin'] = request.params['origin'] - elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/) - @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER'] - end - request_phase - end - end - - # Performs the steps necessary to run the callback phase of a strategy. - def callback_call - setup_phase - @env['omniauth.origin'] = session.delete('omniauth.origin') - @env['omniauth.origin'] = nil if env['omniauth.origin'] == '' - - callback_phase - end - - def on_auth_path? - on_request_path? || on_callback_path? - end - - def on_request_path? - on_path?(request_path) - end - - def on_callback_path? - on_path?(callback_path) - end - - def on_path?(path) - current_path.casecmp(path) == 0 - end - - def options_request? - request.request_method == 'OPTIONS' - end - - def mock_call!(env) - return mock_request_call if on_request_path? - return mock_callback_call if on_callback_path? - call_app! - end - - def mock_request_call - setup_phase - return response if response = call_through_to_app - - if request.params['origin'] - @env['rack.session']['omniauth.origin'] = request.params['origin'] - elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/) - @env['rack.session']['omniauth.origin'] = env['HTTP_REFERER'] - end - redirect(script_name + callback_path + query_string) - end - - def mock_callback_call - setup_phase - mocked_auth = OmniAuth.mock_auth_for(name.to_sym) - if mocked_auth.is_a?(Symbol) - fail!(mocked_auth) - else - @env['omniauth.auth'] = mocked_auth - @env['omniauth.origin'] = session.delete('omniauth.origin') - @env['omniauth.origin'] = nil if env['omniauth.origin'] == '' - call_app! - end - end - - def setup_phase - if options[:setup].respond_to?(:call) - options[:setup].call(env) - elsif options[:setup] - setup_env = env.merge('PATH_INFO' => setup_path, 'REQUEST_METHOD' => 'GET') - call_app!(setup_env) - end - end - - def request_phase - raise NotImplementedError - end - - def callback_phase - @env['omniauth.auth'] = auth_hash - @env['omniauth.params'] = session['query_params'] || {} - session['query_params'] = nil if session['query_params'] - call_app! - end - - def path_prefix - options[:path_prefix] || OmniAuth.config.path_prefix - end - - def request_path - options[:request_path] || "#{path_prefix}/#{name}" - end - - def callback_path - options[:callback_path] || "#{path_prefix}/#{name}/callback" - end - - def setup_path - options[:setup_path] || "#{path_prefix}/#{name}/setup" - end - - def current_path - request.path_info.downcase.sub(/\/$/,'') - end - - def query_string - request.query_string.empty? ? "" : "?#{request.query_string}" - end - - def call_through_to_app - status, headers, body = *call_app! - session['query_params'] = Rack::Request.new(env).params - @response = Rack::Response.new(body, status, headers) - - status == 404 ? nil : @response.finish - end - - def call_app!(env = @env) - @app.call(env) - end - - def auth_hash - AuthHash.new(:provider => name.to_s) - end - - def full_host - case OmniAuth.config.full_host - when String - OmniAuth.config.full_host - when Proc - OmniAuth.config.full_host.call(env) - else - uri = URI.parse(request.url.gsub(/\?.*$/,'')) - uri.path = '' - uri.query = nil - uri.to_s - end - end - - def callback_url - full_host + script_name + callback_path + query_string - end - - def script_name - @env['SCRIPT_NAME'] || '' - end - - def session - @env['rack.session'] - end - - def request - @request ||= Rack::Request.new(@env) - end - - def redirect(uri) - r = Rack::Response.new - - if options[:iframe] - r.write("") - else - r.write("Redirecting to #{uri}...") - r.redirect(uri) - end - - r.finish - end - - def user_info; {} end - - def fail!(message_key, exception = nil) - self.env['omniauth.error'] = exception - self.env['omniauth.error.type'] = message_key.to_sym - self.env['omniauth.error.strategy'] = self - - OmniAuth.config.on_failure.call(self.env) - end - end -end diff --git a/oa-core/lib/omniauth/test.rb b/oa-core/lib/omniauth/test.rb deleted file mode 100644 index bce2561..0000000 --- a/oa-core/lib/omniauth/test.rb +++ /dev/null @@ -1,12 +0,0 @@ -module OmniAuth - - # Support for testing OmniAuth strategies. - module Test - - autoload :PhonySession, 'omniauth/test/phony_session' - autoload :StrategyMacros, 'omniauth/test/strategy_macros' - autoload :StrategyTestCase, 'omniauth/test/strategy_test_case' - - end - -end diff --git a/oa-core/lib/omniauth/test/phony_session.rb b/oa-core/lib/omniauth/test/phony_session.rb deleted file mode 100644 index 768fa74..0000000 --- a/oa-core/lib/omniauth/test/phony_session.rb +++ /dev/null @@ -1,8 +0,0 @@ -class OmniAuth::Test::PhonySession - def initialize(app); @app = app end - def call(env) - @session ||= (env['rack.session'] || {}) - env['rack.session'] = @session - @app.call(env) - end -end diff --git a/oa-core/lib/omniauth/test/strategy_macros.rb b/oa-core/lib/omniauth/test/strategy_macros.rb deleted file mode 100644 index 2d897e0..0000000 --- a/oa-core/lib/omniauth/test/strategy_macros.rb +++ /dev/null @@ -1,34 +0,0 @@ -module OmniAuth - - module Test - - module StrategyMacros - - def sets_an_auth_hash - it 'should set an auth hash' do - last_request.env['omniauth.auth'].should be_kind_of(Hash) - end - end - - def sets_provider_to(provider) - it "should set the provider to #{provider}" do - (last_request.env['omniauth.auth'] || {})['provider'].should == provider - end - end - - def sets_uid_to(uid) - it "should set the UID to #{uid}" do - (last_request.env['omniauth.auth'] || {})['uid'].should == uid - end - end - - def sets_user_info_to(user_info) - it "should set the user_info to #{user_info}" do - (last_request.env['omniauth.auth'] || {})['user_info'].should == user_info - end - end - end - - end - -end diff --git a/oa-core/lib/omniauth/test/strategy_test_case.rb b/oa-core/lib/omniauth/test/strategy_test_case.rb deleted file mode 100644 index 9dc67e8..0000000 --- a/oa-core/lib/omniauth/test/strategy_test_case.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'rack' -require 'omniauth/test' - -module OmniAuth - - module Test - - # Support for testing OmniAuth strategies. - # - # @example Usage - # class MyStrategyTest < Test::Unit::TestCase - # include OmniAuth::Test::StrategyTestCase - # def strategy - # # return the parameters to a Rack::Builder map call: - # [MyStrategy.new, :some, :configuration, :options => 'here'] - # end - # setup do - # post '/auth/my_strategy/callback', :user => { 'name' => 'Dylan', 'id' => '445' } - # end - # end - module StrategyTestCase - - def app - strat = self.strategy - resp = self.app_response - Rack::Builder.new { - use OmniAuth::Test::PhonySession - use *strat - run lambda {|env| [404, {'Content-Type' => 'text/plain'}, [resp || env.key?('omniauth.auth').to_s]] } - }.to_app - end - - def app_response - nil - end - - def session - last_request.env['rack.session'] - end - - def strategy - raise NotImplementedError.new('Including specs must define #strategy') - end - - end - - end - -end diff --git a/oa-core/lib/omniauth/version.rb b/oa-core/lib/omniauth/version.rb deleted file mode 100644 index 9f980b0..0000000 --- a/oa-core/lib/omniauth/version.rb +++ /dev/null @@ -1,19 +0,0 @@ -module OmniAuth - module Version - unless defined?(::OmniAuth::Version::MAJOR) - MAJOR = 0 - end - unless defined?(::OmniAuth::Version::MINOR) - MINOR = 3 - end - unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 - end - unless defined?(::OmniAuth::Version::PRE) - PRE = "rc3" - end - unless defined?(::OmniAuth::Version::STRING) - STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') - end - end -end diff --git a/oa-core/spec/omniauth/builder_spec.rb b/oa-core/spec/omniauth/builder_spec.rb deleted file mode 100644 index c45c3c2..0000000 --- a/oa-core/spec/omniauth/builder_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require File.expand_path('../../spec_helper', __FILE__) - -describe OmniAuth::Builder do - describe '#provider' do - it 'should translate a symbol to a constant' do - OmniAuth::Strategies.should_receive(:const_get).with('MyStrategy').and_return(Class.new) - OmniAuth::Builder.new(nil) do - provider :my_strategy - end - end - - it 'should also just accept a class' do - class ::ExampleClass; end - - lambda{ OmniAuth::Builder.new(nil) do - provider ::ExampleClass - end }.should_not raise_error - end - end -end diff --git a/oa-core/spec/omniauth/core_spec.rb b/oa-core/spec/omniauth/core_spec.rb deleted file mode 100644 index dffa5ce..0000000 --- a/oa-core/spec/omniauth/core_spec.rb +++ /dev/null @@ -1,79 +0,0 @@ -require File.expand_path('../../spec_helper', __FILE__) - -describe OmniAuth do - describe '.strategies' do - it 'should increase when a new strategy is made' do - lambda{ class ExampleStrategy - include OmniAuth::Strategy - end }.should change(OmniAuth.strategies, :size).by(1) - OmniAuth.strategies.last.should == ExampleStrategy - end - end - - context 'configuration' do - it 'should be callable from .configure' do - OmniAuth.configure do |c| - c.should be_kind_of(OmniAuth::Configuration) - end - end - - before do - @old_path_prefix = OmniAuth.config.path_prefix - @old_on_failure = OmniAuth.config.on_failure - end - - after do - OmniAuth.configure do |config| - config.path_prefix = @old_path_prefix - config.on_failure = @old_on_failure - end - end - - it 'should be able to set the path' do - OmniAuth.configure do |config| - config.path_prefix = '/awesome' - end - - OmniAuth.config.path_prefix.should == '/awesome' - end - - it 'should be able to set the on_failure rack app' do - OmniAuth.configure do |config| - config.on_failure do - 'yoyo' - end - end - - OmniAuth.config.on_failure.call.should == 'yoyo' - end - end - - describe '::Utils' do - describe '.deep_merge' do - it 'should combine hashes' do - OmniAuth::Utils.deep_merge({'abc' => {'def' => 123}}, {'abc' => {'foo' => 'bar'}}).should == { - 'abc' => {'def' => 123, 'foo' => 'bar'} - } - end - end - - describe '.camelize' do - it 'should work on normal cases' do - { - 'some_word' => 'SomeWord', - 'AnotherWord' => 'AnotherWord', - 'one' => 'One', - 'three_words_now' => 'ThreeWordsNow' - }.each_pair{ |k,v| OmniAuth::Utils.camelize(k).should == v } - end - - it 'should work in special cases' do - { - 'oauth' => "OAuth", - 'openid' => 'OpenID', - 'open_id' => 'OpenID' - }.each_pair{ |k,v| OmniAuth::Utils.camelize(k).should == v} - end - end - end -end diff --git a/oa-core/spec/omniauth/strategy_spec.rb b/oa-core/spec/omniauth/strategy_spec.rb deleted file mode 100644 index 7137f6b..0000000 --- a/oa-core/spec/omniauth/strategy_spec.rb +++ /dev/null @@ -1,397 +0,0 @@ -require File.expand_path('../../spec_helper', __FILE__) - -class ExampleStrategy - include OmniAuth::Strategy - def call(env); self.call!(env) end - attr_reader :last_env - def request_phase - @fail = fail!(options[:failure]) if options[:failure] - @last_env = env - return @fail if @fail - raise "Request Phase" - end - def callback_phase - @fail = fail!(options[:failure]) if options[:failure] - @last_env = env - return @fail if @fail - raise "Callback Phase" - end -end - -def make_env(path = '/auth/test', props = {}) - { - 'REQUEST_METHOD' => 'GET', - 'PATH_INFO' => path, - 'rack.session' => {}, - 'rack.input' => StringIO.new('test=true') - }.merge(props) -end - -describe OmniAuth::Strategy do - let(:app){ lambda{|env| [404, {}, ['Awesome']]}} - describe '#initialize' do - context 'options extraction' do - it 'should be the last argument if the last argument is a Hash' do - ExampleStrategy.new(app, 'test', :abc => 123).options[:abc].should == 123 - end - - it 'should be a blank hash if none are provided' do - ExampleStrategy.new(app, 'test').options.should == {} - end - end - end - - describe '#full_host' do - let(:strategy){ ExampleStrategy.new(app, 'test', {}) } - it 'should not freak out if there is a pipe in the URL' do - strategy.call!(make_env('/whatever', 'rack.url_scheme' => 'http', 'SERVER_NAME' => 'facebook.lame', 'QUERY_STRING' => 'code=asofibasf|asoidnasd', 'SCRIPT_NAME' => '', 'SERVER_PORT' => 80)) - lambda{ strategy.full_host }.should_not raise_error - end - end - - describe '#call' do - let(:strategy){ ExampleStrategy.new(app, 'test', @options) } - - context 'omniauth.origin' do - it 'should be set on the request phase' do - lambda{ strategy.call(make_env('/auth/test', 'HTTP_REFERER' => 'http://example.com/origin')) }.should raise_error("Request Phase") - strategy.last_env['rack.session']['omniauth.origin'].should == 'http://example.com/origin' - end - - it 'should be turned into an env variable on the callback phase' do - lambda{ strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => 'http://example.com/origin'})) }.should raise_error("Callback Phase") - strategy.last_env['omniauth.origin'].should == 'http://example.com/origin' - end - - it 'should set from the params if provided' do - lambda{ strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'origin=/foo')) }.should raise_error('Request Phase') - strategy.last_env['rack.session']['omniauth.origin'].should == '/foo' - end - - it 'should be set on the failure env' do - OmniAuth.config.should_receive(:on_failure).and_return(lambda{|env| env}) - @options = {:failure => :forced_fail} - strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => '/awesome'})) - end - - context "with script_name" do - it 'should be set on the request phase, containing full path' do - env = {'HTTP_REFERER' => 'http://example.com/sub_uri/origin', 'SCRIPT_NAME' => '/sub_uri' } - lambda{ strategy.call(make_env('/auth/test', env)) }.should raise_error("Request Phase") - strategy.last_env['rack.session']['omniauth.origin'].should == 'http://example.com/sub_uri/origin' - end - - it 'should be turned into an env variable on the callback phase, containing full path' do - env = { - 'rack.session' => {'omniauth.origin' => 'http://example.com/sub_uri/origin'}, - 'SCRIPT_NAME' => '/sub_uri' - } - - lambda{ strategy.call(make_env('/auth/test/callback', env)) }.should raise_error("Callback Phase") - strategy.last_env['omniauth.origin'].should == 'http://example.com/sub_uri/origin' - end - - end - end - - context 'default paths' do - it 'should use the default request path' do - lambda{ strategy.call(make_env) }.should raise_error("Request Phase") - end - - it 'should be case insensitive on request path' do - lambda{ strategy.call(make_env('/AUTH/Test'))}.should raise_error("Request Phase") - end - - it 'should be case insensitive on callback path' do - lambda{ strategy.call(make_env('/AUTH/TeSt/CaLlBAck'))}.should raise_error("Callback Phase") - end - - it 'should use the default callback path' do - lambda{ strategy.call(make_env('/auth/test/callback')) }.should raise_error("Callback Phase") - end - - it 'should strip trailing spaces on request' do - lambda{ strategy.call(make_env('/auth/test/')) }.should raise_error("Request Phase") - end - - it 'should strip trailing spaces on callback' do - lambda{ strategy.call(make_env('/auth/test/callback/')) }.should raise_error("Callback Phase") - end - - context 'callback_url' do - it 'uses the default callback_path' do - strategy.should_receive(:full_host).and_return('http://example.com') - - lambda{ strategy.call(make_env) }.should raise_error("Request Phase") - - strategy.callback_url.should == 'http://example.com/auth/test/callback' - end - - it 'preserves the query parameters' do - strategy.stub(:full_host).and_return('http://example.com') - begin - strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5')) - rescue RuntimeError; end - strategy.callback_url.should == 'http://example.com/auth/test/callback?id=5' - end - - it 'consider script name' do - strategy.stub(:full_host).and_return('http://example.com') - begin - strategy.call(make_env('/auth/test', 'SCRIPT_NAME' => '/sub_uri')) - rescue RuntimeError; end - strategy.callback_url.should == 'http://example.com/sub_uri/auth/test/callback' - end - end - end - - context 'pre-request call through' do - subject { ExampleStrategy.new(app, 'test') } - let(:app){ lambda{|env| env['omniauth.boom'] = true; [env['test.status'] || 404, {}, ['Whatev']] } } - it 'should be able to modify the env on the fly before the request_phase' do - lambda{ subject.call(make_env) }.should raise_error("Request Phase") - subject.response.status.should == 404 - subject.last_env.should be_key('omniauth.boom') - end - - it 'should call through to the app instead if a non-404 response is received' do - lambda{ subject.call(make_env('/auth/test', 'test.status' => 200)) }.should_not raise_error - subject.response.body.should == ['Whatev'] - end - end - - context 'custom paths' do - it 'should use a custom request_path if one is provided' do - @options = {:request_path => '/awesome'} - lambda{ strategy.call(make_env('/awesome')) }.should raise_error("Request Phase") - end - - it 'should use a custom callback_path if one is provided' do - @options = {:callback_path => '/radical'} - lambda{ strategy.call(make_env('/radical')) }.should raise_error("Callback Phase") - end - - context 'callback_url' do - it 'uses a custom callback_path if one is provided' do - @options = {:callback_path => '/radical'} - strategy.should_receive(:full_host).and_return('http://example.com') - - lambda{ strategy.call(make_env('/radical')) }.should raise_error("Callback Phase") - - strategy.callback_url.should == 'http://example.com/radical' - end - - it 'preserves the query parameters' do - @options = {:callback_path => '/radical'} - strategy.stub(:full_host).and_return('http://example.com') - begin - strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5')) - rescue RuntimeError; end - strategy.callback_url.should == 'http://example.com/radical?id=5' - end - end - end - - context 'custom prefix' do - before do - @options = {:path_prefix => '/wowzers'} - end - - it 'should use a custom prefix for request' do - lambda{ strategy.call(make_env('/wowzers/test')) }.should raise_error("Request Phase") - end - - it 'should use a custom prefix for callback' do - lambda{ strategy.call(make_env('/wowzers/test/callback')) }.should raise_error("Callback Phase") - end - - context 'callback_url' do - it 'uses a custom prefix' do - strategy.should_receive(:full_host).and_return('http://example.com') - - lambda{ strategy.call(make_env('/wowzers/test')) }.should raise_error("Request Phase") - - strategy.callback_url.should == 'http://example.com/wowzers/test/callback' - end - - it 'preserves the query parameters' do - strategy.stub(:full_host).and_return('http://example.com') - begin - strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5')) - rescue RuntimeError; end - strategy.callback_url.should == 'http://example.com/wowzers/test/callback?id=5' - end - end - end - - context 'request method restriction' do - before do - OmniAuth.config.allowed_request_methods = [:post] - end - - it 'should not allow a request method of the wrong type' do - lambda{ strategy.call(make_env)}.should_not raise_error - end - - it 'should allow a request method of the correct type' do - lambda{ strategy.call(make_env('/auth/test', 'REQUEST_METHOD' => 'POST'))}.should raise_error("Request Phase") - end - - after do - OmniAuth.config.allowed_request_methods = [:get, :post] - end - end - - context 'receiving an OPTIONS request' do - shared_examples_for "an OPTIONS request" do - it 'should respond with 200' do - response[0].should == 200 - end - - it 'should set the Allow header properly' do - response[1]['Allow'].should == "GET, POST" - end - end - - context 'to the request path' do - let(:response) { strategy.call(make_env('/auth/test', 'REQUEST_METHOD' => 'OPTIONS')) } - it_should_behave_like 'an OPTIONS request' - end - - context 'to the request path' do - let(:response) { strategy.call(make_env('/auth/test/callback', 'REQUEST_METHOD' => 'OPTIONS')) } - it_should_behave_like 'an OPTIONS request' - end - - context 'to some other path' do - it 'should not short-circuit the request' do - env = make_env('/other', 'REQUEST_METHOD' => 'OPTIONS') - strategy.call(env).should == app.call(env) - end - end - end - - context 'test mode' do - before do - OmniAuth.config.test_mode = true - end - - it 'should short circuit the request phase entirely' do - response = strategy.call(make_env) - response[0].should == 302 - response[1]['Location'].should == '/auth/test/callback' - end - - it 'should be case insensitive on request path' do - strategy.call(make_env('/AUTH/Test'))[0].should == 302 - end - - it 'should respect SCRIPT_NAME (a.k.a. BaseURI)' do - response = strategy.call(make_env('/auth/test', 'SCRIPT_NAME' => '/sub_uri')) - response[1]['Location'].should == '/sub_uri/auth/test/callback' - end - - it 'should be case insensitive on callback path' do - strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).should == strategy.call(make_env('/auth/test/callback')) - end - - it 'should maintain query string parameters' do - response = strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'cheese=stilton')) - response[1]['Location'].should == '/auth/test/callback?cheese=stilton' - end - - it 'should not short circuit requests outside of authentication' do - strategy.call(make_env('/')).should == app.call(make_env('/')) - end - - it 'should respond with the default hash if none is set' do - strategy.call make_env('/auth/test/callback') - strategy.env['omniauth.auth']['uid'].should == '1234' - end - - it 'should respond with a provider-specific hash if one is set' do - OmniAuth.config.mock_auth[:test] = { - 'uid' => 'abc' - } - - strategy.call make_env('/auth/test/callback') - strategy.env['omniauth.auth']['uid'].should == 'abc' - end - - it 'should simulate login failure if mocked data is set as a symbol' do - OmniAuth.config.mock_auth[:test] = :invalid_credentials - - strategy.call make_env('/auth/test/callback') - strategy.env['omniauth.error.type'].should == :invalid_credentials - end - - it 'should set omniauth.origin on the request phase' do - strategy.call(make_env('/auth/test', 'HTTP_REFERER' => 'http://example.com/origin')) - strategy.env['rack.session']['omniauth.origin'].should == 'http://example.com/origin' - end - - it 'should set omniauth.origin from the params if provided' do - strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'origin=/foo')) - strategy.env['rack.session']['omniauth.origin'].should == '/foo' - end - - it 'should turn omniauth.origin into an env variable on the callback phase' do - OmniAuth.config.mock_auth[:test] = {} - - strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.origin' => 'http://example.com/origin'})) - strategy.env['omniauth.origin'].should == 'http://example.com/origin' - end - end - - context 'custom full_host' do - it 'should be the string when a string is there' do - OmniAuth.config.full_host = 'my.host.com' - strategy.full_host.should == 'my.host.com' - end - - it 'should run the proc with the env when it is a proc' do - OmniAuth.config.full_host = Proc.new{|env| env['HOST']} - strategy.call(make_env('/auth/test', 'HOST' => 'my.host.net')) - strategy.full_host.should == 'my.host.net' - end - end - end - - context 'setup phase' do - context 'when options[:setup] = true' do - let(:strategy){ ExampleStrategy.new(app, 'test', :setup => true) } - let(:app){lambda{|env| env['omniauth.strategy'].options[:awesome] = 'sauce' if env['PATH_INFO'] == '/auth/test/setup'; [404, {}, 'Awesome'] }} - - it 'should call through to /auth/:provider/setup' do - strategy.call(make_env('/auth/test')) - strategy.options[:awesome].should == 'sauce' - end - - it 'should not call through on a non-omniauth endpoint' do - strategy.call(make_env('/somewhere/else')) - strategy.options[:awesome].should_not == 'sauce' - end - end - - context 'when options[:setup] is an app' do - let(:setup_proc) do - Proc.new do |env| - env['omniauth.strategy'].options[:awesome] = 'sauce' - end - end - - let(:strategy){ ExampleStrategy.new(app, 'test', :setup => setup_proc) } - - it 'should not call the app on a non-omniauth endpoint' do - strategy.call(make_env('/somehwere/else')) - strategy.options[:awesome].should_not == 'sauce' - end - - it 'should call the rack app' do - strategy.call(make_env('/auth/test')) - strategy.options[:awesome].should == 'sauce' - end - end - end -end diff --git a/oa-core/spec/spec_helper.rb b/oa-core/spec/spec_helper.rb deleted file mode 100644 index c9f3ecf..0000000 --- a/oa-core/spec/spec_helper.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'simplecov' -SimpleCov.start -require 'rspec' -require 'rack/test' -require 'omniauth/core' -require 'omniauth/test' - -RSpec.configure do |config| - config.include Rack::Test::Methods - config.extend OmniAuth::Test::StrategyMacros, :type => :strategy -end - diff --git a/oa-enterprise/.gemtest b/oa-enterprise/.gemtest deleted file mode 100644 index e69de29..0000000 diff --git a/oa-enterprise/.rspec b/oa-enterprise/.rspec deleted file mode 100644 index bb259fe..0000000 --- a/oa-enterprise/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---color ---format=nested ---backtrace diff --git a/oa-enterprise/.yardopts b/oa-enterprise/.yardopts deleted file mode 100644 index 7a69ee4..0000000 --- a/oa-enterprise/.yardopts +++ /dev/null @@ -1,4 +0,0 @@ ---markup markdown ---markup-provider maruku -- -LICENSE diff --git a/oa-enterprise/Gemfile b/oa-enterprise/Gemfile deleted file mode 100644 index 73a8e19..0000000 --- a/oa-enterprise/Gemfile +++ /dev/null @@ -1,11 +0,0 @@ -require File.expand_path('../lib/omniauth/version', __FILE__) - -source 'http://rubygems.org' - -gem 'oa-core', OmniAuth::Version::STRING, :path => '../oa-core' - -platforms :jruby do - gem 'jruby-openssl', '~> 0.7' -end - -gemspec diff --git a/oa-enterprise/LICENSE b/oa-enterprise/LICENSE deleted file mode 100644 index 811fa0e..0000000 --- a/oa-enterprise/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/oa-enterprise/README.rdoc b/oa-enterprise/README.rdoc deleted file mode 100644 index bbd7976..0000000 --- a/oa-enterprise/README.rdoc +++ /dev/null @@ -1,115 +0,0 @@ -= OmniAuth::Enterprise - -OmniAuth strategies for use in your intranet. - -== Installation - -To get just enterprise functionality: - - gem install oa-enterprise - -For the full auth suite: - - gem install omniauth - -== CAS - -Use the CAS strategy as a middleware in your application: - - require 'omniauth/enterprise' - - use OmniAuth::Strategies::CAS, :server => 'http://cas.mycompany.com/cas' - -Then simply direct users to '/auth/cas' to have them sign in via your company's CAS server. -See OmniAuth::Strategies::CAS::Configuration for more configuration options. - -== LDAP - -Use the LDAP strategy as a middleware in your application: - - require 'omniauth/enterprise' - use OmniAuth::Strategies::LDAP, - :title => "My LDAP", - :host => '10.101.10.1', - :port => 389, - :method => :plain, - :base => 'dc=intridea, dc=com', - :uid => 'sAMAccountName', - :name_proc => Proc.new {|name| name.gsub(/@.*$/,'')} - :bind_dn => 'default_bind_dn' - :password => 'password' - -All of the listed options are required, with the exception of :name_proc, :bind_dn, and :password -Allowed values of :method are: :plain, :ssl, :tls. - -:bind_dn and :password are used to perform the initial binding if user lookup is -needed. If the user lookup returns result, the DN attribute from the result set is used -to perform the final binding. This is needed only when the LDAP server requires -DN to be used for binding and you may only want user to using email or username -in the login form. - -:uid is the LDAP attribute name for the user name in the login form. typically -AD would be 'sAMAccountName' or 'UserPrincipalName', while OpenLDAP is 'uid'. -You can also use 'dn', if your user choose the put in the dn in the login form -(but usually is too long for user to remember or know). - -:name_proc allows you to match the user name entered with the format of the -:uid attributes. For example, value of 'sAMAccountName' in AD contains only the -windows user name. If your user prefers use email to login, a name_proc as -above will trim the email string down to just the windows name. In summary, -:name_proc helps you to fill the gap between the authentication and user lookup -process. - -:try_sasl and :sasl_mechanisms are optional. Use them to initialize a SASL -connection to server. Allowed values are 'DIGEST-MD5' and 'GSS-SPNEGO'. If you -are not familiar with these authentication methods, please just avoid them. - -Direct users to '/auth/ldap' to have them authenticated via your -company's LDAP server. - -== SAML - -Use the SAML strategy as a middleware in your application: - - require 'omniauth/enterprise' - use OmniAuth::Strategies::SAML, - :assertion_consumer_service_url => "consumer_service_url", - :issuer => "issuer", - :idp_sso_target_url => "idp_sso_target_url", - :idp_cert_fingerprint => "E7:91:B2:E1:...", - :name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" - -:assertion_consumer_service_url - The URL at which the SAML assertion should be received. - -:issuer - The name of your application. Some identity providers might need this to establish the - identity of the service provider requesting the login. - -:idp_sso_target_url - The URL to which the authentication request should be sent. This would be on the identity provider. - -:idp_cert_fingerprint - The certificate fingerprint, e.g. "90:CC:16:F0:8D:A6:D1:C6:BB:27:2D:BA:93:80:1A:1F:16:8E:4E:08". - This is provided from the identity provider when setting up the relationship. - -:name_identifier_format - Describes the format of the username required by this application. - If you need the email address, use "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress". - See http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf section 8.3 for - other options. Note that the identity provider might not support all options. - - -== Multiple Strategies - -If you're using multiple strategies together, use OmniAuth's Builder. That's -what it's there for: - - require 'omniauth/enterprise' - require 'omniauth/oauth' # for Campfire - require 'openid/store/filesystem' - - use OmniAuth::Builder do - provider :cas, :server => 'http://cas.mycompany.com/cas' - provider :campfire - end diff --git a/oa-enterprise/Rakefile b/oa-enterprise/Rakefile deleted file mode 100644 index 69797fc..0000000 --- a/oa-enterprise/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require 'bundler' -Bundler::GemHelper.install_tasks -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) -task :default => :spec -task :test => :spec diff --git a/oa-enterprise/lib/oa-enterprise.rb b/oa-enterprise/lib/oa-enterprise.rb deleted file mode 100644 index 0c48616..0000000 --- a/oa-enterprise/lib/oa-enterprise.rb +++ /dev/null @@ -1 +0,0 @@ -require 'omniauth/enterprise' diff --git a/oa-enterprise/lib/omniauth/enterprise.rb b/oa-enterprise/lib/omniauth/enterprise.rb deleted file mode 100644 index 77321f2..0000000 --- a/oa-enterprise/lib/omniauth/enterprise.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'omniauth/core' - -module OmniAuth - module Strategies - autoload :CAS, 'omniauth/strategies/cas' - autoload :LDAP, 'omniauth/strategies/ldap' - autoload :SAML, 'omniauth/strategies/saml' - end -end diff --git a/oa-enterprise/lib/omniauth/strategies/cas.rb b/oa-enterprise/lib/omniauth/strategies/cas.rb deleted file mode 100644 index 2bacc8c..0000000 --- a/oa-enterprise/lib/omniauth/strategies/cas.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'omniauth/enterprise' - -module OmniAuth - module Strategies - class CAS - include OmniAuth::Strategy - - autoload :Configuration, 'omniauth/strategies/cas/configuration' - autoload :ServiceTicketValidator, 'omniauth/strategies/cas/service_ticket_validator' - - def initialize(app, options = {}, &block) - super(app, options[:name] || :cas, options.dup, &block) - @configuration = OmniAuth::Strategies::CAS::Configuration.new(options) - end - - protected - - def request_phase - [ - 302, - { - 'Location' => @configuration.login_url(callback_url), - 'Content-Type' => 'text/plain' - }, - ["You are being redirected to CAS for sign-in."] - ] - end - - def callback_phase - ticket = request.params['ticket'] - return fail!(:no_ticket, 'No CAS Ticket') unless ticket - validator = ServiceTicketValidator.new(@configuration, callback_url, ticket) - @user_info = validator.user_info - return fail!(:invalid_ticket, 'Invalid CAS Ticket') if @user_info.nil? || @user_info.empty? - super - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'uid' => @user_info.delete('user'), - 'extra' => @user_info - }) - end - - end - end -end diff --git a/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb b/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb deleted file mode 100644 index 7d5a174..0000000 --- a/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb +++ /dev/null @@ -1,98 +0,0 @@ -require 'rack' - -module OmniAuth - module Strategies - class CAS - class Configuration - - DEFAULT_LOGIN_URL = "%s/login" - - DEFAULT_SERVICE_VALIDATE_URL = "%s/serviceValidate" - - # @param [Hash] params configuration options - # @option params [String, nil] :cas_server the CAS server root URL; probably something like - # `http://cas.mycompany.com` or `http://cas.mycompany.com/cas`; optional. - # @option params [String, nil] :cas_login_url (:cas_server + '/login') the URL to which to - # redirect for logins; options if `:cas_server` is specified, - # required otherwise. - # @option params [String, nil] :cas_service_validate_url (:cas_server + '/serviceValidate') the - # URL to use for validating service tickets; optional if `:cas_server` is - # specified, requred otherwise. - # @option params [Boolean, nil] :disable_ssl_verification disable verification for SSL cert, - # helpful when you developing with a fake cert. - def initialize(params) - parse_params params - end - - # Build a CAS login URL from +service+. - # - # @param [String] service the service (a.k.a. return-to) URL - # - # @return [String] a URL like `http://cas.mycompany.com/login?service=...` - def login_url(service) - append_service @login_url, service - end - - # Build a service-validation URL from +service+ and +ticket+. - # If +service+ has a ticket param, first remove it. URL-encode - # +service+ and add it and the +ticket+ as paraemters to the - # CAS serviceValidate URL. - # - # @param [String] service the service (a.k.a. return-to) URL - # @param [String] ticket the ticket to validate - # - # @return [String] a URL like `http://cas.mycompany.com/serviceValidate?service=...&ticket=...` - def service_validate_url(service, ticket) - service = service.sub(/[?&]ticket=[^?&]+/, '') - url = append_service(@service_validate_url, service) - url << '&ticket=' << Rack::Utils.escape(ticket) - end - - def disable_ssl_verification? - @disable_ssl_verification - end - - private - - def parse_params(params) - if params[:cas_server].nil? && params[:cas_login_url].nil? - raise ArgumentError.new(":cas_server or :cas_login_url MUST be provided") - end - @login_url = params[:cas_login_url] - @login_url ||= DEFAULT_LOGIN_URL % params[:cas_server] - validate_is_url 'login URL', @login_url - - if params[:cas_server].nil? && params[:cas_service_validate_url].nil? - raise ArgumentError.new(":cas_server or :cas_service_validate_url MUST be provided") - end - @service_validate_url = params[:cas_service_validate_url] - @service_validate_url ||= DEFAULT_SERVICE_VALIDATE_URL % params[:cas_server] - validate_is_url 'service-validate URL', @service_validate_url - - @disable_ssl_verification = params[:disable_ssl_verification] - end - - IS_NOT_URL_ERROR_MESSAGE = "%s is not a valid URL" - - def validate_is_url(name, possibly_a_url) - url = URI.parse(possibly_a_url) rescue nil - raise ArgumentError.new(IS_NOT_URL_ERROR_MESSAGE % name) unless url.kind_of?(URI::HTTP) - end - - # Adds +service+ as an URL-escaped parameter to +base+. - # - # @param [String] base the base URL - # @param [String] service the service (a.k.a. return-to) URL. - # - # @return [String] the new joined URL. - def append_service(base, service) - result = base.dup - result << (result.include?('?') ? '&' : '?') - result << 'service=' - result << Rack::Utils.escape(service) - end - - end - end - end -end diff --git a/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb b/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb deleted file mode 100644 index 0a1249a..0000000 --- a/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'net/http' -require 'net/https' -require 'nokogiri' - -module OmniAuth - module Strategies - class CAS - class ServiceTicketValidator - - VALIDATION_REQUEST_HEADERS = { 'Accept' => '*/*' } - - # Build a validator from a +configuration+, a - # +return_to+ URL, and a +ticket+. - # - # @param [OmniAuth::Strategies::CAS::Configuration] configuration the CAS configuration - # @param [String] return_to_url the URL of this CAS client service - # @param [String] ticket the service ticket to validate - def initialize(configuration, return_to_url, ticket) - @configuration = configuration - @uri = URI.parse(@configuration.service_validate_url(return_to_url, ticket)) - end - - # Request validation of the ticket from the CAS server's - # serviceValidate (CAS 2.0) function. - # - # Swallows all XML parsing errors (and returns +nil+ in those cases). - # - # @return [Hash, nil] a user information hash if the response is valid; +nil+ otherwise. - # - # @raise any connection errors encountered. - def user_info - parse_user_info(find_authentication_success(get_service_response_body)) - end - - private - - # turns an `` node into a Hash; - # returns nil if given nil - def parse_user_info(node) - return nil if node.nil? - hash = {} - node.children.each do |e| - unless e.kind_of?(Nokogiri::XML::Text) || - e.name == 'cas:proxies' || - e.name == 'proxies' - # There are no child elements - if e.element_children.count == 0 - hash[e.name.sub(/^cas:/, '')] = e.content - elsif e.element_children.count - hash[e.name.sub(/^cas:/, '')] = [] if hash[e.name.sub(/^cas:/, '')].nil? - hash[e.name.sub(/^cas:/, '')].push parse_user_info e - end - end - end - hash - end - - # finds an `` node in - # a `` body if present; returns nil - # if the passed body is nil or if there is no such node. - def find_authentication_success(body) - return nil if body.nil? || body == '' - begin - doc = Nokogiri::XML(body) - begin - doc.xpath('/cas:serviceResponse/cas:authenticationSuccess') - rescue Nokogiri::XML::XPath::SyntaxError - doc.xpath('/serviceResponse/authenticationSuccess') - end - rescue Nokogiri::XML::XPath::SyntaxError - nil - end - end - - # retrieves the `` XML from the CAS server - def get_service_response_body - result = '' - http = ::Net::HTTP.new(@uri.host, @uri.port) - http.use_ssl = @uri.port == 443 || @uri.instance_of?(URI::HTTPS) - http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl? && @configuration.disable_ssl_verification? - http.start do |c| - response = c.get "#{@uri.path}?#{@uri.query}", VALIDATION_REQUEST_HEADERS.dup - result = response.body - end - result - end - - end - end - end -end diff --git a/oa-enterprise/lib/omniauth/strategies/ldap.rb b/oa-enterprise/lib/omniauth/strategies/ldap.rb deleted file mode 100644 index e65f7f9..0000000 --- a/oa-enterprise/lib/omniauth/strategies/ldap.rb +++ /dev/null @@ -1,124 +0,0 @@ -require 'omniauth/enterprise' -require 'net/ldap' -require 'sasl/base' -require 'sasl' - -module OmniAuth - module Strategies - class LDAP - include OmniAuth::Strategy - - autoload :Adaptor, 'omniauth/strategies/ldap/adaptor' - @@config = { - 'name' => 'cn', - 'first_name' => 'givenName', - 'last_name' => 'sn', - 'email' => ['mail', "email", 'userPrincipalName'], - 'phone' => ['telephoneNumber', 'homePhone', 'facsimileTelephoneNumber'], - 'mobile_number' => ['mobile', 'mobileTelephoneNumber'], - 'nickname' => ['uid', 'userid', 'sAMAccountName'], - 'title' => 'title', - 'location' => {"%0, %1, %2, %3 %4" => [['address', 'postalAddress', 'homePostalAddress', 'street', 'streetAddress'], ['l'], ['st'],['co'],['postOfficeBox']]}, - 'uid' => 'dn', - 'url' => ['wwwhomepage'], - 'image' => 'jpegPhoto', - 'description' => 'description' - } - - # Initialize the LDAP Middleware - # - # @param [Rack Application] app Standard Rack middleware argument. - # @option options [String, 'LDAP Authentication'] :title A title for the authentication form. - def initialize(app, options = {}, &block) - super(app, options[:name] || :ldap, options.dup, &block) - @name_proc = (@options.delete(:name_proc) || Proc.new {|name| name}) - @adaptor = OmniAuth::Strategies::LDAP::Adaptor.new(options) - end - - protected - - def request_phase - if env['REQUEST_METHOD'] == 'GET' - get_credentials - else - session['omniauth.ldap'] = {'username' => request['username'], 'password' => request['password']} - redirect callback_path - end - end - - def get_credentials - OmniAuth::Form.build(:title => (options[:title] || "LDAP Authentication")) do - text_field 'Login', 'username' - password_field 'Password', 'password' - end.to_response - end - - def callback_phase - begin - creds = session['omniauth.ldap'] - session.delete 'omniauth.ldap' - @ldap_user_info = {} - begin - (@adaptor.bind(:allow_anonymous => true) unless @adaptor.bound?) - rescue Exception => e - puts "failed to bind with the default credentials: " + e.message - end - @ldap_user_info = @adaptor.search(:filter => Net::LDAP::Filter.eq(@adaptor.uid, @name_proc.call(creds['username'])),:limit => 1) if @adaptor.bound? - bind_dn = creds['username'] - bind_dn = @ldap_user_info[:dn].to_a.first if @ldap_user_info[:dn] - @adaptor.bind(:bind_dn => bind_dn, :password => creds['password']) - @ldap_user_info = @adaptor.search(:filter => Net::LDAP::Filter.eq(@adaptor.uid, @name_proc.call(creds['username'])),:limit => 1) if @ldap_user_info.empty? - @user_info = self.class.map_user(@@config, @ldap_user_info) - - @env['omniauth.auth'] = auth_hash - - rescue Exception => e - return fail!(:invalid_credentials, e) - end - call_app! - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'uid' => @user_info["uid"], - 'user_info' => @user_info, - 'extra' => @ldap_user_info - }) - end - - # Use only first value if the field is returned as an Array - def self.get_ldap_field(ldap_object, field) - value = ldap_object[field.to_sym] - case value - when Array - value.first.to_s - else - value.to_s - end - end - - def self.map_user(mapper, object) - user = {} - mapper.each do |key, value| - case value - when String - user[key] = get_ldap_field(object, value.downcase) if object[value.downcase.to_sym] - when Array - value.each {|v| (user[key] = get_ldap_field(object, v.downcase); break;) if object[v.downcase.to_sym]} - when Hash - value.map do |key1, value1| - pattern = key1.dup - value1.each_with_index do |v,i| - part = ''; - v.each {|v1| (part = get_ldap_field(object, v1.downcase); break;) if object[v1.downcase.to_sym]} - pattern.gsub!("%#{i}",part||'') - end - user[key] = pattern - end - end - end - user - end - end - end -end diff --git a/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb b/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb deleted file mode 100644 index 3f53345..0000000 --- a/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb +++ /dev/null @@ -1,276 +0,0 @@ -#this code boughts pieces from activeldap and net-ldap - -require 'rack' -require 'net/ldap' -require 'net/ntlm' -require 'uri' - -module OmniAuth - module Strategies - class LDAP - class Adaptor - class LdapError < StandardError; end - class ConfigurationError < StandardError; end - class AuthenticationError < StandardError; end - class ConnectionError < StandardError; end - - VALID_ADAPTER_CONFIGURATION_KEYS = [:host, :port, :method, :bind_dn, :password, :try_sasl, :sasl_mechanisms, :uid, :base, :allow_anonymous] - - MUST_HAVE_KEYS = [:host, :port, :method, :uid, :base] - - METHOD = { - :ssl => :simple_tls, - :tls => :start_tls, - :plain => nil, - } - - attr_accessor :bind_dn, :password - attr_reader :connection, :uid, :base - - def initialize(configuration={}) - @connection = nil - @disconnected = false - @bound = false - @configuration = configuration.dup - @configuration[:allow_anonymous] ||= false - @logger = @configuration.delete(:logger) - message = [] - MUST_HAVE_KEYS.each do |name| - message << name if configuration[name].nil? - end - raise ArgumentError.new(message.join(",") +" MUST be provided") unless message.empty? - VALID_ADAPTER_CONFIGURATION_KEYS.each do |name| - instance_variable_set("@#{name}", configuration[name]) - end - end - - def connect(options={}) - host = options[:host] || @host - method = ensure_method(options[:method] || @method || :plain) - port = options[:port] || @port || ensure_port(method) - @disconnected = false - @bound = false - @bind_tried = false - - config = { - :host => host, - :port => port, - } - - config[:encryption] = {:method => method} if method - - @connection, @uri, @with_start_tls = begin - uri = construct_uri(host, port, method == :simple_tls) - with_start_tls = method == :start_tls - [Net::LDAP::Connection.new(config), uri, with_start_tls] - rescue Net::LDAP::LdapError - raise ConnectionError, $!.message - end - end - - def unbind(options={}) - @connection.close # Net::LDAP doesn't implement unbind. - end - - def bind(options={}) - connect(options) unless connecting? - begin - @bind_tried = true - - bind_dn = (options[:bind_dn] || @bind_dn).to_s - try_sasl = options.has_key?(:try_sasl) ? options[:try_sasl] : @try_sasl - if options.has_key?(:allow_anonymous) - allow_anonymous = options[:allow_anonymous] - else - allow_anonymous = @allow_anonymous - end - # Rough bind loop: - # Attempt 1: SASL if available - # Attempt 2: SIMPLE with credentials if password block - # Attempt 3: SIMPLE ANONYMOUS if 1 and 2 fail and allow anonymous is set to true - if try_sasl and sasl_bind(bind_dn, options) - puts "bound with sasl" - elsif simple_bind(bind_dn, options) - puts "bound with simple" - elsif allow_anonymous and bind_as_anonymous(options) - puts "bound as anonymous" - else - message = yield if block_given? - message ||= ('All authentication methods for %s exhausted.') % target - raise AuthenticationError, message - end - @bound = true - rescue Net::LDAP::LdapError - raise AuthenticationError, $!.message - end - end - - def disconnect!(options={}) - unbind(options) - @connection = @uri = @with_start_tls = nil - @disconnected = true - end - - def rebind(options={}) - unbind(options) if bound? - connect(options) - end - - def connecting? - !@connection.nil? and !@disconnected - end - - def bound? - connecting? and @bound - end - - def search(options={}, &block) - base = options[:base] || @base - filter = options[:filter] - limit = options[:limit] - - args = { - :base => base, - :filter => filter, - :size => limit - } - - attributes = {} - execute(:search, args) do |entry| - entry.attribute_names.each do |name| - attributes[name] = entry[name] - end - end - attributes - end - - private - - def execute(method, *args, &block) - result = @connection.send(method, *args, &block) - message = nil - - if result.is_a?(Hash) - message = result[:errorMessage] - result = result[:resultCode] - end - - unless result.zero? - message = [Net::LDAP.result2string(result), message].compact.join(": ") - raise LdapError, message - end - end - - def ensure_port(method) - if method == :ssl - URI::LDAPS::DEFAULT_PORT - else - URI::LDAP::DEFAULT_PORT - end - end - - def prepare_connection(options) - end - - def ensure_method(method) - method ||= "plain" - normalized_method = method.to_s.downcase.to_sym - return METHOD[normalized_method] if METHOD.has_key?(normalized_method) - - available_methods = METHOD.keys.collect {|m| m.inspect}.join(", ") - format = "%s is not one of the available connect methods: %s" - raise ConfigurationError, format % [method.inspect, available_methods] - end - - def sasl_bind(bind_dn, options={}) - sasl_mechanisms = options[:sasl_mechanisms] || @sasl_mechanisms - sasl_mechanisms.each do |mechanism| - begin - normalized_mechanism = mechanism.downcase.gsub(/-/, '_') - sasl_bind_setup = "sasl_bind_setup_#{normalized_mechanism}" - next unless respond_to?(sasl_bind_setup, true) - initial_credential, challenge_response = send(sasl_bind_setup, bind_dn, options) - - args = { - :method => :sasl, - :initial_credential => initial_credential, - :mechanism => mechanism, - :challenge_response => challenge_response, - } - - info = { - :name => "bind: SASL", :dn => bind_dn, :mechanism => mechanism, - } - - execute(:bind, args) - return true - - rescue Exception => e - puts e.message - end - end - false - end - - def sasl_bind_setup_digest_md5(bind_dn, options) - initial_credential = "" - challenge_response = Proc.new do |cred| - pref = SASL::Preferences.new :digest_uri => "ldap/#{@host}", :username => bind_dn, :has_password? => true, :password => options[:password]||@password - sasl = SASL.new("DIGEST-MD5", pref) - response = sasl.receive("challenge", cred) - response[1] - end - [initial_credential, challenge_response] - end - - def sasl_bind_setup_gss_spnego(bind_dn, options) - user,psw = [bind_dn, options[:password]||@password] - raise LdapError.new( "invalid binding information" ) unless (user && psw) - - nego = proc {|challenge| - t2_msg = Net::NTLM::Message.parse( challenge ) - user, domain = user.split('\\').reverse - t2_msg.target_name = Net::NTLM::encode_utf16le(domain) if domain - t3_msg = t2_msg.response( {:user => user, :password => psw}, {:ntlmv2 => true} ) - t3_msg.serialize - } - [Net::NTLM::Message::Type1.new.serialize, nego] - end - - def simple_bind(bind_dn, options={}) - args = { - :method => :simple, - :username => bind_dn, - :password => (options[:password]||@password).to_s, - } - begin - raise AuthenticationError if args[:password] == "" - execute(:bind, args) - true - rescue Exception - false - end - end - - def bind_as_anonymous(options={}) - execute(:bind, {:method => :anonymous}) - true - end - - def construct_uri(host, port, ssl) - protocol = ssl ? "ldaps" : "ldap" - URI.parse("#{protocol}://#{host}:#{port}").to_s - end - - def target - return nil if @uri.nil? - if @with_start_tls - "#{@uri}(StartTLS)" - else - @uri - end - end - end - end - end -end diff --git a/oa-enterprise/lib/omniauth/strategies/saml.rb b/oa-enterprise/lib/omniauth/strategies/saml.rb deleted file mode 100644 index 4238b11..0000000 --- a/oa-enterprise/lib/omniauth/strategies/saml.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'omniauth/enterprise' - -module OmniAuth - module Strategies - class SAML - include OmniAuth::Strategy - autoload :AuthRequest, 'omniauth/strategies/saml/auth_request' - autoload :AuthResponse, 'omniauth/strategies/saml/auth_response' - autoload :ValidationError, 'omniauth/strategies/saml/validation_error' - autoload :XMLSecurity, 'omniauth/strategies/saml/xml_security' - - @@settings = {} - - def initialize(app, options={}) - super(app, :saml) - @@settings = { - :assertion_consumer_service_url => options[:assertion_consumer_service_url], - :issuer => options[:issuer], - :idp_sso_target_url => options[:idp_sso_target_url], - :idp_cert_fingerprint => options[:idp_cert_fingerprint], - :name_identifier_format => options[:name_identifier_format] || "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" - } - end - - def request_phase - request = OmniAuth::Strategies::SAML::AuthRequest.new - redirect(request.create(@@settings)) - end - - def callback_phase - begin - response = OmniAuth::Strategies::SAML::AuthResponse.new(request.params['SAMLResponse']) - response.settings = @@settings - @name_id = response.name_id - return fail!(:invalid_ticket, 'Invalid SAML Ticket') if @name_id.nil? || @name_id.empty? - super - rescue ArgumentError => e - fail!(:invalid_ticket, 'Invalid SAML Response') - end - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'uid' => @name_id - }) - end - - end - end -end diff --git a/oa-enterprise/lib/omniauth/strategies/saml/auth_request.rb b/oa-enterprise/lib/omniauth/strategies/saml/auth_request.rb deleted file mode 100644 index 8129f5f..0000000 --- a/oa-enterprise/lib/omniauth/strategies/saml/auth_request.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "base64" -require "uuid" -require "zlib" -require "cgi" - -module OmniAuth - module Strategies - class SAML - class AuthRequest - - def create(settings, params = {}) - uuid = "_" + UUID.new.generate - time = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ") - - request = - "" + - "#{settings[:issuer]}\n" + - "\n" + - "" + - "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport\n" + - "" - - deflated_request = Zlib::Deflate.deflate(request, 9)[2..-5] - base64_request = Base64.encode64(deflated_request) - encoded_request = CGI.escape(base64_request) - request_params = "?SAMLRequest=" + encoded_request - - params.each_pair do |key, value| - request_params << "&#{key}=#{CGI.escape(value.to_s)}" - end - - settings[:idp_sso_target_url] + request_params - end - - end - end - end -end \ No newline at end of file diff --git a/oa-enterprise/lib/omniauth/strategies/saml/auth_response.rb b/oa-enterprise/lib/omniauth/strategies/saml/auth_response.rb deleted file mode 100644 index d63f39d..0000000 --- a/oa-enterprise/lib/omniauth/strategies/saml/auth_response.rb +++ /dev/null @@ -1,141 +0,0 @@ -require "time" - -module OmniAuth - module Strategies - class SAML - class AuthResponse - - ASSERTION = "urn:oasis:names:tc:SAML:2.0:assertion" - PROTOCOL = "urn:oasis:names:tc:SAML:2.0:protocol" - DSIG = "http://www.w3.org/2000/09/xmldsig#" - - attr_accessor :options, :response, :document, :settings - - def initialize(response, options = {}) - raise ArgumentError.new("Response cannot be nil") if response.nil? - self.options = options - self.response = response - self.document = OmniAuth::Strategies::SAML::XMLSecurity::SignedDocument.new(Base64.decode64(response)) - end - - def is_valid? - validate(soft = true) - end - - def validate! - validate(soft = false) - end - - # The value of the user identifier as designated by the initialization request response - def name_id - @name_id ||= begin - node = REXML::XPath.first(document, "/p:Response/a:Assertion[@ID='#{document.signed_element_id[1,document.signed_element_id.size]}']/a:Subject/a:NameID", { "p" => PROTOCOL, "a" => ASSERTION }) - node ||= REXML::XPath.first(document, "/p:Response[@ID='#{document.signed_element_id[1,document.signed_element_id.size]}']/a:Assertion/a:Subject/a:NameID", { "p" => PROTOCOL, "a" => ASSERTION }) - node.nil? ? nil : node.text - end - end - - # A hash of alle the attributes with the response. Assuming there is only one value for each key - def attributes - @attr_statements ||= begin - result = {} - - stmt_element = REXML::XPath.first(document, "/p:Response/a:Assertion/a:AttributeStatement", { "p" => PROTOCOL, "a" => ASSERTION }) - return {} if stmt_element.nil? - - stmt_element.elements.each do |attr_element| - name = attr_element.attributes["Name"] - value = attr_element.elements.first.text - - result[name] = value - end - - result.keys.each do |key| - result[key.intern] = result[key] - end - - result - end - end - - # When this user session should expire at latest - def session_expires_at - @expires_at ||= begin - node = REXML::XPath.first(document, "/p:Response/a:Assertion/a:AuthnStatement", { "p" => PROTOCOL, "a" => ASSERTION }) - parse_time(node, "SessionNotOnOrAfter") - end - end - - # Conditions (if any) for the assertion to run - def conditions - @conditions ||= begin - REXML::XPath.first(document, "/p:Response/a:Assertion[@ID='#{document.signed_element_id[1,document.signed_element_id.size]}']/a:Conditions", { "p" => PROTOCOL, "a" => ASSERTION }) - end - end - - private - - def validation_error(message) - raise OmniAuth::Strategies::SAML::ValidationError.new(message) - end - - def validate(soft = true) - validate_response_state(soft) && - validate_conditions(soft) && - document.validate(get_fingerprint, soft) - end - - def validate_response_state(soft = true) - if response.empty? - return soft ? false : validation_error("Blank response") - end - - if settings.nil? - return soft ? false : validation_error("No settings on response") - end - - if settings.idp_cert_fingerprint.nil? && settings.idp_cert.nil? - return soft ? false : validation_error("No fingerprint or certificate on settings") - end - - true - end - - def get_fingerprint - if settings.idp_cert - cert = OpenSSL::X509::Certificate.new(settings.idp_cert) - Digest::SHA1.hexdigest(cert.to_der).upcase.scan(/../).join(":") - else - settings.idp_cert_fingerprint - end - end - - def validate_conditions(soft = true) - return true if conditions.nil? - return true if options[:skip_conditions] - - if not_before = parse_time(conditions, "NotBefore") - if Time.now.utc < not_before - return soft ? false : validation_error("Current time is earlier than NotBefore condition") - end - end - - if not_on_or_after = parse_time(conditions, "NotOnOrAfter") - if Time.now.utc >= not_on_or_after - return soft ? false : validation_error("Current time is on or after NotOnOrAfter condition") - end - end - - true - end - - def parse_time(node, attribute) - if node && node.attributes[attribute] - Time.parse(node.attributes[attribute]) - end - end - - end - end - end -end \ No newline at end of file diff --git a/oa-enterprise/lib/omniauth/strategies/saml/validation_error.rb b/oa-enterprise/lib/omniauth/strategies/saml/validation_error.rb deleted file mode 100644 index f62f763..0000000 --- a/oa-enterprise/lib/omniauth/strategies/saml/validation_error.rb +++ /dev/null @@ -1,8 +0,0 @@ -module OmniAuth - module Strategies - class SAML - class ValidationError < Exception - end - end - end -end \ No newline at end of file diff --git a/oa-enterprise/lib/omniauth/strategies/saml/xml_security.rb b/oa-enterprise/lib/omniauth/strategies/saml/xml_security.rb deleted file mode 100644 index 06974c8..0000000 --- a/oa-enterprise/lib/omniauth/strategies/saml/xml_security.rb +++ /dev/null @@ -1,126 +0,0 @@ -# The contents of this file are subject to the terms -# of the Common Development and Distribution License -# (the License). You may not use this file except in -# compliance with the License. -# -# You can obtain a copy of the License at -# https://opensso.dev.java.net/public/CDDLv1.0.html or -# opensso/legal/CDDLv1.0.txt -# See the License for the specific language governing -# permission and limitations under the License. -# -# When distributing Covered Code, include this CDDL -# Header Notice in each file and include the License file -# at opensso/legal/CDDLv1.0.txt. -# If applicable, add the following below the CDDL Header, -# with the fields enclosed by brackets [] replaced by -# your own identifying information: -# "Portions Copyrighted [year] [name of copyright owner]" -# -# $Id: xml_sec.rb,v 1.6 2007/10/24 00:28:41 todddd Exp $ -# -# Copyright 2007 Sun Microsystems Inc. All Rights Reserved -# Portions Copyrighted 2007 Todd W Saxton. - -require 'rubygems' -require "rexml/document" -require "rexml/xpath" -require "openssl" -require "xmlcanonicalizer" -require "digest/sha1" - -module OmniAuth - module Strategies - class SAML - - module XMLSecurity - - class SignedDocument < REXML::Document - DSIG = "http://www.w3.org/2000/09/xmldsig#" - - attr_accessor :signed_element_id - - def initialize(response) - super(response) - extract_signed_element_id - end - - def validate(idp_cert_fingerprint, soft = true) - # get cert from response - base64_cert = self.elements["//ds:X509Certificate"].text - cert_text = Base64.decode64(base64_cert) - cert = OpenSSL::X509::Certificate.new(cert_text) - - # check cert matches registered idp cert - fingerprint = Digest::SHA1.hexdigest(cert.to_der) - - if fingerprint != idp_cert_fingerprint.gsub(/[^a-zA-Z0-9]/,"").downcase - return soft ? false : (raise OmniAuth::Strategies::SAML::ValidationError.new("Fingerprint mismatch")) - end - - validate_doc(base64_cert, soft) - end - - def validate_doc(base64_cert, soft = true) - # validate references - - # check for inclusive namespaces - - inclusive_namespaces = [] - inclusive_namespace_element = REXML::XPath.first(self, "//ec:InclusiveNamespaces") - - if inclusive_namespace_element - prefix_list = inclusive_namespace_element.attributes.get_attribute('PrefixList').value - inclusive_namespaces = prefix_list.split(" ") - end - - # remove signature node - sig_element = REXML::XPath.first(self, "//ds:Signature", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}) - sig_element.remove - - # check digests - REXML::XPath.each(sig_element, "//ds:Reference", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}) do |ref| - uri = ref.attributes.get_attribute("URI").value - hashed_element = REXML::XPath.first(self, "//[@ID='#{uri[1,uri.size]}']") - canoner = XML::Util::XmlCanonicalizer.new(false, true) - canoner.inclusive_namespaces = inclusive_namespaces if canoner.respond_to?(:inclusive_namespaces) && !inclusive_namespaces.empty? - canon_hashed_element = canoner.canonicalize(hashed_element) - hash = Base64.encode64(Digest::SHA1.digest(canon_hashed_element)).chomp - digest_value = REXML::XPath.first(ref, "//ds:DigestValue", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}).text - - if hash != digest_value - return soft ? false : (raise OmniAuth::Strategies::SAML::ValidationError.new("Digest mismatch")) - end - end - - # verify signature - canoner = XML::Util::XmlCanonicalizer.new(false, true) - signed_info_element = REXML::XPath.first(sig_element, "//ds:SignedInfo", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}) - canon_string = canoner.canonicalize(signed_info_element) - - base64_signature = REXML::XPath.first(sig_element, "//ds:SignatureValue", {"ds"=>"http://www.w3.org/2000/09/xmldsig#"}).text - signature = Base64.decode64(base64_signature) - - # get certificate object - cert_text = Base64.decode64(base64_cert) - cert = OpenSSL::X509::Certificate.new(cert_text) - - if !cert.public_key.verify(OpenSSL::Digest::SHA1.new, signature, canon_string) - return soft ? false : (raise OmniAuth::Strategies::SAML::ValidationError.new("Key validation error")) - end - - return true - end - - private - - def extract_signed_element_id - reference_element = REXML::XPath.first(self, "//ds:Signature/ds:SignedInfo/ds:Reference", {"ds"=>DSIG}) - self.signed_element_id = reference_element.attribute("URI").value unless reference_element.nil? - end - end - end - - end - end -end \ No newline at end of file diff --git a/oa-enterprise/lib/omniauth/version.rb b/oa-enterprise/lib/omniauth/version.rb deleted file mode 100644 index 9f980b0..0000000 --- a/oa-enterprise/lib/omniauth/version.rb +++ /dev/null @@ -1,19 +0,0 @@ -module OmniAuth - module Version - unless defined?(::OmniAuth::Version::MAJOR) - MAJOR = 0 - end - unless defined?(::OmniAuth::Version::MINOR) - MINOR = 3 - end - unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 - end - unless defined?(::OmniAuth::Version::PRE) - PRE = "rc3" - end - unless defined?(::OmniAuth::Version::STRING) - STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') - end - end -end diff --git a/oa-enterprise/oa-enterprise.gemspec b/oa-enterprise/oa-enterprise.gemspec deleted file mode 100644 index 0eb4c47..0000000 --- a/oa-enterprise/oa-enterprise.gemspec +++ /dev/null @@ -1,31 +0,0 @@ -# encoding: utf-8 -require File.expand_path('../lib/omniauth/version', __FILE__) - -Gem::Specification.new do |gem| - gem.add_dependency 'addressable', '~> 2.2.6' - gem.add_dependency 'net-ldap', '~> 0.2.2' - gem.add_dependency 'nokogiri', '~> 1.5.0' - gem.add_dependency 'oa-core', OmniAuth::Version::STRING - gem.add_dependency 'pyu-ruby-sasl', '~> 0.0.3.1' - gem.add_dependency 'rubyntlm', '~> 0.1.1' - gem.add_dependency 'uuid' - gem.add_dependency 'XMLCanonicalizer', '~> 1.0.1' - gem.add_development_dependency 'rack-test', '~> 0.5' - gem.add_development_dependency 'rake', '~> 0.8' - gem.add_development_dependency 'rdiscount', '~> 1.6' - gem.add_development_dependency 'rspec', '~> 2.5' - gem.add_development_dependency 'simplecov', '~> 0.4' - gem.add_development_dependency 'webmock', '~> 1.7' - gem.add_development_dependency 'yard', '~> 0.7' - gem.authors = ['James A. Rosen', 'Ping Yu', 'Michael Bleigh', 'Erik Michaels-Ober', 'Raecoo Cao'] - gem.description = %q{Enterprise strategies for OmniAuth.} - gem.email = ['james.a.rosen@gmail.com', 'ping@intridea.com', 'michael@intridea.com', 'sferik@gmail.com', 'raecoo@intridea.com'] - gem.files = `git ls-files`.split("\n") - gem.homepage = 'http://github.com/intridea/omniauth' - gem.name = 'oa-enterprise' - gem.require_paths = ['lib'] - gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version= - gem.summary = gem.description - gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - gem.version = OmniAuth::Version::STRING -end diff --git a/oa-enterprise/spec/fixtures/cas_failure.xml b/oa-enterprise/spec/fixtures/cas_failure.xml deleted file mode 100644 index f8238a1..0000000 --- a/oa-enterprise/spec/fixtures/cas_failure.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/oa-enterprise/spec/fixtures/cas_success.xml b/oa-enterprise/spec/fixtures/cas_success.xml deleted file mode 100644 index 5a621ff..0000000 --- a/oa-enterprise/spec/fixtures/cas_success.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - psegel - Peter - Segel - 2004-07-13 - - diff --git a/oa-enterprise/spec/omniauth/strategies/cas_spec.rb b/oa-enterprise/spec/omniauth/strategies/cas_spec.rb deleted file mode 100644 index a43bda5..0000000 --- a/oa-enterprise/spec/omniauth/strategies/cas_spec.rb +++ /dev/null @@ -1,94 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'cgi' - -describe OmniAuth::Strategies::CAS, :type => :strategy do - - include OmniAuth::Test::StrategyTestCase - - def strategy - @cas_server ||= 'https://cas.example.org' - [OmniAuth::Strategies::CAS, {:cas_server => @cas_server}] - end - - describe 'GET /auth/cas' do - before do - get '/auth/cas' - end - - it 'should redirect to the CAS server' do - last_response.should be_redirect - return_to = CGI.escape(last_request.url + '/callback') - last_response.headers['Location'].should == @cas_server + '/login?service=' + return_to - end - end - - describe 'GET /auth/cas/callback without a ticket' do - before do - get '/auth/cas/callback' - end - it 'should fail' do - last_response.should be_redirect - last_response.headers['Location'].should =~ /no_ticket/ - end - end - - describe 'GET /auth/cas/callback with an invalid ticket' do - before do - stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=9391d/). - to_return(:body => File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'cas_failure.xml'))) - get '/auth/cas/callback?ticket=9391d' - end - it 'should fail' do - last_response.should be_redirect - last_response.headers['Location'].should =~ /invalid_ticket/ - end - end - - describe 'GET /auth/cas/callback with a valid ticket' do - before do - stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=593af/). - with { |request| @request_uri = request.uri.to_s }. - to_return(:body => File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'cas_success.xml'))) - get '/auth/cas/callback?ticket=593af' - end - - it 'should strip the ticket parameter from the callback URL before sending it to the CAS server' do - @request_uri.scan('ticket=').length.should == 1 - end - - sets_an_auth_hash - sets_provider_to 'cas' - sets_uid_to 'psegel' - - it 'should set additional user information' do - extra = (last_request.env['omniauth.auth'] || {})['extra'] - extra.should be_kind_of(Hash) - extra['first-name'].should == 'Peter' - extra['last-name'].should == 'Segel' - extra['hire-date'].should == '2004-07-13' - end - - it 'should call through to the master app' do - last_response.body.should == 'true' - end - end - - unless RUBY_VERSION =~ /^1\.8\.\d$/ - describe 'GET /auth/cas/callback with a valid ticket and gzipped response from the server on ruby >1.8' do - before do - zipped = StringIO.new - Zlib::GzipWriter.wrap zipped do |io| - io.write File.read(File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'cas_success.xml')) - end - stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=593af/). - with { |request| @request_uri = request.uri.to_s }. - to_return(:body => zipped.string, :headers => { 'content-encoding' => 'gzip' }) - get '/auth/cas/callback?ticket=593af' - end - - it 'should call through to the master app when response is gzipped' do - last_response.body.should == 'true' - end - end - end -end diff --git a/oa-enterprise/spec/omniauth/strategies/ldap_spec.rb b/oa-enterprise/spec/omniauth/strategies/ldap_spec.rb deleted file mode 100644 index 0517fbd..0000000 --- a/oa-enterprise/spec/omniauth/strategies/ldap_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'cgi' - -describe OmniAuth::Strategies::LDAP, :type => :strategy do - - include OmniAuth::Test::StrategyTestCase - - def strategy - @ldap_server ||= 'ldap.example.org' - [OmniAuth::Strategies::LDAP, { - :host => @ldap_server, - :port => 636, - :method => :ssl, - :uid => 'jeremyf', - :base => 'o="University of OmniAuth", st=Sublime, c=RubyNation', - }] - end - - describe 'GET /auth/ldap' do - before do - get '/auth/ldap' - end - - # TODO: Add checks that page has authentication form; I attempted - # to use `should have_tag` but that was not working. - it 'should get authentication page' do - last_response.status.should == 200 - end - end - - describe 'POST /auth/ldap' do - before do - post '/auth/ldap', {:username => 'jeremy', :password => 'valid_password' } - end - - it 'should redirect us to /auth/ldap/callback' do - last_response.should be_redirect - last_response.location.should == '/auth/ldap/callback' - end - end -end \ No newline at end of file diff --git a/oa-enterprise/spec/omniauth/strategies/saml_spec.rb b/oa-enterprise/spec/omniauth/strategies/saml_spec.rb deleted file mode 100644 index 2bd1776..0000000 --- a/oa-enterprise/spec/omniauth/strategies/saml_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe OmniAuth::Strategies::SAML, :type => :strategy do - - include OmniAuth::Test::StrategyTestCase - - def strategy - [OmniAuth::Strategies::SAML, { - :assertion_consumer_service_url => "http://consumer.service.url/auth/saml/callback", - :issuer => "https://saml.issuer.url/issuers/29490", - :idp_sso_target_url => "https://idp.sso.target_url/signon/29490", - :idp_cert_fingerprint => "E7:91:B2:E1:4C:65:2C:49:F3:33:74:0A:58:5A:7E:55:F7:15:7A:33", - :name_identifier_format => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" - }] - end - - describe 'GET /auth/saml' do - before do - get '/auth/saml' - end - - it 'should get authentication page' do - last_response.should be_redirect - end - end - - describe 'POST /auth/saml/callback' do - - it 'should raise ArgumentError exception without the SAMLResponse parameter' do - post '/auth/saml/callback' - last_response.should be_redirect - last_response.location.should == '/auth/failure?message=invalid_ticket' - end - - end - -end \ No newline at end of file diff --git a/oa-enterprise/spec/spec_helper.rb b/oa-enterprise/spec/spec_helper.rb deleted file mode 100644 index 45bfc33..0000000 --- a/oa-enterprise/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'simplecov' -SimpleCov.start -require 'rspec' -require 'rack/test' -require 'webmock/rspec' -require 'omniauth/core' -require 'omniauth/test' -require 'omniauth/enterprise' - -RSpec.configure do |config| - config.include WebMock::API - config.include Rack::Test::Methods - config.extend OmniAuth::Test::StrategyMacros, :type => :strategy -end diff --git a/oa-identity/.rspec b/oa-identity/.rspec deleted file mode 100644 index f7ddb05..0000000 --- a/oa-identity/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---format=nested ---colour diff --git a/oa-identity/README.markdown b/oa-identity/README.markdown deleted file mode 100644 index b7c88a0..0000000 --- a/oa-identity/README.markdown +++ /dev/null @@ -1,90 +0,0 @@ -# OmniAuth Identity - -The OmniAuth Identity gem provides a way for applications to utilize a -traditional login/password based authentication system without the need -to give up the simple authentication flow provided by OmniAuth. Identity -is designed on purpose to be as featureless as possible: it provides the -basic construct for user management and then gets out of the way. - -## Usage - -You use `oa-identity` just like you would any other OmniAuth provider: as a -Rack middleware. The basic setup for a email/password authentication would -look something like this: - - use OmniAuth::Builder do - provider :identity, :fields => [:email] - end - -Next, you need to create a model (called `Identity by default`) that will be -able to persist the information provided by the user. Luckily for you, there -are pre-built models for popular ORMs that make this dead simple. You just -need to subclass the relevant class: - - class Identity < OmniAuth::Identity::Models::ActiveRecord - # Add whatever you like! - end - -Adapters are provided for `ActiveRecord` and `MongoMapper` and are -autoloaded on request (but not loaded by default so no dependencies are -injected). - -Once you've got an Identity persistence model and the strategy up and -running, you can point users to `/auth/identity` and it will request -that they log in or give them the opportunity to sign up for an account. -Once they have authenticated with their identity, OmniAuth will call -through to `/auth/identity/callback` with the same kinds of information -it would had the user authenticated through an external provider. -Simple! - -## Custom Auth Model - -To use a class other than the default, specify the :model option to a -different class. - - use OmniAuth::Builder do - provider :identity, :fields => [:email], :model => MyCustomClass - end - -## Customizing Registration Failure - -To use your own custom registration form, create a form that POSTs to -'/auth/identity/register' with 'password', 'password_confirmation', and your -other fields. - - <%= form_tag '/auth/identity/register' do |f| %> -

Create an Account

- <%= text_field_tag :email %> - <%= password_field_tag, :password %> - <%= password_field_tag, :password_confirmation %> - <%= submit_tag %> - <% end %> - -Beware not to nest your form parameters within a namespace. This strategy -looks for the form parameters at the top level of the post params. If you are -using [simple\_form](https://github.com/plataformatec/simple_form), then you -can avoid the params nesting by specifying :input_html. - - <%= simple_form_for @identity, :url => '/auth/identity/register' do |f| %> -

Create an Account

- <%# specify :input_html to avoid params nesting %> - <%= f.input :email, :input_html => {:name => 'email'} %> - <%= f.input :password, :as => 'password', :input_html => {:name => 'password'} %> - <%= f.input :password_confirmation, :label => "Confirm Password", :as => 'password', :input_html => {:name => 'password_confirmation'} %> - - <% end %> - -Next you'll need to let OmniAuth know what action to call when a registration -fails. In your OmniAuth configuration, specify any valid rack endpoint in the -:on_failed_registration option. - - use OmniAuth::Builder do - provider :identity, - :fields => [:email], - :on_failed_registration => UsersController.action(:new) - end - -For more information on rack endpoints, check out [this -introduction](http://library.edgecase.com/Rails/2011/01/04/rails-routing-and-rack-endpoints.html) -and -[ActionController::Metal](http://rubydoc.info/docs/rails/ActionController/Metal) diff --git a/oa-identity/Rakefile b/oa-identity/Rakefile deleted file mode 100644 index f7205cb..0000000 --- a/oa-identity/Rakefile +++ /dev/null @@ -1,8 +0,0 @@ -require 'bundler' -Bundler::GemHelper.install_tasks - -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec -task :test => :spec diff --git a/oa-identity/lib/oa-identity.rb b/oa-identity/lib/oa-identity.rb deleted file mode 100644 index 2a3ab8f..0000000 --- a/oa-identity/lib/oa-identity.rb +++ /dev/null @@ -1 +0,0 @@ -require 'omniauth/identity' diff --git a/oa-identity/lib/omniauth/identity.rb b/oa-identity/lib/omniauth/identity.rb deleted file mode 100644 index 1a15411..0000000 --- a/oa-identity/lib/omniauth/identity.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'omniauth/core' - -module OmniAuth - module Strategies - autoload :Identity, 'omniauth/strategies/identity' - end - - module Identity - autoload :Model, 'omniauth/identity/model' - autoload :SecurePassword, 'omniauth/identity/secure_password' - module Models - autoload :ActiveRecord, 'omniauth/identity/models/active_record' - # autoload :MongoMapper, 'omniauth/identity/models/mongo_mapper' - # autoload :Mongoid, 'omniauth/identity/models/mongoid' - end - end -end diff --git a/oa-identity/lib/omniauth/identity/model.rb b/oa-identity/lib/omniauth/identity/model.rb deleted file mode 100644 index 8f3a5d6..0000000 --- a/oa-identity/lib/omniauth/identity/model.rb +++ /dev/null @@ -1,119 +0,0 @@ -module OmniAuth - module Identity - # This module provides an includable interface for implementing the - # necessary API for OmniAuth Identity to properly locate identities - # and provide all necessary information. All methods marked as - # abstract must be implemented in the including class for things to - # work properly. - module Model - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - # Locate an identity given its unique login key. - # - # @abstract - # @param [String] key The unique login key. - # @return [Model] An instance of the identity model class. - def locate(key) - raise NotImplementedError - end - - # Authenticate a user with the given key and password. - # - # @param [String] key The unique login key provided for a given identity. - # @param [String] password The presumed password for the identity. - # @return [Model] An instance of the identity model class. - def authenticate(key, password) - instance = locate(key) - return false unless instance - instance.authenticate(password) - end - - # Used to set or retrieve the method that will be used to get - # and set the user-supplied authentication key. - # @return [String] The method name. - def auth_key(method = false) - @auth_key = method.to_s unless method == false - @auth_key = nil if @auth_key == '' - - @auth_key || 'email' - end - end - - # Returns self if the provided password is correct, false - # otherwise. - # - # @abstract - # @param [String] password The password to check. - # @return [self or false] Self if authenticated, false if not. - def authenticate(password) - raise NotImplementedError - end - - SCHEMA_ATTRIBUTES = %w(name email nickname first_name last_name location description image phone) - # A hash of as much of the standard OmniAuth schema as is stored - # in this particular model. By default, this will call instance - # methods for each of the attributes it needs in turn, ignoring - # any for which `#respond_to?` is `false`. - # - # If `first_name`, `nickname`, and/or `last_name` is provided but - # `name` is not, it will be automatically calculated. - # - # @return [Hash] A string-keyed hash of user information. - def user_info - info = SCHEMA_ATTRIBUTES.inject({}) do |hash,attribute| - hash[attribute] = send(attribute) if respond_to?(attribute) - hash - end - - info['name'] ||= [info['first_name'], info['last_name']].join(' ').strip if info['first_name'] || info['last_name'] - info['name'] ||= info['nickname'] - - info - end - - # An identifying string that must be globally unique to the - # application. Defaults to stringifying the `id` method. - # - # @return [String] An identifier string unique to this identity. - def uid - if respond_to?('id') - return nil if self.id.nil? - self.id.to_s - else - raise NotImplementedError - end - end - - # Used to retrieve the user-supplied authentication key (e.g. a - # username or email). Determined using the class method of the same name, - # defaults to `:email`. - # - # @return [String] An identifying string that will be entered by - # users upon sign in. - def auth_key - if respond_to?(self.class.auth_key) - send(self.class.auth_key) - else - raise NotImplementedError - end - end - - # Used to set the user-supplied authentication key (e.g. a - # username or email. Determined using the `.auth_key` class - # method. - # - # @param [String] value The value to which the auth key should be - # set. - def auth_key=(value) - if respond_to?(self.class.auth_key + '=') - send(self.class.auth_key + '=', value) - else - raise NotImplementedError - end - end - end - end -end diff --git a/oa-identity/lib/omniauth/identity/models/active_record.rb b/oa-identity/lib/omniauth/identity/models/active_record.rb deleted file mode 100644 index 3bfbe9c..0000000 --- a/oa-identity/lib/omniauth/identity/models/active_record.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'active_record' - -module OmniAuth - module Identity - module Models - class ActiveRecord < ::ActiveRecord::Base - include OmniAuth::Identity::Model - include OmniAuth::Identity::SecurePassword - - self.abstract_class = true - has_secure_password - - def self.auth_key=(key) - super - validates_uniqueness_of key, :case_sensitive => false - end - - def self.locate(key) - where(auth_key => key).first - end - end - end - end -end diff --git a/oa-identity/lib/omniauth/identity/secure_password.rb b/oa-identity/lib/omniauth/identity/secure_password.rb deleted file mode 100644 index b420747..0000000 --- a/oa-identity/lib/omniauth/identity/secure_password.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'bcrypt' - -module OmniAuth - module Identity - # This is taken directly from Rails 3.1 code and is used if - # the version of ActiveModel that's being used does not - # include SecurePassword. The only difference is that instead of - # using ActiveSupport::Concern, it checks to see if there is already - # a has_secure_password method. - module SecurePassword - def self.included(base) - unless base.respond_to?(:has_secure_password) - base.extend ClassMethods - end - end - - module ClassMethods - # Adds methods to set and authenticate against a BCrypt password. - # This mechanism requires you to have a password_digest attribute. - # - # Validations for presence of password, confirmation of password (using - # a "password_confirmation" attribute) are automatically added. - # You can add more validations by hand if need be. - # - # Example using Active Record (which automatically includes ActiveModel::SecurePassword): - # - # # Schema: User(name:string, password_digest:string) - # class User < ActiveRecord::Base - # has_secure_password - # end - # - # user = User.new(:name => "david", :password => "", :password_confirmation => "nomatch") - # user.save # => false, password required - # user.password = "mUc3m00RsqyRe" - # user.save # => false, confirmation doesn't match - # user.password_confirmation = "mUc3m00RsqyRe" - # user.save # => true - # user.authenticate("notright") # => false - # user.authenticate("mUc3m00RsqyRe") # => user - # User.find_by_name("david").try(:authenticate, "notright") # => nil - # User.find_by_name("david").try(:authenticate, "mUc3m00RsqyRe") # => user - def has_secure_password - attr_reader :password - - validates_confirmation_of :password - validates_presence_of :password_digest - - include InstanceMethodsOnActivation - - if respond_to?(:attributes_protected_by_default) - def self.attributes_protected_by_default - super + ['password_digest'] - end - end - end - end - - module InstanceMethodsOnActivation - # Returns self if the password is correct, otherwise false. - def authenticate(unencrypted_password) - if BCrypt::Password.new(password_digest) == unencrypted_password - self - else - false - end - end - - # Encrypts the password into the password_digest attribute. - def password=(unencrypted_password) - @password = unencrypted_password - unless unencrypted_password.blank? - self.password_digest = BCrypt::Password.create(unencrypted_password) - end - end - end - end - end -end diff --git a/oa-identity/lib/omniauth/strategies/identity.rb b/oa-identity/lib/omniauth/strategies/identity.rb deleted file mode 100644 index 680b844..0000000 --- a/oa-identity/lib/omniauth/strategies/identity.rb +++ /dev/null @@ -1,96 +0,0 @@ -module OmniAuth - module Strategies - # The identity strategy allows you to provide simple internal - # user authentication using the same process flow that you - # use for external OmniAuth providers. - class Identity - include OmniAuth::Strategy - - # @option options [Symbol] :name The name you want to use for this strategy. - # @option options [Symbol] :model The class you wish to use as the identity model. - # @option options [Array] :fields ([:name, :email]) Required information at identity registration. - def initialize(app, options = {}) - options[:fields] ||= [:name, :email] - super(app, options[:name] || :identity, options.dup) - end - - def request_phase - OmniAuth::Form.build( - :title => (options[:title] || "Identity Verification"), - :url => callback_path - ) do |f| - f.text_field 'Login', 'auth_key' - f.password_field 'Password', 'password' - f.html "

Create an Identity

" - end.to_response - end - - def callback_phase - return fail!(:invalid_credentials) unless identity - super - end - - def other_phase - if on_registration_path? - if request.get? - registration_form - elsif request.post? - registration_phase - end - else - call_app! - end - end - - def registration_form - OmniAuth::Form.build(:title => 'Register Identity') do |f| - options[:fields].each do |field| - f.text_field field.to_s.capitalize, field.to_s - end - f.password_field 'Password', 'password' - f.password_field 'Confirm Password', 'password_confirmation' - end.to_response - end - - def registration_phase - attributes = (options[:fields] + [:password, :password_confirmation]).inject({}){|h,k| h[k] = request[k.to_s]; h} - @identity = model.create(attributes) - if @identity.persisted? - env['PATH_INFO'] = callback_path - callback_phase - else - if options[:on_failed_registration] - self.env['omniauth.identity'] = @identity - options[:on_failed_registration].call(self.env) - else - registration_form - end - end - end - - def auth_hash - { - 'provider' => name.to_s, - 'uid' => identity.uid, - 'user_info' => identity.user_info - } - end - - def registration_path - options[:registration_path] || "#{path_prefix}/#{name}/register" - end - - def on_registration_path? - on_path?(registration_path) - end - - def identity - @identity ||= model.authenticate(request['auth_key'], request['password']) - end - - def model - options[:model] || ::Identity - end - end - end -end diff --git a/oa-identity/oa-identity.gemspec b/oa-identity/oa-identity.gemspec deleted file mode 100644 index b05d5a9..0000000 --- a/oa-identity/oa-identity.gemspec +++ /dev/null @@ -1,27 +0,0 @@ -# -*- encoding: utf-8 -*- -require File.expand_path('../../lib/omniauth/version', __FILE__) - -Gem::Specification.new do |gem| - gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING - gem.add_development_dependency 'maruku', '~> 0.6' - gem.add_development_dependency 'simplecov', '~> 0.4' - gem.add_development_dependency 'rack-test', '~> 0.5' - gem.add_development_dependency 'rake', '~> 0.8' - gem.add_development_dependency 'rspec', '~> 2.5' - gem.add_development_dependency 'yard', '~> 0.6' - gem.add_development_dependency 'ZenTest', '~> 4.5' - gem.add_development_dependency 'bcrypt-ruby', '~> 2.1.4' - gem.add_development_dependency 'activerecord', '~> 3.0' - gem.name = 'oa-identity' - gem.version = OmniAuth::Version::STRING - gem.description = %q{Internal authentication handlers for OmniAuth.} - gem.summary = gem.description - gem.email = ['michael@intridea.com', 'sferik@gmail.com'] - gem.homepage = 'http://github.com/intridea/omniauth' - gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober'] - gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)} - gem.files = `git ls-files`.split("\n") - gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - gem.require_paths = ['lib'] - gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version= -end diff --git a/oa-identity/spec/omniauth/identity/model_spec.rb b/oa-identity/spec/omniauth/identity/model_spec.rb deleted file mode 100644 index 419df42..0000000 --- a/oa-identity/spec/omniauth/identity/model_spec.rb +++ /dev/null @@ -1,123 +0,0 @@ -require 'spec_helper' - -class ExampleModel - include OmniAuth::Identity::Model -end - -describe OmniAuth::Identity::Model do - context 'Class Methods' do - subject{ ExampleModel } - - describe '.locate' do - it('should be abstract'){ lambda{ subject.locate('abc') }.should raise_error(NotImplementedError) } - end - - describe '.authenticate' do - it 'should call locate and then authenticate' do - mocked_instance = mock('ExampleModel', :authenticate => 'abbadoo') - subject.should_receive(:locate).with('example').and_return(mocked_instance) - subject.authenticate('example','pass').should == 'abbadoo' - end - - it 'should recover gracefully if locate is nil' do - subject.stub!(:locate).and_return(nil) - subject.authenticate('blah','foo').should be_false - end - end - end - - context 'Instance Methods' do - subject{ ExampleModel.new } - - describe '#authenticate' do - it('should be abstract'){ lambda{ subject.authenticate('abc') }.should raise_error(NotImplementedError) } - end - - describe '#uid' do - it 'should default to #id' do - subject.should_receive(:respond_to?).with('id').and_return(true) - subject.stub!(:id).and_return 'wakka-do' - subject.uid.should == 'wakka-do' - end - - it 'should stringify it' do - subject.stub!(:id).and_return 123 - subject.uid.should == '123' - end - - it 'should raise NotImplementedError if #id is not defined' do - subject.should_receive(:respond_to?).with('id').and_return(false) - lambda{ subject.uid }.should raise_error(NotImplementedError) - end - end - - describe '#auth_key' do - it 'should default to #email' do - subject.should_receive(:respond_to?).with('email').and_return(true) - subject.stub!(:email).and_return('bob@bob.com') - subject.auth_key.should == 'bob@bob.com' - end - - it 'should use the class .auth_key' do - subject.class.auth_key 'login' - subject.stub!(:login).and_return 'bob' - subject.auth_key.should == 'bob' - subject.class.auth_key nil - end - - it 'should raise a NotImplementedError if the auth_key method is not defined' do - lambda{ subject.auth_key }.should raise_error(NotImplementedError) - end - end - - describe '#auth_key=' do - it 'should default to setting email' do - subject.should_receive(:respond_to?).with('email=').and_return(true) - subject.should_receive(:email=).with 'abc' - - subject.auth_key = 'abc' - end - - it 'should use a custom .auth_key if one is provided' do - subject.class.auth_key 'login' - subject.should_receive(:respond_to?).with('login=').and_return(true) - subject.should_receive('login=').with('abc') - - subject.auth_key = 'abc' - end - - it 'should raise a NotImplementedError if the autH_key method is not defined' do - lambda{ subject.auth_key = 'broken' }.should raise_error(NotImplementedError) - end - end - - describe '#user_info' do - it 'should include attributes that are set' do - subject.stub!(:name).and_return('Bob Bobson') - subject.stub!(:nickname).and_return('bob') - - subject.user_info.should == { - 'name' => 'Bob Bobson', - 'nickname' => 'bob' - } - end - - it 'should automatically set name off of first and last name' do - subject.stub!(:first_name).and_return('Bob') - subject.stub!(:last_name).and_return('Bobson') - subject.user_info['name'].should == 'Bob Bobson' - end - - it 'should automatically set name off of nickname' do - subject.stub!(:nickname).and_return('bob') - subject.user_info['name'] == 'bob' - end - - it 'should not overwrite a provided name' do - subject.stub!(:name).and_return('Awesome Dude') - subject.stub!(:first_name).and_return('Frank') - subject.user_info['name'].should == 'Awesome Dude' - end - end - end -end diff --git a/oa-identity/spec/omniauth/identity/models/active_record_spec.rb b/oa-identity/spec/omniauth/identity/models/active_record_spec.rb deleted file mode 100644 index fdd46f1..0000000 --- a/oa-identity/spec/omniauth/identity/models/active_record_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'spec_helper' - -describe(OmniAuth::Identity::Models::ActiveRecord, :db => true) do - class TestIdentity < OmniAuth::Identity::Models::ActiveRecord - auth_key :ham_sandwich - end - - it 'should locate using the auth key using a where query' do - TestIdentity.should_receive(:where).with('ham_sandwich' => 'open faced').and_return(['wakka']) - TestIdentity.locate('open faced').should == 'wakka' - end - - it 'should not use STI rules for its table name' do - TestIdentity.table_name.should == 'test_identities' - end -end diff --git a/oa-identity/spec/omniauth/identity/secure_password_spec.rb b/oa-identity/spec/omniauth/identity/secure_password_spec.rb deleted file mode 100644 index a3ccfcf..0000000 --- a/oa-identity/spec/omniauth/identity/secure_password_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper' - -class HasTheMethod - def self.has_secure_password; end -end - -class DoesNotHaveTheMethod -end - -describe OmniAuth::Identity::SecurePassword do - it 'should extend with the class methods if it does not have the method' do - DoesNotHaveTheMethod.should_receive(:extend).with(OmniAuth::Identity::SecurePassword::ClassMethods) - DoesNotHaveTheMethod.send(:include, OmniAuth::Identity::SecurePassword) - end - - it 'should not extend if the method is already defined' do - HasTheMethod.should_not_receive(:extend) - HasTheMethod.send(:include, OmniAuth::Identity::SecurePassword) - end - - it 'should respond to has_secure_password afterwards' do - [HasTheMethod,DoesNotHaveTheMethod].each do |klass| - klass.send(:include, OmniAuth::Identity::SecurePassword) - klass.should be_respond_to(:has_secure_password) - end - end -end diff --git a/oa-identity/spec/omniauth/strategies/identity_spec.rb b/oa-identity/spec/omniauth/strategies/identity_spec.rb deleted file mode 100644 index ad47f98..0000000 --- a/oa-identity/spec/omniauth/strategies/identity_spec.rb +++ /dev/null @@ -1,130 +0,0 @@ -require 'spec_helper' - -class MockIdentity; end - -describe OmniAuth::Strategies::Identity do - attr_accessor :app - - let(:auth_hash){ last_response.headers['env']['omniauth.auth'] } - let(:identity_hash){ last_response.headers['env']['omniauth.identity'] } - - # customize rack app for testing, if block is given, reverts to default - # rack app after testing is done - def set_app!(identity_options = {}) - identity_options.reverse_merge!({:model => MockIdentity}) - old_app = self.app - self.app = Rack::Builder.app do - use Rack::Session::Cookie - use OmniAuth::Strategies::Identity, identity_options - run lambda{|env| [404, {'env' => env}, ["HELLO!"]]} - end - if block_given? - yield - self.app = old_app - end - self.app - end - - before(:all) do - set_app! - end - - describe '#request_phase' do - it 'should display a form' do - get '/auth/identity' - last_response.body.should be_include(" 'user1', :user_info => {'name' => 'Rockefeller'})} - - context 'with valid credentials' do - before do - MockIdentity.should_receive('authenticate').with('john','awesome').and_return(user) - post '/auth/identity/callback', :auth_key => 'john', :password => 'awesome' - end - - it 'should populate the auth hash' do - auth_hash.should be_kind_of(Hash) - end - - it 'should populate the uid' do - auth_hash['uid'].should == 'user1' - end - - it 'should populate the user_info hash' do - auth_hash['user_info'].should == {'name' => 'Rockefeller'} - end - end - - context 'with invalid credentials' do - before do - OmniAuth.config.on_failure = lambda{|env| [401, {}, [env['omniauth.error.type'].inspect]]} - MockIdentity.should_receive(:authenticate).with('wrong','login').and_return(false) - post '/auth/identity/callback', :auth_key => 'wrong', :password => 'login' - end - - it 'should fail with :invalid_credentials' do - last_response.body.should == ':invalid_credentials' - end - end - end - - describe '#registration_form' do - it 'should trigger from /auth/identity/register by default' do - get '/auth/identity/register' - last_response.body.should be_include("Register Identity") - end - end - - describe '#registration_phase' do - context 'with successful creation' do - let(:properties){ { - :name => 'Awesome Dude', - :email => 'awesome@example.com', - :password => 'face', - :password_confirmation => 'face' - } } - - before do - m = mock(:uid => 'abc', :name => 'Awesome Dude', :email => 'awesome@example.com', :user_info => {:name => 'DUUUUDE!'}, :persisted? => true) - MockIdentity.should_receive(:create).with(properties).and_return(m) - end - - it 'should set the auth hash' do - post '/auth/identity/register', properties - auth_hash['uid'].should == 'abc' - end - end - - context 'with invalid identity' do - let(:properties) { { - :name => 'Awesome Dude', - :email => 'awesome@example.com', - :password => 'NOT', - :password_confirmation => 'MATCHING' - } } - - before do - MockIdentity.should_receive(:create).with(properties).and_return(mock(:persisted? => false)) - end - - context 'default' do - it 'should show registration form' do - post '/auth/identity/register', properties - last_response.body.should be_include("Register Identity") - end - end - - context 'custom on_failed_registration endpoint' do - it 'should set the identity hash' do - set_app!(:on_failed_registration => lambda{|env| [404, {'env' => env}, ["HELLO!"]]}) do - post '/auth/identity/register', properties - identity_hash.should_not be_nil - end - end - end - end - end -end diff --git a/oa-identity/spec/spec_helper.rb b/oa-identity/spec/spec_helper.rb deleted file mode 100644 index 4c1ab8b..0000000 --- a/oa-identity/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rubygems' -require 'bundler' -Bundler.setup :default, :development, :test - -require 'simplecov' -SimpleCov.start - -require 'rack/test' -require 'omniauth/identity' - -RSpec.configure do |config| - config.include Rack::Test::Methods -end - diff --git a/oa-more/.gemtest b/oa-more/.gemtest deleted file mode 100644 index e69de29..0000000 diff --git a/oa-more/.rspec b/oa-more/.rspec deleted file mode 100644 index bb259fe..0000000 --- a/oa-more/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---color ---format=nested ---backtrace diff --git a/oa-more/.yardopts b/oa-more/.yardopts deleted file mode 100644 index 7a69ee4..0000000 --- a/oa-more/.yardopts +++ /dev/null @@ -1,4 +0,0 @@ ---markup markdown ---markup-provider maruku -- -LICENSE diff --git a/oa-more/Gemfile b/oa-more/Gemfile deleted file mode 100644 index 73a8e19..0000000 --- a/oa-more/Gemfile +++ /dev/null @@ -1,11 +0,0 @@ -require File.expand_path('../lib/omniauth/version', __FILE__) - -source 'http://rubygems.org' - -gem 'oa-core', OmniAuth::Version::STRING, :path => '../oa-core' - -platforms :jruby do - gem 'jruby-openssl', '~> 0.7' -end - -gemspec diff --git a/oa-more/LICENSE b/oa-more/LICENSE deleted file mode 100644 index 811fa0e..0000000 --- a/oa-more/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/oa-more/README.rdoc b/oa-more/README.rdoc deleted file mode 100644 index 5d5aecb..0000000 --- a/oa-more/README.rdoc +++ /dev/null @@ -1,22 +0,0 @@ -= OmniAuth::More - -OmniAuth stratgies for authentication providers that do not -fit into one of the other authentication gems. - -== Installation - -To install omniauth as a suite of gems: - - gem install omniauth - -To install just the providers in the "more" gem: - - gem install oa-more - -== OmniAuth Builder - -If you want to allow multiple providers, use the OmniAuth Builder: - - use OmniAuth::Builder do - provider :flickr, 'api_key', 'secret_key', :scope => 'read' - end diff --git a/oa-more/Rakefile b/oa-more/Rakefile deleted file mode 100644 index 69797fc..0000000 --- a/oa-more/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require 'bundler' -Bundler::GemHelper.install_tasks -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) -task :default => :spec -task :test => :spec diff --git a/oa-more/lib/oa-more.rb b/oa-more/lib/oa-more.rb deleted file mode 100644 index 23a26ad..0000000 --- a/oa-more/lib/oa-more.rb +++ /dev/null @@ -1 +0,0 @@ -require 'omniauth/more' diff --git a/oa-more/lib/omniauth/more.rb b/oa-more/lib/omniauth/more.rb deleted file mode 100644 index 7b69889..0000000 --- a/oa-more/lib/omniauth/more.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'omniauth/core' - -module OmniAuth - module Strategies - autoload :Draugiem, 'omniauth/strategies/draugiem' - autoload :Flickr, 'omniauth/strategies/flickr' - autoload :HttpBasic, 'omniauth/strategies/http_basic' - autoload :Ign, 'omniauth/strategies/ign' - autoload :LastFm, 'omniauth/strategies/last_fm' - autoload :WindowsLive, 'omniauth/strategies/windows_live' - end -end diff --git a/oa-more/lib/omniauth/strategies/draugiem.rb b/oa-more/lib/omniauth/strategies/draugiem.rb deleted file mode 100644 index e7a659c..0000000 --- a/oa-more/lib/omniauth/strategies/draugiem.rb +++ /dev/null @@ -1,104 +0,0 @@ -require 'omniauth/core' -require 'digest/md5' -require 'rest-client' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to draugiem.lv and frype.com and others. - # - # @example Basic Rails Usage - # - # Add this to config/initializers/omniauth.rb - # - # Rails.application.config.middleware.use OmniAuth::Builder do - # provider :draugiem, 'App id', 'API Key' - # end - # - # @example Basic Rack example - # - # use Rack::Session::Cookie - # use OmniAuth::Strategies::Draugiem, 'App id', 'API Key' - # - class Draugiem - include OmniAuth::Strategy - attr_accessor :app_id, :api_key - - def initialize(app, app_id, api_key) - super(app, :draugiem) - @app_id = app_id - @api_key = api_key - end - - protected - - def request_phase - params = { - :app => @app_id, - :redirect => callback_url, - :hash => Digest::MD5.hexdigest("#{@api_key}#{callback_url}") - } - query_string = params.collect{ |key,value| "#{key}=#{Rack::Utils.escape(value)}" }.join('&') - redirect "http://api.draugiem.lv/authorize/?#{query_string}" - end - - def callback_phase - if request.params['dr_auth_status'] == 'ok' && request.params['dr_auth_code'] - response = RestClient.get('http://api.draugiem.lv/json/', { :params => draugiem_authorize_params(request.params['dr_auth_code']) }) - auth = MultiJson.decode(response.to_s) - unless auth['error'] - @auth_data = auth - super - else - fail!(auth['error']['code'].to_s,auth["error"]["description"].to_s) - end - else - fail!(:invalid_request) - end - rescue Exception => e - fail!(:invalid_response, e) - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'uid' => @auth_data['uid'], - 'user_info' => get_user_info, - 'credentials' => { - 'apikey' => @auth_data['apikey'] - }, - 'extra' => { 'user_hash' => @auth_data } - }) - end - - private - - def get_user_info - if @auth_data['users'] && @auth_data['users'][@auth_data['uid']] - user = @auth_data['users'][@auth_data['uid']] - { - 'name' => "#{user['name']} #{user['surname']}", - 'nickname' => user['nick'], - 'first_name' => user['name'], - 'last_name' => user['surname'], - 'location' => user['place'], - 'age' => user['age'] =~ /^0-9$/ ? user['age'] : nil, - 'adult' => user['adult'] == '1' ? true : false, - 'image' => user['img'], - 'sex' => user['sex'] - } - else - {} - end - end - - def draugiem_authorize_params code - { - :action => 'authorize', - :app => @api_key, - :code => code - } - end - end - end -end diff --git a/oa-more/lib/omniauth/strategies/http_basic.rb b/oa-more/lib/omniauth/strategies/http_basic.rb deleted file mode 100644 index 247a185..0000000 --- a/oa-more/lib/omniauth/strategies/http_basic.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'rest-client' -require 'omniauth/more' - -module OmniAuth - module Strategies - class HttpBasic - include OmniAuth::Strategy - - def initialize(app, name, endpoint = nil, headers = {}, &block) - super - @endpoint = endpoint - @request_headers = headers - end - - attr_reader :endpoint, :request_headers - - def request_phase - if env['REQUEST_METHOD'] == 'GET' - get_credentials - else - perform - end - end - - def title - name.split('_').map{|s| s.capitalize}.join(' ') - end - - def get_credentials - OmniAuth::Form.build(:title => title) do - text_field 'Username', 'username' - password_field 'Password', 'password' - end.to_response - end - - def perform - @response = perform_authentication(endpoint) - @env['omniauth.auth'] = auth_hash - @env['REQUEST_METHOD'] = 'GET' - @env['PATH_INFO'] = "#{OmniAuth.config.path_prefix}/#{name}/callback" - - call_app! - rescue RestClient::Request::Unauthorized => e - fail!(:invalid_credentials, e) - end - - def perform_authentication(uri, headers = request_headers) - RestClient.get(uri, headers) - end - - def callback_phase - fail!(:invalid_credentials) - end - end - end -end diff --git a/oa-more/lib/omniauth/strategies/ign.rb b/oa-more/lib/omniauth/strategies/ign.rb deleted file mode 100644 index 8d4a964..0000000 --- a/oa-more/lib/omniauth/strategies/ign.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'omniauth/core' -require 'openssl' - -module OmniAuth - module Strategies - class Ign - include OmniAuth::Strategy - IDENTIFIER_URL_PARAMETER = "" - - class CallbackError < StandardError - attr_accessor :error, :error_reason - def initialize(error, error_reason) - self.error = error - self.error_reason = error_reason - end - end - - def initialize(app, api_key, hostname=nil, options = {}) - options[:name] ||= "ign" - super(app, :ign) - @api_key = api_key - @hostname = hostname - end - - protected - - def request_phase - OmniAuth::Form.build(:title => 'IGN Authentication', :header_info=>js) do - label_field('Identifying you with the IGN server', IDENTIFIER_URL_PARAMETER) - end.to_response - end - - def callback_phase - signature = OpenSSL::HMAC.hexdigest('sha1', @api_key, ("#{request.params["username"]}::#{request.params["timestamp"]}")) - - raise CallbackError.new("Invalid Signature","The supplied and calculated signature did not match, user not approved.") if signature != request.params["signature"] - - super - rescue CallbackError => e - fail!(:invalid_response, e) - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'uid' => "ign-" + request.params["username"], - 'credentials' => { 'token' => request.params["signature"] }, - 'user_info' => user_info, - 'extra' => { 'user_hash' => request.params } - }) - end - - def user_info - { - 'nickname' => request.params["username"], - } - end - - def js - @js = <<-JS - $(document).ready(function() { - $.ajax({ - url: "http://#{@hostname}/users/current.json?callback=z33k", - type: "get", - dataType:"jsonp", - success: function(data) { - if(typeof data.error == 'undefined'){ - // There is a current My IGN user - var username = data.my_ign_username; - var signature = data.signature; - var timestamp = data.timestamp; - window.location = "/auth/ign/callback?username=" +username+"&signature="+signature+"×tamp=" + timestamp; - } - else{ - nouser(); - } - } - }); - return false; - }); - function nouser() { - var url = "http://my.ign.com/login?r="+window.location; - top.location = url; - window.location = url; - } - JS - "\n" + - "\n" + - "\n" - end - - end - end -end diff --git a/oa-more/lib/omniauth/strategies/last_fm.rb b/oa-more/lib/omniauth/strategies/last_fm.rb deleted file mode 100644 index 90ffdc6..0000000 --- a/oa-more/lib/omniauth/strategies/last_fm.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'omniauth/core' -require 'digest/md5' -require 'rest-client' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to LastFM - # - # @example Basic Usage - # - # use OmniAuth::Strategies::LastFm, 'API Key', 'Secret Key' - class LastFm - include OmniAuth::Strategy - attr_accessor :api_key, :secret_key, :options - - # error catching, based on OAuth2 callback - class CallbackError < StandardError - attr_accessor :error, :error_reason - def initialize(error, error_reason) - self.error = error - self.error_reason = error_reason - end - end - - # @param [Rack Application] app standard middleware application parameter - # @param [String] api_key the application id as [registered on LastFM](http://www.last.fm/api/account) - # @param [String] secret_key the application secret as [registered on LastFM](http://www.last.fm/api/account) - # @option options, You can optionally specify a callback URL that is different to your API Account callback url. Include this as a query param cb - def initialize(app, api_key, secret_key, options = {}) - super(app, :last_fm) - @api_key = api_key - @secret_key = secret_key - @options = options - end - - protected - - def request_phase - params = { :api_key => api_key, :cb => options[:cb] } - query_string = params.collect{ |key,value| "#{key}=#{Rack::Utils.escape(value)}" }.join('&') - redirect "http://www.last.fm/api/auth/?#{query_string}" - end - - def callback_phase - token = request.params['token'] - params = { :api_key => api_key, :method => 'auth.getSession', :format => 'json' } - params[:token] = token - params[:api_sig] = signature(token) - - response = RestClient.get('http://ws.audioscrobbler.com/2.0/', { :params => params }) - @auth = MultiJson.decode(response.to_s) - raise CallbackError.new(@auth['error'],@auth['message']) if @auth['error'] - - user_params = { :method => "user.getInfo", :user => @auth['session']['name'], :api_key => api_key, :format => "json" } - user_response = RestClient.get('http://ws.audioscrobbler.com/2.0/', { :params => user_params }) - @user_auth = MultiJson.decode(user_response.to_s) - raise CallbackError.new(@user_auth['error'],@user_auth['message']) if @user_auth['error'] - - super - rescue CallbackError => e - fail!(:invalid_response, e) - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'uid' => @user_auth['user']['id'], - 'credentials' => { 'token' => @auth['session']['key'] }, - 'user_info' => user_info, - 'extra' => { 'user_hash' => @user_auth } - }) - end - - def user_info - { - 'name' => @user_auth['user']['realname'], - 'nickname' => @user_auth['user']['name'], - 'location' => @user_auth['user']['country'], - 'image' => @user_auth['user']['image'], - 'urls' => { - 'Profile' => @user_auth['user']['url'] - } - } - end - - def signature(token) - sign = "api_key#{api_key}methodauth.getSessiontoken#{token}#{secret_key}" - Digest::MD5.hexdigest(sign) - end - end - end -end diff --git a/oa-more/lib/omniauth/strategies/windows_live.rb b/oa-more/lib/omniauth/strategies/windows_live.rb deleted file mode 100644 index 7aa892c..0000000 --- a/oa-more/lib/omniauth/strategies/windows_live.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'omniauth/core' -require 'omniauth/strategies/windows_live/windowslivelogin' - -module OmniAuth - module Strategies - class WindowsLive - include OmniAuth::Strategy - - attr_accessor :app_id, :app_secret - - # Initialize the strategy by providing - # - # @param app_id [String] The application ID from your registered app with Microsoft. - # @param app_secret [String] The secret from your registered app with Microsoft. - # @option options [String] :locale A localization string for the login, should be in the form `en-us` or similar. - # @option options [String] :state Some state information that is serialized into the query string upon callback. - # @option options [Boolean] :ssl Whether or not to use SSL for login. Defaults to `true`. - # @option options [Boolean] :force_nonprovisioned When true, forces a non-provisioned (i.e. no app id or secret) mode. - def initialize(app, app_id = nil, app_secret = nil, options = {}) - self.app_id = app_id - self.app_secret = app_secret - super(app, :windows_live, app_id, app_secret, options) - options[:ssl] ||= true - options[:locale] ||= 'en-us' - options[:force_nonprovisioned] = true unless app_id - end - - protected - - def consumer - WindowsLiveLogin.new app_id, app_secret, options[:security_algorithm], options[:force_nonprovisioned], options[:policy_url], callback_url - end - - def request_phase - redirect consumer.getLoginUrl(options[:state], options[:locale]) - end - end - end -end diff --git a/oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb b/oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb deleted file mode 100644 index e6066b2..0000000 --- a/oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb +++ /dev/null @@ -1,1143 +0,0 @@ -####################################################################### -# FILE: windowslivelogin.rb -# -# DESCRIPTION: Sample implementation of Web Authentication and -# Delegated Authentication protocol in Ruby. Also -# includes trusted sign-in and application verification -# sample implementations. -# -# VERSION: 1.1 -# -# Copyright (c) 2008 Microsoft Corporation. All Rights Reserved. -####################################################################### - -require 'cgi' -require 'uri' -require 'base64' -require 'openssl' -require 'net/https' -require 'rexml/document' - -module OmniAuth; module Strategies; class WindowsLive; class WindowsLiveLogin - - ##################################################################### - # Stub implementation for logging errors. If you want to enable - # debugging output using the default mechanism, specify true. - # By default, debug information will be printed to the standard - # error output and should be visible in the web server logs. - ##################################################################### - def setDebug(flag) - @debug = flag - end - - ##################################################################### - # Stub implementation for logging errors. By default, this function - # does nothing if the debug flag has not been set with setDebug. - # Otherwise, it tries to log the error message. - ##################################################################### - def debug(error) - return unless @debug - return if error.nil? or error.empty? - warn("Windows Live ID Authentication SDK #{error}") - nil - end - - ##################################################################### - # Stub implementation for handling a fatal error. - ##################################################################### - def fatal(error) - debug(error) - raise(error) - end - - ##################################################################### - # Initialize the WindowsLiveLogin module with the application ID, - # secret key, and security algorithm. - # - # We recommend that you employ strong measures to protect the - # secret key. The secret key should never be exposed to the Web - # or other users. - # - # Be aware that if you do not supply these settings at - # initialization time, you may need to set the corresponding - # properties manually. - # - # For Delegated Authentication, you may optionally specify the - # privacy policy URL and return URL. If you do not specify these - # values here, the default values that you specified when you - # registered your application will be used. - # - # The 'force_delauth_nonprovisioned' flag also indicates whether - # your application is registered for Delegated Authentication - # (that is, whether it uses an application ID and secret key). We - # recommend that your Delegated Authentication application always - # be registered for enhanced security and functionality. - ##################################################################### - def initialize(appid=nil, secret=nil, securityalgorithm=nil, - force_delauth_nonprovisioned=nil, - policyurl=nil, returnurl=nil) - self.force_delauth_nonprovisioned = force_delauth_nonprovisioned - self.appid = appid if appid - self.secret = secret if secret - self.securityalgorithm = securityalgorithm if securityalgorithm - self.policyurl = policyurl if policyurl - self.returnurl = returnurl if returnurl - end - - ##################################################################### - # Initialize the WindowsLiveLogin module from a settings file. - # - # 'settingsFile' specifies the location of the XML settings file - # that contains the application ID, secret key, and security - # algorithm. The file is of the following format: - # - # - # APPID - # SECRET - # wsignin1.0 - # - # - # In a Delegated Authentication scenario, you may also specify - # 'returnurl' and 'policyurl' in the settings file, as shown in the - # Delegated Authentication samples. - # - # We recommend that you store the WindowsLiveLogin settings file - # in an area on your server that cannot be accessed through the - # Internet. This file contains important confidential information. - ##################################################################### - def self.initFromXml(settingsFile) - o = self.new - settings = o.parseSettings(settingsFile) - - o.setDebug(settings['debug'] == 'true') - o.force_delauth_nonprovisioned = - (settings['force_delauth_nonprovisioned'] == 'true') - - o.appid = settings['appid'] - o.secret = settings['secret'] - o.oldsecret = settings['oldsecret'] - o.oldsecretexpiry = settings['oldsecretexpiry'] - o.securityalgorithm = settings['securityalgorithm'] - o.policyurl = settings['policyurl'] - o.returnurl = settings['returnurl'] - o.baseurl = settings['baseurl'] - o.secureurl = settings['secureurl'] - o.consenturl = settings['consenturl'] - o - end - - ##################################################################### - # Sets the application ID. Use this method if you did not specify - # an application ID at initialization. - ##################################################################### - def appid=(appid) - if (appid.nil? or appid.empty?) - return if force_delauth_nonprovisioned - fatal("Error: appid: Null application ID.") - end - if (not appid =~ /^\w+$/) - fatal("Error: appid: Application ID must be alpha-numeric: " + appid) - end - @appid = appid - end - - ##################################################################### - # Returns the application ID. - ##################################################################### - def appid - if (@appid.nil? or @appid.empty?) - fatal("Error: appid: App ID was not set. Aborting.") - end - @appid - end - - ##################################################################### - # Sets your secret key. Use this method if you did not specify - # a secret key at initialization. - ##################################################################### - def secret=(secret) - if (secret.nil? or secret.empty?) - return if force_delauth_nonprovisioned - fatal("Error: secret=: Secret must be non-null.") - end - if (secret.size < 16) - fatal("Error: secret=: Secret must be at least 16 characters.") - end - @signkey = derive(secret, "SIGNATURE") - @cryptkey = derive(secret, "ENCRYPTION") - end - - ##################################################################### - # Sets your old secret key. - # - # Use this property to set your old secret key if you are in the - # process of transitioning to a new secret key. You may need this - # property because the Windows Live ID servers can take up to - # 24 hours to propagate a new secret key after you have updated - # your application settings. - # - # If an old secret key is specified here and has not expired - # (as determined by the oldsecretexpiry setting), it will be used - # as a fallback if token decryption fails with the new secret - # key. - ##################################################################### - def oldsecret=(secret) - return if (secret.nil? or secret.empty?) - if (secret.size < 16) - fatal("Error: oldsecret=: Secret must be at least 16 characters.") - end - @oldsignkey = derive(secret, "SIGNATURE") - @oldcryptkey = derive(secret, "ENCRYPTION") - end - - ##################################################################### - # Sets the expiry time for your old secret key. - # - # After this time has passed, the old secret key will no longer be - # used even if token decryption fails with the new secret key. - # - # The old secret expiry time is represented as the number of seconds - # elapsed since January 1, 1970. - ##################################################################### - def oldsecretexpiry=(timestamp) - return if (timestamp.nil? or timestamp.empty?) - timestamp = timestamp.to_i - fatal("Error: oldsecretexpiry=: Invalid timestamp: #{timestamp}") if (timestamp <= 0) - @oldsecretexpiry = Time.at timestamp - end - - ##################################################################### - # Gets the old secret key expiry time. - ##################################################################### - attr_accessor :oldsecretexpiry - - ##################################################################### - # Sets or gets the version of the security algorithm being used. - ##################################################################### - attr_accessor :securityalgorithm - - def securityalgorithm - if(@securityalgorithm.nil? or @securityalgorithm.empty?) - "wsignin1.0" - else - @securityalgorithm - end - end - - ##################################################################### - # Sets a flag that indicates whether Delegated Authentication - # is non-provisioned (i.e. does not use an application ID or secret - # key). - ##################################################################### - attr_accessor :force_delauth_nonprovisioned - - ##################################################################### - # Sets the privacy policy URL, to which the Windows Live ID consent - # service redirects users to view the privacy policy of your Web - # site for Delegated Authentication. - ##################################################################### - def policyurl=(policyurl) - if ((policyurl.nil? or policyurl.empty?) and force_delauth_nonprovisioned) - fatal("Error: policyurl=: Invalid policy URL specified.") - end - @policyurl = policyurl - end - - ##################################################################### - # Gets the privacy policy URL for your site. - ##################################################################### - def policyurl - if (@policyurl.nil? or @policyurl.empty?) - debug("Warning: In the initial release of Del Auth, a Policy URL must be configured in the SDK for both provisioned and non-provisioned scenarios.") - raise("Error: policyurl: Policy URL must be set in a Del Auth non-provisioned scenario. Aborting.") if force_delauth_nonprovisioned - end - @policyurl - end - - ##################################################################### - # Sets the return URL--the URL on your site to which the consent - # service redirects users (along with the action, consent token, - # and application context) after they have successfully provided - # consent information for Delegated Authentication. This value will - # override the return URL specified during registration. - ##################################################################### - def returnurl=(returnurl) - if ((returnurl.nil? or returnurl.empty?) and force_delauth_nonprovisioned) - fatal("Error: returnurl=: Invalid return URL specified.") - end - @returnurl = returnurl - end - - - ##################################################################### - # Returns the return URL of your site. - ##################################################################### - def returnurl - if ((@returnurl.nil? or @returnurl.empty?) and force_delauth_nonprovisioned) - fatal("Error: returnurl: Return URL must be set in a Del Auth non-provisioned scenario. Aborting.") - end - @returnurl - end - - ##################################################################### - # Sets or gets the base URL to use for the Windows Live Login server. You - # should not have to change this property. Furthermore, we recommend - # that you use the Sign In control instead of the URL methods - # provided here. - ##################################################################### - attr_accessor :baseurl - - def baseurl - if(@baseurl.nil? or @baseurl.empty?) - "http://login.live.com/" - else - @baseurl - end - end - - ##################################################################### - # Sets or gets the secure (HTTPS) URL to use for the Windows Live Login - # server. You should not have to change this property. - ##################################################################### - attr_accessor :secureurl - - def secureurl - if(@secureurl.nil? or @secureurl.empty?) - "https://login.live.com/" - else - @secureurl - end - end - - ##################################################################### - # Sets or gets the Consent Base URL to use for the Windows Live Consent - # server. You should not have to use or change this property directly. - ##################################################################### - attr_accessor :consenturl - - def consenturl - if(@consenturl.nil? or @consenturl.empty?) - "https://consent.live.com/" - else - @consenturl - end - end -end - -####################################################################### -# Implementation of the basic methods needed for Web Authentication. -####################################################################### -class WindowsLiveLogin - ##################################################################### - # Returns the sign-in URL to use for the Windows Live Login server. - # We recommend that you use the Sign In control instead. - # - # If you specify it, 'context' will be returned as-is in the sign-in - # response for site-specific use. - ##################################################################### - def getLoginUrl(context=nil, market=nil) - url = baseurl + "wlogin.srf?appid=#{appid}" - url += "&alg=#{securityalgorithm}" - url += "&appctx=#{CGI.escape(context)}" if context - url += "&mkt=#{CGI.escape(market)}" if market - url - end - - ##################################################################### - # Returns the sign-out URL to use for the Windows Live Login server. - # We recommend that you use the Sign In control instead. - ##################################################################### - def getLogoutUrl(market=nil) - url = baseurl + "logout.srf?appid=#{appid}" - url += "&mkt=#{CGI.escape(market)}" if market - url - end - - ##################################################################### - # Holds the user information after a successful sign-in. - # - # 'timestamp' is the time as obtained from the SSO token. - # 'id' is the pairwise unique ID for the user. - # 'context' is the application context that was originally passed to - # the sign-in request, if any. - # 'token' is the encrypted Web Authentication token that contains the - # UID. This can be cached in a cookie and the UID can be retrieved by - # calling the processToken method. - # 'usePersistentCookie?' indicates whether the application is - # expected to store the user token in a session or persistent - # cookie. - ##################################################################### - class User - attr_reader :timestamp, :id, :context, :token - - def usePersistentCookie? - @usePersistentCookie - end - - - ##################################################################### - # Initialize the User with time stamp, userid, flags, context and token. - ##################################################################### - def initialize(timestamp, id, flags, context, token) - self.timestamp = timestamp - self.id = id - self.flags = flags - self.context = context - self.token = token - end - - private - attr_writer :timestamp, :id, :flags, :context, :token - - ##################################################################### - # Sets or gets the Unix timestamp as obtained from the SSO token. - ##################################################################### - def timestamp=(timestamp) - raise("Error: User: Null timestamp in token.") unless timestamp - timestamp = timestamp.to_i - raise("Error: User: Invalid timestamp: #{timestamp}") if (timestamp <= 0) - @timestamp = Time.at timestamp - end - - ##################################################################### - # Sets or gets the pairwise unique ID for the user. - ##################################################################### - def id=(id) - raise("Error: User: Null id in token.") unless id - raise("Error: User: Invalid id: #{id}") unless (id =~ /^\w+$/) - @id = id - end - - ##################################################################### - # Sets or gets the usePersistentCookie flag for the user. - ##################################################################### - def flags=(flags) - @usePersistentCookie = false - if flags - @usePersistentCookie = ((flags.to_i % 2) == 1) - end - end - end - - ##################################################################### - # Processes the sign-in response from the Windows Live sign-in server. - # - # 'query' contains the preprocessed POST table, such as that - # returned by CGI.params or Rails. (The unprocessed POST string - # could also be used here but we do not recommend it). - # - # This method returns a User object on successful sign-in; otherwise - # it returns nil. - ##################################################################### - def processLogin(query) - query = parse query - unless query - debug("Error: processLogin: Failed to parse query.") - return - end - action = query['action'] - unless action == 'login' - debug("Warning: processLogin: query action ignored: #{action}.") - return - end - token = query['stoken'] - context = CGI.unescape(query['appctx']) if query['appctx'] - processToken(token, context) - end - - ##################################################################### - # Decodes and validates a Web Authentication token. Returns a User - # object on success. If a context is passed in, it will be returned - # as the context field in the User object. - ##################################################################### - def processToken(token, context=nil) - if token.nil? or token.empty? - debug("Error: processToken: Null/empty token.") - return - end - stoken = decodeAndValidateToken token - stoken = parse stoken - unless stoken - debug("Error: processToken: Failed to decode/validate token: #{token}") - return - end - sappid = stoken['appid'] - unless sappid == appid - debug("Error: processToken: Application ID in token did not match ours: #{sappid}, #{appid}") - return - end - begin - user = User.new(stoken['ts'], stoken['uid'], stoken['flags'], - context, token) - return user - rescue Exception => e - debug("Error: processToken: Contents of token considered invalid: #{e}") - return - end - end - - ##################################################################### - # Returns an appropriate content type and body response that the - # application handler can return to signify a successful sign-out - # from the application. - # - # When a user signs out of Windows Live or a Windows Live - # application, a best-effort attempt is made at signing the user out - # from all other Windows Live applications the user might be signed - # in to. This is done by calling the handler page for each - # application with 'action' set to 'clearcookie' in the query - # string. The application handler is then responsible for clearing - # any cookies or data associated with the sign-in. After successfully - # signing the user out, the handler should return a GIF (any GIF) - # image as response to the 'action=clearcookie' query. - ##################################################################### - def getClearCookieResponse() - type = "image/gif" - content = "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7" - content = Base64.decode64(content) - return type, content - end -end - -####################################################################### -# Implementation of the basic methods needed for Delegated -# Authentication. -####################################################################### -class WindowsLiveLogin - ##################################################################### - # Returns the consent URL to use for Delegated Authentication for - # the given comma-delimited list of offers. - # - # If you specify it, 'context' will be returned as-is in the consent - # response for site-specific use. - # - # The registered/configured return URL can also be overridden by - # specifying 'ru' here. - # - # You can change the language in which the consent page is displayed - # by specifying a culture ID (For example, 'fr-fr' or 'en-us') in the - # 'market' parameter. - ##################################################################### - def getConsentUrl(offers, context=nil, ru=nil, market=nil) - if (offers.nil? or offers.empty?) - fatal("Error: getConsentUrl: Invalid offers list.") - end - url = consenturl + "Delegation.aspx?ps=#{CGI.escape(offers)}" - url += "&appctx=#{CGI.escape(context)}" if context - ru = returnurl if (ru.nil? or ru.empty?) - url += "&ru=#{CGI.escape(ru)}" if ru - pu = policyurl - url += "&pl=#{CGI.escape(pu)}" if pu - url += "&mkt=#{CGI.escape(market)}" if market - url += "&app=#{getAppVerifier()}" unless force_delauth_nonprovisioned - url - end - - ##################################################################### - # Returns the URL to use to download a new consent token, given the - # offers and refresh token. - # The registered/configured return URL can also be overridden by - # specifying 'ru' here. - ##################################################################### - def getRefreshConsentTokenUrl(offers, refreshtoken, ru) - if (offers.nil? or offers.empty?) - fatal("Error: getRefreshConsentTokenUrl: Invalid offers list.") - end - if (refreshtoken.nil? or refreshtoken.empty?) - fatal("Error: getRefreshConsentTokenUrl: Invalid refresh token.") - end - url = consenturl + "RefreshToken.aspx?ps=#{CGI.escape(offers)}" - url += "&reft=#{refreshtoken}" - ru = returnurl if (ru.nil? or ru.empty?) - url += "&ru=#{CGI.escape(ru)}" if ru - url += "&app=#{getAppVerifier()}" unless force_delauth_nonprovisioned - url - end - - ##################################################################### - # Returns the URL for the consent-management user interface. - # You can change the language in which the consent page is displayed - # by specifying a culture ID (For example, 'fr-fr' or 'en-us') in the - # 'market' parameter. - ##################################################################### - def getManageConsentUrl(market=nil) - url = consenturl + "ManageConsent.aspx" - url += "?mkt=#{CGI.escape(market)}" if market - url - end - - class ConsentToken - attr_reader :delegationtoken, :refreshtoken, :sessionkey, :expiry - attr_reader :offers, :offers_string, :locationid, :context - attr_reader :decodedtoken, :token - - ##################################################################### - # Indicates whether the delegation token is set and has not expired. - ##################################################################### - def isValid? - return false unless delegationtoken - return ((Time.now.to_i-300) < expiry.to_i) - end - - ##################################################################### - # Refreshes the current token and replace it. If operation succeeds - # true is returned to signify success. - ##################################################################### - def refresh - ct = @wll.refreshConsentToken(self) - return false unless ct - copy(ct) - true - end - - ##################################################################### - # Initialize the ConsentToken module with the WindowsLiveLogin, - # delegation token, refresh token, session key, expiry, offers, - # location ID, context, decoded token, and raw token. - ##################################################################### - def initialize(wll, delegationtoken, refreshtoken, sessionkey, expiry, - offers, locationid, context, decodedtoken, token) - @wll = wll - self.delegationtoken = delegationtoken - self.refreshtoken = refreshtoken - self.sessionkey = sessionkey - self.expiry = expiry - self.offers = offers - self.locationid = locationid - self.context = context - self.decodedtoken = decodedtoken - self.token = token - end - - private - attr_writer :delegationtoken, :refreshtoken, :sessionkey, :expiry - attr_writer :offers, :offers_string, :locationid, :context - attr_writer :decodedtoken, :token, :locationid - - ##################################################################### - # Sets the delegation token. - ##################################################################### - def delegationtoken=(delegationtoken) - if (delegationtoken.nil? or delegationtoken.empty?) - raise("Error: ConsentToken: Null delegation token.") - end - @delegationtoken = delegationtoken - end - - ##################################################################### - # Sets the session key. - ##################################################################### - def sessionkey=(sessionkey) - if (sessionkey.nil? or sessionkey.empty?) - raise("Error: ConsentToken: Null session key.") - end - @sessionkey = @wll.u64(sessionkey) - end - - ##################################################################### - # Sets the expiry time of the delegation token. - ##################################################################### - def expiry=(expiry) - if (expiry.nil? or expiry.empty?) - raise("Error: ConsentToken: Null expiry time.") - end - expiry = expiry.to_i - raise("Error: ConsentToken: Invalid expiry: #{expiry}") if (expiry <= 0) - @expiry = Time.at expiry - end - - ##################################################################### - # Sets the offers/actions for which the user granted consent. - ##################################################################### - def offers=(offers) - if (offers.nil? or offers.empty?) - raise("Error: ConsentToken: Null offers.") - end - - @offers_string = "" - @offers = [] - - offers = CGI.unescape(offers) - offers = offers.split(";") - offers.each{|offer| - offer = offer.split(":")[0] - @offers_string += "," unless @offers_string.empty? - @offers_string += offer - @offers.push(offer) - } - end - - ##################################################################### - # Sets the LocationID. - ##################################################################### - def locationid=(locationid) - if (locationid.nil? or locationid.empty?) - raise("Error: ConsentToken: Null Location ID.") - end - @locationid = locationid - end - - ##################################################################### - # Makes a copy of the ConsentToken object. - ##################################################################### - def copy(consenttoken) - @delegationtoken = consenttoken.delegationtoken - @refreshtoken = consenttoken.refreshtoken - @sessionkey = consenttoken.sessionkey - @expiry = consenttoken.expiry - @offers = consenttoken.offers - @locationid = consenttoken.locationid - @offers_string = consenttoken.offers_string - @decodedtoken = consenttoken.decodedtoken - @token = consenttoken.token - end - end - - ##################################################################### - # Processes the POST response from the Delegated Authentication - # service after a user has granted consent. The processConsent - # function extracts the consent token string and returns the result - # of invoking the processConsentToken method. - ##################################################################### - def processConsent(query) - query = parse query - unless query - debug("Error: processConsent: Failed to parse query.") - return - end - action = query['action'] - unless action == 'delauth' - debug("Warning: processConsent: query action ignored: #{action}.") - return - end - responsecode = query['ResponseCode'] - unless responsecode == 'RequestApproved' - debug("Error: processConsent: Consent was not successfully granted: #{responsecode}") - return - end - token = query['ConsentToken'] - context = CGI.unescape(query['appctx']) if query['appctx'] - processConsentToken(token, context) - end - - ##################################################################### - # Processes the consent token string that is returned in the POST - # response by the Delegated Authentication service after a - # user has granted consent. - ##################################################################### - def processConsentToken(token, context=nil) - if token.nil? or token.empty? - debug("Error: processConsentToken: Null token.") - return - end - decodedtoken = token - parsedtoken = parse(CGI.unescape(decodedtoken)) - unless parsedtoken - debug("Error: processConsentToken: Failed to parse token: #{token}") - return - end - eact = parsedtoken['eact'] - if eact - decodedtoken = decodeAndValidateToken eact - unless decodedtoken - debug("Error: processConsentToken: Failed to decode/validate token: #{token}") - return - end - parsedtoken = parse(decodedtoken) - decodedtoken = CGI.escape(decodedtoken) - end - begin - consenttoken = ConsentToken.new(self, - parsedtoken['delt'], - parsedtoken['reft'], - parsedtoken['skey'], - parsedtoken['exp'], - parsedtoken['offer'], - parsedtoken['lid'], - context, decodedtoken, token) - return consenttoken - rescue Exception => e - debug("Error: processConsentToken: Contents of token considered invalid: #{e}") - return - end - end - - ##################################################################### - # Attempts to obtain a new, refreshed token and return it. The - # original token is not modified. - ##################################################################### - def refreshConsentToken(consenttoken, ru=nil) - if consenttoken.nil? - debug("Error: refreshConsentToken: Null consent token.") - return - end - refreshConsentToken2(consenttoken.offers_string, consenttoken.refreshtoken, ru) - end - - ##################################################################### - # Helper function to obtain a new, refreshed token and return it. - # The original token is not modified. - ##################################################################### - def refreshConsentToken2(offers_string, refreshtoken, ru=nil) - url = nil - begin - url = getRefreshConsentTokenUrl(offers_string, refreshtoken, ru) - ret = fetch url - ret.value # raises exception if fetch failed - body = ret.body - body.scan(/\{"ConsentToken":"(.*)"\}/){|match| - return processConsentToken("#{match}") - } - debug("Error: refreshConsentToken2: Failed to extract token: #{body}") - rescue Exception => e - debug("Error: Failed to refresh consent token: #{e}") - end - return - end -end - -####################################################################### -# Common methods. -####################################################################### -class WindowsLiveLogin - - ##################################################################### - # Decodes and validates the token. - ##################################################################### - def decodeAndValidateToken(token, cryptkey=@cryptkey, signkey=@signkey, - internal_allow_recursion=true) - haveoldsecret = false - if (oldsecretexpiry and (Time.now.to_i < oldsecretexpiry.to_i)) - haveoldsecret = true if (@oldcryptkey and @oldsignkey) - end - haveoldsecret = (haveoldsecret and internal_allow_recursion) - - stoken = decodeToken(token, cryptkey) - stoken = validateToken(stoken, signkey) if stoken - if (stoken.nil? and haveoldsecret) - debug("Warning: Failed to validate token with current secret, attempting old secret.") - stoken = decodeAndValidateToken(token, @oldcryptkey, @oldsignkey, false) - end - stoken - end - - ##################################################################### - # Decodes the given token string; returns undef on failure. - # - # First, the string is URL-unescaped and base64 decoded. - # Second, the IV is extracted from the first 16 bytes of the string. - # Finally, the string is decrypted using the encryption key. - ##################################################################### - def decodeToken(token, cryptkey=@cryptkey) - if (cryptkey.nil? or cryptkey.empty?) - fatal("Error: decodeToken: Secret key was not set. Aborting.") - end - token = u64(token) - if (token.nil? or (token.size <= 16) or !(token.size % 16).zero?) - debug("Error: decodeToken: Attempted to decode invalid token.") - return - end - iv = token[0..15] - crypted = token[16..-1] - begin - aes128cbc = OpenSSL::Cipher::AES128.new("CBC") - aes128cbc.decrypt - aes128cbc.iv = iv - aes128cbc.key = cryptkey - decrypted = aes128cbc.update(crypted) + aes128cbc.final - rescue Exception => e - debug("Error: decodeToken: Decryption failed: #{token}, #{e}") - return - end - decrypted - end - - ##################################################################### - # Creates a signature for the given string by using the signature - # key. - ##################################################################### - def signToken(token, signkey=@signkey) - if (signkey.nil? or signkey.empty?) - fatal("Error: signToken: Secret key was not set. Aborting.") - end - begin - digest = OpenSSL::Digest::SHA256.new - return OpenSSL::HMAC.digest(digest, signkey, token) - rescue Exception => e - debug("Error: signToken: Signing failed: #{token}, #{e}") - return - end - end - - ##################################################################### - # Extracts the signature from the token and validates it. - ##################################################################### - def validateToken(token, signkey=@signkey) - if (token.nil? or token.empty?) - debug("Error: validateToken: Null token.") - return - end - body, sig = token.split("&sig=") - if (body.nil? or sig.nil?) - debug("Error: validateToken: Invalid token: #{token}") - return - end - sig = u64(sig) - return token if (sig == signToken(body, signkey)) - debug("Error: validateToken: Signature did not match.") - return - end -end - -####################################################################### -# Implementation of the methods needed to perform Windows Live -# application verification as well as trusted sign-in. -####################################################################### -class WindowsLiveLogin - ##################################################################### - # Generates an application verifier token. An IP address can - # optionally be included in the token. - ##################################################################### - def getAppVerifier(ip=nil) - token = "appid=#{appid}&ts=#{timestamp}" - token += "&ip=#{ip}" if ip - token += "&sig=#{e64(signToken(token))}" - CGI.escape token - end - - ##################################################################### - # Returns the URL that is required to retrieve the application - # security token. - # - # By default, the application security token is generated for - # the Windows Live site; a specific Site ID can optionally be - # specified in 'siteid'. The IP address can also optionally be - # included in 'ip'. - # - # If 'js' is nil, a JavaScript Output Notation (JSON) response is - # returned in the following format: - # - # {"token":""} - # - # Otherwise, a JavaScript response is returned. It is assumed that - # WLIDResultCallback is a custom function implemented to handle the - # token value: - # - # WLIDResultCallback(""); - ##################################################################### - def getAppLoginUrl(siteid=nil, ip=nil, js=nil) - url = secureurl + "wapplogin.srf?app=#{getAppVerifier(ip)}" - url += "&alg=#{securityalgorithm}" - url += "&id=#{siteid}" if siteid - url += "&js=1" if js - url - end - - ##################################################################### - # Retrieves the application security token for application - # verification from the application sign-in URL. - # - # By default, the application security token will be generated for - # the Windows Live site; a specific Site ID can optionally be - # specified in 'siteid'. The IP address can also optionally be - # included in 'ip'. - # - # Implementation note: The application security token is downloaded - # from the application sign-in URL in JSON format: - # - # {"token":""} - # - # Therefore we must extract from the string and return it as - # seen here. - ##################################################################### - def getAppSecurityToken(siteid=nil, ip=nil) - url = getAppLoginUrl(siteid, ip) - begin - ret = fetch url - ret.value # raises exception if fetch failed - body = ret.body - body.scan(/\{"token":"(.*)"\}/){|match| - return match - } - debug("Error: getAppSecurityToken: Failed to extract token: #{body}") - rescue Exception => e - debug("Error: getAppSecurityToken: Failed to get token: #{e}") - end - return - end - - ##################################################################### - # Returns a string that can be passed to the getTrustedParams - # function as the 'retcode' parameter. If this is specified as the - # 'retcode', the application will be used as return URL after it - # finishes trusted sign-in. - ##################################################################### - def getAppRetCode - "appid=#{appid}" - end - - ##################################################################### - # Returns a table of key-value pairs that must be posted to the - # sign-in URL for trusted sign-in. Use HTTP POST to do this. Be aware - # that the values in the table are neither URL nor HTML escaped and - # may have to be escaped if you are inserting them in code such as - # an HTML form. - # - # The user to be trusted on the local site is passed in as string - # 'user'. - # - # Optionally, 'retcode' specifies the resource to which successful - # sign-in is redirected, such as Windows Live Mail, and is typically - # a string in the format 'id=2000'. If you pass in the value from - # getAppRetCode instead, sign-in will be redirected to the - # application. Otherwise, an HTTP 200 response is returned. - ##################################################################### - def getTrustedParams(user, retcode=nil) - token = getTrustedToken(user) - return unless token - token = %{#{token}uri:WindowsLiveID} - params = {} - params['wa'] = securityalgorithm - params['wresult'] = token - params['wctx'] = retcode if retcode - params - end - - ##################################################################### - # Returns the trusted sign-in token in the format that is needed by a - # control doing trusted sign-in. - # - # The user to be trusted on the local site is passed in as string - # 'user'. - ##################################################################### - def getTrustedToken(user) - if user.nil? or user.empty? - debug('Error: getTrustedToken: Null user specified.') - return - end - token = "appid=#{appid}&uid=#{CGI.escape(user)}&ts=#{timestamp}" - token += "&sig=#{e64(signToken(token))}" - CGI.escape token - end - - ##################################################################### - # Returns the trusted sign-in URL to use for the Windows Live Login - # server. - ##################################################################### - def getTrustedLoginUrl - secureurl + "wlogin.srf" - end - - ##################################################################### - # Returns the trusted sign-out URL to use for the Windows Live Login - # server. - ##################################################################### - def getTrustedLogoutUrl - secureurl + "logout.srf?appid=#{appid}" - end -end - -####################################################################### -# Helper methods. -####################################################################### -class WindowsLiveLogin - - ####################################################################### - # Function to parse the settings file. - ####################################################################### - def parseSettings(settingsFile) - settings = {} - begin - file = File.new(settingsFile) - doc = REXML::Document.new file - root = doc.root - root.each_element{|e| - settings[e.name] = e.text - } - rescue Exception => e - fatal("Error: parseSettings: Error while reading #{settingsFile}: #{e}") - end - return settings - end - - ##################################################################### - # Derives the key, given the secret key and prefix as described in the - # Web Authentication SDK documentation. - ##################################################################### - def derive(secret, prefix) - begin - fatal("Nil/empty secret.") if (secret.nil? or secret.empty?) - key = prefix + secret - key = OpenSSL::Digest::SHA256.digest(key) - return key[0..15] - rescue Exception => e - debug("Error: derive: #{e}") - return - end - end - - ##################################################################### - # Parses query string and return a table - # {String=>String} - # - # If a table is passed in from CGI.params, we convert it from - # {String=>[]} to {String=>String}. I believe Rails uses symbols - # instead of strings in general, so we convert from symbols to - # strings here also. - ##################################################################### - def parse(input) - if (input.nil? or input.empty?) - debug("Error: parse: Nil/empty input.") - return - end - - pairs = {} - if (input.class == String) - input = input.split('&') - input.each{|pair| - k, v = pair.split('=') - pairs[k] = v - } - else - input.each{|k, v| - v = v[0] if (v.class == Array) - pairs[k.to_s] = v.to_s - } - end - return pairs - end - - ##################################################################### - # Generates a time stamp suitable for the application verifier token. - ##################################################################### - def timestamp - Time.now.to_i.to_s - end - - ##################################################################### - # Base64-encodes and URL-escapes a string. - ##################################################################### - def e64(s) - return unless s - CGI.escape Base64.encode64(s) - end - - ##################################################################### - # URL-unescapes and Base64-decodes a string. - ##################################################################### - def u64(s) - return unless s - Base64.decode64 CGI.unescape(s) - end - - ##################################################################### - # Fetches the contents given a URL. - ##################################################################### - def fetch(url) - url = URI.parse url - http = Net::HTTP.new(url.host, url.port) - http.use_ssl = (url.scheme == "https") - http.request_get url.request_uri - end -end end end end - diff --git a/oa-more/lib/omniauth/strategies/yupoo.rb b/oa-more/lib/omniauth/strategies/yupoo.rb deleted file mode 100644 index a76b581..0000000 --- a/oa-more/lib/omniauth/strategies/yupoo.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'omniauth/core' -require 'digest/md5' -require 'rest-client' -require 'multi_json' - -module OmniAuth - module Strategies - class Yupoo - include OmniAuth::Strategy - attr_accessor :api_key, :secret_key, :options - - - class CallbackError < StandardError - attr_accessor :error, :error_reason - def initialize(error, error_reason) - self.error = error - self.error_reason = error_reason - end - end - - def initialize(app, api_key, secret_key, options = {}) - super(app, :yupoo) - @api_key = api_key - @secret_key = secret_key - @options = {:scope => 'read'}.merge(options) - end - - protected - - def request_phase - params = { :api_key => api_key, :perms => options[:scope] } - params[:api_sig] = yupoo_sign(params) - query_string = params.collect{ |key,value| "#{key}=#{Rack::Utils.escape(value)}" }.join('&') - redirect "http://www.yupoo.com/services/auth/?#{query_string}" - end - - def callback_phase - params = { :api_key => api_key, :method => 'yupoo.auth.getToken', :frob => request.params['frob'], :format => 'json', :nojsoncallback => '1' } - params[:api_sig] = yupoo_sign(params) - - response = RestClient.get('http://www.yupoo.com/api/rest/', { :params => params }) - auth = MultiJson.decode(response.to_s) - raise CallbackError.new(auth['code'],auth['message']) if auth['stat'] == 'fail' - - @user = auth['auth']['user'] - @access_token = auth['auth']['token']['_content'] - - super - rescue CallbackError => e - fail!(:invalid_response, e) - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'uid' => @user['nsid'], - 'credentials' => { 'token' => @access_token }, - 'user_info' => @user, - 'extra' => { 'user_hash' => @user } - }) - end - - def yupoo_sign(params) - Digest::MD5.hexdigest(secret_key + params.sort{|a,b| a[0].to_s <=> b[0].to_s }.flatten.join) - end - end - end -end diff --git a/oa-more/lib/omniauth/version.rb b/oa-more/lib/omniauth/version.rb deleted file mode 100644 index 9f980b0..0000000 --- a/oa-more/lib/omniauth/version.rb +++ /dev/null @@ -1,19 +0,0 @@ -module OmniAuth - module Version - unless defined?(::OmniAuth::Version::MAJOR) - MAJOR = 0 - end - unless defined?(::OmniAuth::Version::MINOR) - MINOR = 3 - end - unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 - end - unless defined?(::OmniAuth::Version::PRE) - PRE = "rc3" - end - unless defined?(::OmniAuth::Version::STRING) - STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') - end - end -end diff --git a/oa-more/oa-more.gemspec b/oa-more/oa-more.gemspec deleted file mode 100644 index 6053657..0000000 --- a/oa-more/oa-more.gemspec +++ /dev/null @@ -1,27 +0,0 @@ -# encoding: utf-8 -require File.expand_path('../lib/omniauth/version', __FILE__) - -Gem::Specification.new do |gem| - gem.add_dependency 'multi_json', '~> 1.0.0' - gem.add_dependency 'oa-core', OmniAuth::Version::STRING - gem.add_dependency 'rest-client', '~> 1.6.0' - gem.add_development_dependency 'json_pure', '~> 1.5' - gem.add_development_dependency 'rack-test', '~> 0.5' - gem.add_development_dependency 'rake', '~> 0.8' - gem.add_development_dependency 'rdiscount', '~> 1.6' - gem.add_development_dependency 'rspec', '~> 2.5' - gem.add_development_dependency 'simplecov', '~> 0.4' - gem.add_development_dependency 'webmock', '~> 1.7' - gem.add_development_dependency 'yard', '~> 0.7' - gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober'] - gem.description = %q{Additional strategies for OmniAuth.} - gem.email = 'michael@intridea.com' - gem.files = `git ls-files`.split("\n") - gem.homepage = 'http://github.com/intridea/omniauth' - gem.name = 'oa-more' - gem.require_paths = ['lib'] - gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version= - gem.summary = gem.description - gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - gem.version = OmniAuth::Version::STRING -end diff --git a/oa-more/spec/omniauth/strategies/draugiem_spec.rb b/oa-more/spec/omniauth/strategies/draugiem_spec.rb deleted file mode 100644 index 757c5ae..0000000 --- a/oa-more/spec/omniauth/strategies/draugiem_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe 'OmniAuth::Strategies::Draugiem', :type => :strategy do - - include OmniAuth::Test::StrategyTestCase - - def strategy - [OmniAuth::Strategies::Draugiem, '123', "abc"] - end - - it 'should initialize with api key and app id' do - lambda{OmniAuth::Strategies::Draugiem.new({},'123','abc')}.should_not raise_error - end - - describe '/auth/draugiem' do - - it 'should redirect to api.draugiem.lv' do - get '/auth/draugiem' - last_response.should be_redirect - last_response.headers['Location'].should match %r{http://api\.draugiem\.lv/authorize/} - end - - it 'should gather user data after success authorization' do - stub_request(:get, "http://api.draugiem.lv/json/?action=authorize&app=abc&code=123456"). - to_return(:body => MultiJson.encode({ - 'apikey'=>"123456789", - 'uid'=>"100", - 'language'=>"lv", - 'users'=>{ - '100'=>{ - 'uid'=>"100", - 'name'=>"John", - 'surname'=>"Lenon", - 'nick'=>"johnybravo", - 'place'=>"Durbe", - 'age'=>"false", - 'adult'=>"1", - 'img'=>"http://4.bp.blogspot.com/_ZmXOoYjxXog/Sg2jby1RFSI/AAAAAAAAE_Q/1LpfjimAz50/s400/JohnnyBravo3.gif", - 'sex'=>"M" - } - } - })) - get '/auth/draugiem/callback?dr_auth_status=ok&dr_auth_code=123456' - - last_request.env['omniauth.auth']['credentials']['apikey'].should == "123456789" - last_request.env['omniauth.auth']['user_info']['location'].should == "Durbe" - last_request.env['omniauth.auth']['user_info']['age'].should be_nil - last_request.env['omniauth.auth']['user_info']['adult'].should be_true - end - end -end diff --git a/oa-more/spec/omniauth/strategies/http_basic_spec.rb b/oa-more/spec/omniauth/strategies/http_basic_spec.rb deleted file mode 100644 index caf5ce7..0000000 --- a/oa-more/spec/omniauth/strategies/http_basic_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe OmniAuth::Strategies::HttpBasic do - it 'should exist' do - # do nothing - end -end diff --git a/oa-more/spec/omniauth/strategies/last_fm_spec.rb b/oa-more/spec/omniauth/strategies/last_fm_spec.rb deleted file mode 100644 index 1252130..0000000 --- a/oa-more/spec/omniauth/strategies/last_fm_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe 'OmniAuth::Strategies::LastFm' do - it 'should initialize with a consumer key and secret' do - lambda{OmniAuth::Strategies::LastFm.new({},'abc','def')}.should_not raise_error - end -end diff --git a/oa-more/spec/spec_helper.rb b/oa-more/spec/spec_helper.rb deleted file mode 100644 index 8f8fcfa..0000000 --- a/oa-more/spec/spec_helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'simplecov' -SimpleCov.start -require 'rspec' -require 'rack/test' -require 'webmock/rspec' -require 'omniauth/more' - -RSpec.configure do |config| - config.include Rack::Test::Methods - config.include WebMock::API -end diff --git a/oa-oauth/.gemtest b/oa-oauth/.gemtest deleted file mode 100644 index e69de29..0000000 diff --git a/oa-oauth/.rspec b/oa-oauth/.rspec deleted file mode 100644 index bb259fe..0000000 --- a/oa-oauth/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---color ---format=nested ---backtrace diff --git a/oa-oauth/.yardopts b/oa-oauth/.yardopts deleted file mode 100644 index 7a69ee4..0000000 --- a/oa-oauth/.yardopts +++ /dev/null @@ -1,4 +0,0 @@ ---markup markdown ---markup-provider maruku -- -LICENSE diff --git a/oa-oauth/Gemfile b/oa-oauth/Gemfile deleted file mode 100644 index 73a8e19..0000000 --- a/oa-oauth/Gemfile +++ /dev/null @@ -1,11 +0,0 @@ -require File.expand_path('../lib/omniauth/version', __FILE__) - -source 'http://rubygems.org' - -gem 'oa-core', OmniAuth::Version::STRING, :path => '../oa-core' - -platforms :jruby do - gem 'jruby-openssl', '~> 0.7' -end - -gemspec diff --git a/oa-oauth/LICENSE b/oa-oauth/LICENSE deleted file mode 100644 index 811fa0e..0000000 --- a/oa-oauth/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/oa-oauth/README.rdoc b/oa-oauth/README.rdoc deleted file mode 100644 index e3ce68a..0000000 --- a/oa-oauth/README.rdoc +++ /dev/null @@ -1,35 +0,0 @@ -= OmniAuth::OAuth - -OAuth 1.0 and 2.0 strategies for the OmniAuth gem. - -== Installation - -To get just OAuth functionality: - - gem install oa-oauth - -For the full auth suite: - - gem install omniauth - -== Stand-Alone Example - -Use the strategy as a middleware in your application: - - require 'omniauth/oauth' - - use OmniAuth::Strategies::Twitter, 'consumer_key', 'consumer_secret' - -Then simply direct users to '/auth/twitter' to have them authenticate via Twitter. - -== OmniAuth Builder - -If you want to allow multiple providers, use the OmniAuth Builder: - - require 'omniauth/oauth' - - use OmniAuth::Builder do - provider :twitter, 'consumer_key', 'consumer_secret' - provider :facebook, 'client_id', 'client_secret' - end - \ No newline at end of file diff --git a/oa-oauth/Rakefile b/oa-oauth/Rakefile deleted file mode 100644 index 69797fc..0000000 --- a/oa-oauth/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require 'bundler' -Bundler::GemHelper.install_tasks -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) -task :default => :spec -task :test => :spec diff --git a/oa-oauth/autotest/discover.rb b/oa-oauth/autotest/discover.rb deleted file mode 100644 index cd6892c..0000000 --- a/oa-oauth/autotest/discover.rb +++ /dev/null @@ -1 +0,0 @@ -Autotest.add_discovery { "rspec2" } diff --git a/oa-oauth/lib/oa-oauth.rb b/oa-oauth/lib/oa-oauth.rb deleted file mode 100644 index 929a4e6..0000000 --- a/oa-oauth/lib/oa-oauth.rb +++ /dev/null @@ -1 +0,0 @@ -require 'omniauth/oauth' diff --git a/oa-oauth/lib/omniauth/oauth.rb b/oa-oauth/lib/omniauth/oauth.rb deleted file mode 100644 index 10bdad7..0000000 --- a/oa-oauth/lib/omniauth/oauth.rb +++ /dev/null @@ -1,74 +0,0 @@ -require 'omniauth/core' - -module OmniAuth - module Strategies - autoload :OAuth, 'omniauth/strategies/oauth' - autoload :Blogger, 'omniauth/strategies/oauth/blogger' - autoload :Dopplr, 'omniauth/strategies/oauth/dopplr' - autoload :Douban, 'omniauth/strategies/oauth/douban' - autoload :Dropbox, 'omniauth/strategies/oauth/dropbox' - autoload :Evernote, 'omniauth/strategies/oauth/evernote' - autoload :Flattr, 'omniauth/strategies/oauth/flattr' - autoload :Flickr, 'omniauth/strategies/oauth/flickr' - autoload :Goodreads, 'omniauth/strategies/oauth/goodreads' - autoload :Google, 'omniauth/strategies/oauth/google' - autoload :GoogleHealth, 'omniauth/strategies/oauth/google_health' - autoload :GoogleHealthSandbox,'omniauth/strategies/oauth/google_health_sandbox' - autoload :Hyves, 'omniauth/strategies/oauth/hyves' - autoload :Identica, 'omniauth/strategies/oauth/identica' - autoload :LinkedIn, 'omniauth/strategies/oauth/linked_in' - autoload :Meetup, 'omniauth/strategies/oauth/meetup' - autoload :Miso, 'omniauth/strategies/oauth/miso' - autoload :Netflix, 'omniauth/strategies/oauth/netflix' - autoload :Orkut, 'omniauth/strategies/oauth/orkut' - autoload :Qzone, 'omniauth/strategies/oauth/qzone' - autoload :Plurk, 'omniauth/strategies/oauth/plurk' - autoload :Rdio, 'omniauth/strategies/oauth/rdio' - autoload :SmugMug, 'omniauth/strategies/oauth/smug_mug' - autoload :T163, 'omniauth/strategies/oauth/t163' - autoload :Tqq, 'omniauth/strategies/oauth/tqq' - autoload :TradeMe, 'omniauth/strategies/oauth/trade_me' - autoload :TripIt, 'omniauth/strategies/oauth/trip_it' - autoload :Tsina, 'omniauth/strategies/oauth/tsina' - autoload :Tsohu, 'omniauth/strategies/oauth/tsohu' - autoload :Tumblr, 'omniauth/strategies/oauth/tumblr' - autoload :Twitter, 'omniauth/strategies/oauth/twitter' - autoload :TypePad, 'omniauth/strategies/oauth/type_pad' - autoload :Vimeo, 'omniauth/strategies/oauth/vimeo' - autoload :Yahoo, 'omniauth/strategies/oauth/yahoo' - autoload :Yammer, 'omniauth/strategies/oauth/yammer' - autoload :YouTube, 'omniauth/strategies/oauth/you_tube' - - autoload :OAuth2, 'omniauth/strategies/oauth2' - autoload :AngelList, 'omniauth/strategies/oauth2/angellist' - autoload :Bitly, 'omniauth/strategies/oauth2/bitly' - autoload :Cobot, 'omniauth/strategies/oauth2/cobot' - autoload :Dailymile, 'omniauth/strategies/oauth2/dailymile' - autoload :Doit, 'omniauth/strategies/oauth2/doit' - autoload :Facebook, 'omniauth/strategies/oauth2/facebook' - autoload :Foursquare, 'omniauth/strategies/oauth2/foursquare' - autoload :GitHub, 'omniauth/strategies/oauth2/github' - autoload :Glitch, 'omniauth/strategies/oauth2/glitch' - autoload :GoogleOAuth2, 'omniauth/strategies/google_oauth2' - autoload :Gowalla, 'omniauth/strategies/oauth2/gowalla' - autoload :Instagram, 'omniauth/strategies/oauth2/instagram' - autoload :Liveid, 'omniauth/strategies/oauth2/liveid' - autoload :Mailchimp, 'omniauth/strategies/oauth2/mailchimp' - autoload :Mailru, 'omniauth/strategies/oauth2/mailru' - autoload :Mixi, 'omniauth/strategies/oauth2/mixi' - autoload :Renren, 'omniauth/strategies/oauth2/renren' - autoload :Salesforce, 'omniauth/strategies/oauth2/salesforce' - autoload :SoundCloud, 'omniauth/strategies/oauth2/sound_cloud' - autoload :Taobao, 'omniauth/strategies/oauth2/taobao' - autoload :Teambox, 'omniauth/strategies/oauth2/teambox' - autoload :ThirtySevenSignals, 'omniauth/strategies/oauth2/thirty_seven_signals' - autoload :Viadeo, 'omniauth/strategies/oauth2/viadeo' - autoload :Vkontakte, 'omniauth/strategies/oauth2/vkontakte' - autoload :WePay, 'omniauth/strategies/oauth2/we_pay' - - - autoload :XAuth, 'omniauth/strategies/xauth' - autoload :Instapaper, 'omniauth/strategies/xauth/instapaper' - - end -end diff --git a/oa-oauth/lib/omniauth/strategies/google_oauth2.rb b/oa-oauth/lib/omniauth/strategies/google_oauth2.rb deleted file mode 100644 index 7330315..0000000 --- a/oa-oauth/lib/omniauth/strategies/google_oauth2.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # OAuth 2.0 based authentication with Google. - class GoogleOAuth2 < OAuth2 - # @param [Rack Application] app standard middleware application argument - # @param [String] client_id the application ID for your client - # @param [String] client_secret the application secret - # @option options [String] :scope ('https://www.googleapis.com/auth/userinfo.email') space-separated services that you need. - def initialize(app, client_id = nil, client_secret = nil, options = {}, &block) - client_options = { - :site => 'https://accounts.google.com', - :authorize_url => '/o/oauth2/auth', - :token_url => '/o/oauth2/token' - } - - super(app, :google_oauth2, client_id, client_secret, client_options, options, &block) - end - - def request_phase - google_email_scope = "www.googleapis.com/auth/userinfo.email" - options[:scope] ||= "https://#{google_email_scope}" - options[:scope] << "https://#{google_email_scope}" unless options[:scope] =~ %r[http[s]?:\/\/#{google_email_scope}] - redirect client.auth_code.authorize_url( - {:redirect_uri => callback_url, :response_type => "code"}.merge(options)) - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'uid' => user_info['uid'], - 'user_info' => user_info, - 'credentials' => {'expires_at' => @access_token.expires_at}, - 'extra' => {'user_hash' => user_data} - }) - end - - def user_info - if user_data['data']['isVerified'] - email = user_data['data']['email'] - else - email = nil - end - { - 'email' => email, - 'uid' => email, - 'name' => email - } - end - - def user_data - @data ||= - @access_token.get("https://www.googleapis.com/userinfo/email?alt=json").parsed - end - - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth.rb b/oa-oauth/lib/omniauth/strategies/oauth.rb deleted file mode 100644 index 75ac0ab..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'multi_json' -require 'oauth' -require 'omniauth/oauth' - -module OmniAuth - module Strategies - class OAuth - include OmniAuth::Strategy - - def initialize(app, name, consumer_key=nil, consumer_secret=nil, consumer_options={}, options={}, &block) - self.consumer_key = consumer_key - self.consumer_secret = consumer_secret - self.consumer_options = consumer_options - super - self.options[:open_timeout] ||= 30 - self.options[:read_timeout] ||= 30 - self.options[:authorize_params] = options[:authorize_params] || {} - end - - def consumer - consumer = ::OAuth::Consumer.new(consumer_key, consumer_secret, consumer_options.merge(options[:client_options] || options[:consumer_options] || {})) - consumer.http.open_timeout = options[:open_timeout] if options[:open_timeout] - consumer.http.read_timeout = options[:read_timeout] if options[:read_timeout] - consumer - end - - attr_reader :name - attr_accessor :consumer_key, :consumer_secret, :consumer_options - - def request_phase - request_token = consumer.get_request_token(:oauth_callback => callback_url) - session['oauth'] ||= {} - session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} - - if request_token.callback_confirmed? - redirect request_token.authorize_url(options[:authorize_params]) - else - redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url)) - end - - rescue ::Timeout::Error => e - fail!(:timeout, e) - rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e - fail!(:service_unavailable, e) - end - - def callback_phase - raise OmniAuth::NoSessionError.new("Session Expired") if session['oauth'].nil? - - request_token = ::OAuth::RequestToken.new(consumer, session['oauth'][name.to_s].delete('request_token'), session['oauth'][name.to_s].delete('request_secret')) - - opts = {} - if session['oauth'][name.to_s]['callback_confirmed'] - opts[:oauth_verifier] = request['oauth_verifier'] - else - opts[:oauth_callback] = callback_url - end - - @access_token = request_token.get_access_token(opts) - super - rescue ::Timeout::Error => e - fail!(:timeout, e) - rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e - fail!(:service_unavailable, e) - rescue ::OAuth::Unauthorized => e - fail!(:invalid_credentials, e) - rescue ::NoMethodError, ::MultiJson::DecodeError => e - fail!(:invalid_response, e) - rescue ::OmniAuth::NoSessionError => e - fail!(:session_expired, e) - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'credentials' => { - 'token' => @access_token.token, - 'secret' => @access_token.secret - }, 'extra' => { - 'access_token' => @access_token - } - }) - end - - def unique_id - nil - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/blogger.rb b/oa-oauth/lib/omniauth/strategies/oauth/blogger.rb deleted file mode 100644 index d7f0b28..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/blogger.rb +++ /dev/null @@ -1,58 +0,0 @@ -# Based heavily on the Google strategy, monkeypatch and all -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to YouTube via OAuth and retrieve basic user info. - # - # Usage: - # use OmniAuth::Strategies::YouTube, 'consumerkey', 'consumersecret' - class Blogger < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/accounts/OAuthGetAccessToken', - :authorize_path => '/accounts/OAuthAuthorizeToken', - :request_token_path => '/accounts/OAuthGetRequestToken', - :site => 'https://www.google.com', - } - super(app, :blogger, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - ui = user_info - OmniAuth::Utils.deep_merge(super, { - 'uid' => ui['uid'], - 'user_info' => ui, - 'extra' => {'user_hash' => user_hash}, - }) - end - - # TODO: Remove contact list from hash returned to the application - def user_info - { - 'uid' => user_hash['feed']['author'][0]['email']['$t'], - 'nickname' => user_hash['feed']['author'][0]['name']['$t'], - } - end - - def user_hash - # Using Contact feed - @user_hash ||= MultiJson.decode(@access_token.get('https://www.google.com/m8/feeds/contacts/default/full/?alt=json').body) - end - - def request_phase - request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => 'http://www.blogger.com/feeds/ http://www.google.com/m8/feeds/'}) - session['oauth'] ||= {} - session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} - r = Rack::Response.new - if request_token.callback_confirmed? - r.redirect(request_token.authorize_url) - else - r.redirect(request_token.authorize_url(:oauth_callback => callback_url)) - end - r.finish - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/dopplr.rb b/oa-oauth/lib/omniauth/strategies/oauth/dopplr.rb deleted file mode 100644 index f319463..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/dopplr.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Dopplr via OAuth and retrieve an access token for API usage - # - # Usage: - # use OmniAuth::Strategies::Dopplr, 'consumerkey', 'consumersecret' - class Dopplr < OmniAuth::Strategies::OAuth - # Initialize the Dopplr strategy. - # - # @option options [Hash, {}] :client_options Options to be passed directly to the OAuth Consumer - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/oauth/access_token', - :authorize_path => '/oauth/authorize', - :request_token_path => '/oauth/request_token', - :site => 'https://www.dopplr.com', - } - super(app, :dopplr, consumer_key, consumer_secret, client_options, options, &block) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('/oauthapi/whoami').body)['whoami'] - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['nick'], - 'user_info' => user_info, - } - ) - end - - def user_info - { - 'nickname' => user_data['nick'], - 'first_name' => user_data['forename'], - 'last_name' => user_data['surname'], - 'name' => "#{user_data['forename']} #{user_data['surname']}", - 'urls' => { - 'Dopplr' => user_data['dopplr_url'], - 'DopplrMobile' => user_data['mobile_url'], - }, - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/douban.rb b/oa-oauth/lib/omniauth/strategies/oauth/douban.rb deleted file mode 100644 index e65cc9c..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/douban.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to Douban via OAuth and retrieve basic - # user information. - # Usage: - # use OmniAuth::Strategies::Douban, 'APIKey', 'APIKeySecret' - class Douban < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - # Although in OAuth spec the :realm parameter is optional, - # it is required for Douban. - client_options = { - :access_token_path => '/service/auth/access_token', - :authorize_path => '/service/auth/authorize', - :realm => 'OmniAuth', - :request_token_path => '/service/auth/request_token', - :site => 'http://www.douban.com', - } - - super(app, :douban, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => @access_token.params[:douban_user_id], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - location = user_hash['location'] ? user_hash['location']['$t'] : nil - image = user_hash['link'].find{|l| l['@rel'] == 'icon'}['@href'] - douban_url = user_hash['link'].find{|l| l['@rel'] == 'alternate'}['@href'] - { - 'username' => user_hash['db:uid']['$t'], - 'name' => user_hash['title']['$t'], - 'location' => location, - 'image' => image, - 'description' => user_hash['content']['$t'], - 'urls' => { - 'Douban' => douban_url, - }, - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('http://api.douban.com/people/%40me?alt=json').body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/dropbox.rb b/oa-oauth/lib/omniauth/strategies/oauth/dropbox.rb deleted file mode 100644 index 58b6053..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/dropbox.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class Dropbox < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://www.dropbox.com/0/oauth/authorize', - :access_token_url => 'https://api.dropbox.com/0/oauth/access_token', - :proxy => ENV['HTTP_PROXY'] || ENV['http_proxy'], - :request_token_url => 'https://api.dropbox.com/0/oauth/request_token', - :site => 'https://api.dropbox.com', - } - super(app, :dropbox, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['uid'], - 'user_info' => user_info, - } - ) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('/0/account/info').body) - end - - def user_info - { - 'name' => user_data['display_name'], - 'uid' => user_data['uid'], - 'email' => user_data['email'] - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/evernote.rb b/oa-oauth/lib/omniauth/strategies/oauth/evernote.rb deleted file mode 100644 index fe61ae0..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/evernote.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' -require 'evernote' - -module OmniAuth - module Strategies - # Authenticate to Evernote via OAuth and retrieve an access token for API usage - # - # Usage: - # use OmniAuth::Strategies::Evernote, 'consumerkey', 'consumersecret' - class Evernote < OmniAuth::Strategies::OAuth - # Initialize the Evernote strategy. - # - # @option options [Hash, {}] :client_options Options to be passed directly to the OAuth Consumer - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/oauth', - :authorize_path => '/OAuth.action', - :oauth_signature_method => 'PLAINTEXT', - :request_token_path => '/oauth', - :site => 'https://www.evernote.com', - } - super(app, :evernote, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data.id, - 'user_info' => user_info, - 'extra' => user_data, - } - ) - end - - def user_info - { - 'name' => user_data.name, - 'nickname' => user_data.username, - } - end - - def user_data - @user_data ||= begin - user_store_url = consumer.site + '/edam/user' - client = ::Evernote::Client.new(::Evernote::EDAM::UserStore::UserStore::Client, user_store_url, {}) - client.getUser(@access_token.token) - end - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/flattr.rb b/oa-oauth/lib/omniauth/strategies/oauth/flattr.rb deleted file mode 100644 index 9344830..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/flattr.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'omniauth/oauth' -require 'multi_xml' - -module OmniAuth - module Strategies - # Authenticate to Flattr via OAuth and retrieve basic user information. - # Usage: - # use OmniAuth::Strategies::Flattr, 'consumerkey', 'consumersecret' - class Flattr < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :site => 'https://api.flattr.com' - } - options[:authorize_params] = {:access_scope => "read,publish,click,extendedread"} - super(app, :flattr, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - ui = user_info - OmniAuth::Utils.deep_merge(super, { - 'uid' => user_hash['id'], - 'user_info' => ui, - 'extra' => {'user_hash' => user_hash} - }) - end - - # user info according to schema - def user_info - { - 'uid' => user_hash['id'], - 'nickname' => user_hash['username'], - 'first_name' => user_hash['firstname'], - 'last_name' => user_hash['lastname'], - 'name' => [user_hash['firstname'],user_hash['lastname']].reject{ |n| n.nil? || n.empty? }.join(' '), - 'email' => user_hash['email'], - 'language' => user_hash['language'] - } - end - - # info as supplied by Flattr user summary - # response: {"flattr"=>{"version"=>"0.5", "user"=>{"id"=>"82597", "username"=>"foo", "firstname"=>"Foo", "lastname"=>"Bar", "email"=>"foo@bar.com", "city"=>"", "country"=>"", "gravatar"=>"", "url"=>"", "description"=>"", "thingcount"=>"1", "language"=>"en_GB"}}} - def user_hash - @user_hash ||= MultiXml.parse(@access_token.get('/rest/0.5/user/me').body)["flattr"]["user"] - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/flickr.rb b/oa-oauth/lib/omniauth/strategies/oauth/flickr.rb deleted file mode 100644 index e17774a..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/flickr.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - - class Flickr < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - scope = options.delete(:scope) || 'read' - options[:authorize_params] ||= {} - options[:authorize_params][:perms] = scope - - client_options = { - :access_token_path => "/services/oauth/access_token", - :authorize_path => "/services/oauth/authorize", - :request_token_path => "/services/oauth/request_token", - :site => "http://www.flickr.com" - } - super(app, :flickr, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => @access_token.params["user_nsid"], - 'user_info' => user_info - } - ) - end - - def user_info - { - 'username' => @access_token.params["username"], - 'full_name' => @access_token.params["fullname"] - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb b/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb deleted file mode 100644 index 36665fe..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/goodreads.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'multi_xml' -require 'omniauth/oauth' - -module OmniAuth - module Strategies - class Goodreads < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :site => 'http://www.goodreads.com', - } - @consumer_key = consumer_key - super(app, :goodreads, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - hash = user_info(@access_token) - - OmniAuth::Utils.deep_merge( - super, { - 'uid' => hash.delete('id'), - 'user_info' => hash, - } - ) - end - - def user_info(access_token) - authenticated_user = MultiXml.parse(@access_token.get('/api/auth_user').body) - id = authenticated_user.xpath('GoodreadsResponse/user').attribute('id').value.to_i - response_doc = MultiXml.parse(open("http://www.goodreads.com/user/show/#{id}.xml?key=#{@consumer_key}").read) - user = response_doc.xpath('GoodreadsResponse/user') - - hash = { - 'id' => id, - 'name' => user.xpath('name').text, - 'user_name' => user.xpath('user_name').text, - 'image_url' => user.xpath('image_url').text, - 'about' => user.xpath('about').text, - 'location' => user.xpath('location').text, - 'website' => user.xpath('website').text, - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/google.rb b/oa-oauth/lib/omniauth/strategies/oauth/google.rb deleted file mode 100644 index 6470347..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/google.rb +++ /dev/null @@ -1,79 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Google via OAuth and retrieve basic - # user information. - # - # Usage: - # use OmniAuth::Strategies::Google, 'consumerkey', 'consumersecret' - class Google < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/accounts/OAuthGetAccessToken', - :authorize_path => '/accounts/OAuthAuthorizeToken', - :request_token_path => '/accounts/OAuthGetRequestToken', - :site => 'https://www.google.com', - } - google_contacts_auth = 'www.google.com/m8/feeds' - options[:scope] ||= "https://#{google_contacts_auth}" - options[:scope] << " https://#{google_contacts_auth}" unless options[:scope] =~ %r[http[s]?:\/\/#{google_contacts_auth}] - super(app, :google, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - ui = user_info - OmniAuth::Utils.deep_merge( - super, { - 'uid' => ui['uid'], - 'user_info' => ui, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - email = user_hash['feed']['id']['$t'] - - name = user_hash['feed']['author'].first['name']['$t'] - name = email if name.strip == '(unknown)' - - { - 'email' => email, - 'uid' => email, - 'name' => name, - } - end - - def user_hash - # Google is very strict about keeping authorization and - # authentication separated. - # They give no endpoint to get a user's profile directly that I can - # find. We *can* get their name and email out of the contacts feed, - # however. It will fail in the extremely rare case of a user who has - # a Google Account but has never even signed up for Gmail. This has - # not been seen in the field. - @user_hash ||= MultiJson.decode(@access_token.get('https://www.google.com/m8/feeds/contacts/default/full?max-results=1&alt=json').body) - end - - # Monkeypatch OmniAuth to pass the scope in the consumer.get_request_token call - def request_phase - request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => options[:scope]}) - session['oauth'] ||= {} - session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} - r = Rack::Response.new - - if request_token.callback_confirmed? - r.redirect(request_token.authorize_url) - else - r.redirect(request_token.authorize_url(:oauth_callback => callback_url)) - end - - r.finish - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/google_health.rb b/oa-oauth/lib/omniauth/strategies/oauth/google_health.rb deleted file mode 100644 index 2503270..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/google_health.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Google via OAuth and retrieve basic - # user information. - # - # Usage: - # use OmniAuth::Strategies::Google, 'consumerkey', 'consumersecret' - class GoogleHealth < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/accounts/OAuthGetAccessToken', - :authorize_path => '/accounts/OAuthAuthorizeToken', - :request_token_path => '/accounts/OAuthGetRequestToken', - :site => 'https://www.google.com', - } - super(app, :google_health, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - ui = user_info - OmniAuth::Utils.deep_merge( - super, { - 'uid' => ui['uid'], - 'user_info' => ui, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - email = user_hash['feed']['id']['$t'] - name = user_hash['feed']['author'].first['name']['$t'] - name = email if name.strip == '(unknown)' - { - 'email' => email, - 'uid' => email, - 'name' => name, - } - end - - def user_hash - # Google is very strict about keeping authorization and - # authentication separated. - # They give no endpoint to get a user's profile directly that I can - # find. We *can* get their name and email out of the contacts feed, - # however. It will fail in the extremely rare case of a user who has - # a Google Account but has never even signed up for Gmail. This has - # not been seen in the field. - @user_hash ||= MultiJson.decode(@access_token.get('http://www.google.com/health/feeds/profile/default/default?digest=true&alt=json').body) - end - - # Monkeypatch OmniAuth to pass the scope in the consumer.get_request_token call - def request_phase - request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => 'http://www.google.com/health/feeds'}) - (session['oauth']||={})[name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} - r = Rack::Response.new - if request_token.callback_confirmed? - r.redirect(request_token.authorize_url) - else - r.redirect(request_token.authorize_url(:oauth_callback => callback_url)) - end - r.finish - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/google_health_sandbox.rb b/oa-oauth/lib/omniauth/strategies/oauth/google_health_sandbox.rb deleted file mode 100644 index 540b0c6..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/google_health_sandbox.rb +++ /dev/null @@ -1,74 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to Google via OAuth and retrieve basic - # user information. - # - # Usage: - # - # use OmniAuth::Strategies::Google, 'consumerkey', 'consumersecret' - # - class GoogleHealthSandbox < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/accounts/OAuthGetAccessToken', - :authorize_path => '/accounts/OAuthAuthorizeToken', - :request_token_path => '/accounts/OAuthGetRequestToken', - :site => 'https://www.google.com', - } - super(app, :google_health_sandbox, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - ui = user_info - OmniAuth::Utils.deep_merge( - super, { - 'uid' => ui['uid'], - 'user_info' => ui, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - email = user_hash['feed']['id']['$t'] - name = user_hash['feed']['author'].first['name']['$t'] - name = email if name.strip == '(unknown)' - { - 'email' => email, - 'uid' => email, - 'name' => name, - } - end - - def user_hash - # Google is very strict about keeping authorization and - # authentication separated. - # They give no endpoint to get a user's profile directly that I can - # find. We *can* get their name and email out of the contacts feed, - # however. It will fail in the extremely rare case of a user who has - # a Google Account but has never even signed up for Gmail. This has - # not been seen in the field. - @user_hash ||= MultiJson.decode(@access_token.get('http://www.google.com/h9/feeds/profile/default/default?digest=true&oauth_signature_method=RSA-SHA1&oauth_version=1.0').body) - end - - # Monkeypatch OmniAuth to pass the scope in the consumer.get_request_token call - def request_phase - request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => 'http://www.google.com/h9/feeds'}) - (session['oauth']||={})[name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} - r = Rack::Response.new - if request_token.callback_confirmed? - r.redirect(request_token.authorize_url) - else - r.redirect(request_token.authorize_url(:oauth_callback => callback_url)) - end - r.finish - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/hyves.rb b/oa-oauth/lib/omniauth/strategies/oauth/hyves.rb deleted file mode 100644 index 6d0b5f7..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/hyves.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class Hyves < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - options = { - :methods => 'users.get,friends.get,wwws.create', - :expirationtype => 'default' - }.merge(options) - - client_options = { - :authorize_path => 'http://www.hyves.nl/api/authorize', - :access_token_path => access_token_path, - :http_method => :get, - :request_token_path => request_token_path(options), - :scheme => :header, - } - - super(app, :hyves, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - hash = user_hash(@access_token) - { - 'provider' => 'hyves', - 'uid' => hash['userid'], - 'user_info' => { - 'name' => "#{hash['firstname']} #{hash['lastname']}", - 'first_name' => hash['firstname'], - 'last_name' => hash['lastname'], - }, - 'credentials' => { - 'token' => @access_token.token, - 'secret' => @access_token.secret, - }, - } - end - - def user_hash(access_token) - rsp = MultiJson.decode(access_token.get("http://data.hyves-api.nl/?userid=#{access_token.params[:userid]}&ha_method=users.get&#{default_options}").body) - rsp['user'].first - end - - def request_token_path(options) - options['ha_method'] = 'auth.requesttoken' - options['strict_oauth_spec_response'] = true - "http://data.hyves-api.nl/?#{to_params(options)}&#{default_options}" - end - - def access_token_path - "http://data.hyves-api.nl/?#{access_token_options}&#{default_options}" - end - - def default_options - to_params({:ha_version => '2.0', :ha_format => 'json', :ha_fancylayout => false}) - end - - def access_token_options - to_params({:ha_method => 'auth.accesstoken', :strict_oauth_spec_response => true}) - end - - def to_params(options) - options.collect{|key, value| "#{key}=#{value}"}.join('&') - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/identica.rb b/oa-oauth/lib/omniauth/strategies/oauth/identica.rb deleted file mode 100644 index f0af0d0..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/identica.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Identica via OAuth and retrieve basic - # user information. - # - # Usage: - # use OmniAuth::Strategies::Identica, 'consumerkey', 'consumersecret' - class Identica < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/api/oauth/access_token', - :authorize_path => '/api/oauth/authorize', - :request_token_path => '/api/oauth/request_token', - :site => 'http://identi.ca', - } - super(app, :identica, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_hash['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - { - 'nickname' => user_hash['screen_name'], - 'name' => user_hash['name'], - 'location' => user_hash['location'], - 'image' => user_hash['profile_image_url'], - 'description' => user_hash['description'], - 'urls' => { - 'Website' => user_hash['url'], - }, - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('/api/account/verify_credentials.json').body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/linked_in.rb b/oa-oauth/lib/omniauth/strategies/oauth/linked_in.rb deleted file mode 100644 index 3e3aedd..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/linked_in.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'multi_xml' -require 'omniauth/oauth' - -module OmniAuth - module Strategies - class LinkedIn < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/uas/oauth/accessToken', - :authorize_path => '/uas/oauth/authorize', - :request_token_path => '/uas/oauth/requestToken', - :scheme => :header, - :site => 'https://api.linkedin.com', - } - client_options[:authorize_path] = '/uas/oauth/authenticate' unless options[:sign_in] == false - super(app, :linked_in, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - hash = user_hash(@access_token) - - OmniAuth::Utils.deep_merge(super, - { - 'uid' => hash.delete('id'), - 'user_info' => hash, - } - ) - end - - def user_hash(access_token) - person = MultiXml.parse(@access_token.get('/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location,public-profile-url)').body)['person'] - - hash = { - 'id' => person['id'], - 'first_name' => person['first_name'], - 'last_name' => person['last_name'], - 'nickname' => person['public_profile_url'].to_s.split('/').last, - 'location' => person['location']['name'], - 'image' => person['picture_url'], - 'description' => person['headline'], - 'public_profile_url' => person['public_profile_url'], - } - hash['urls'] = {} - member_urls = person['member_url_resources']['member_url'] - if (!member_urls.nil?) and (!member_urls.empty?) - [member_urls].flatten.each do |url| - hash['urls']["#{url['name']}"] = url['url'] - end - end - hash['urls']['LinkedIn'] = person['public_profile_url'] - hash['name'] = "#{hash['first_name']} #{hash['last_name']}" - hash - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/meetup.rb b/oa-oauth/lib/omniauth/strategies/oauth/meetup.rb deleted file mode 100644 index 1cbf1dc..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/meetup.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate with Meetup via OAuth and retrieve an access token for API usage - # - # Usage: - # use OmniAuth::Strategies::Meetup, 'consumerkey', 'consumersecret' - class Meetup < OmniAuth::Strategies::OAuth - # Initialize meetup middleware - # @param [Rack Application] app standard middleware application parameter - # @param [String] consumer_key the application consumer id - # @param [String] consumer_secret the application consumer secret - # @option options [Boolean, true] :sign_in When true, use a sign-in flow instead of the authorization flow. - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - auth_path = (options[:sign_in] == false) ? 'http://www.meetup.com/authorize' : 'http://www.meetup.com/authenticate' - client_options = { - :access_token_path => 'https://api.meetup.com/oauth/access', - :authorize_path => auth_path, - :request_token_path => 'https://api.meetup.com/oauth/request', - } - super(app, :meetup, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, - { - 'uid' => member['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => member, - }, - } - ) - end - - def user_info - { - 'name' => member['name'], - 'image' => member['photo_url'], - 'location' => member['city'], - 'urls' => { - 'profile' => member['link'], - }, - } - end - - def member - @member ||= parse(@access_token.get('https://api.meetup.com/members.json?relation=self').body)['results'][0] - end - - def parse(response) - MultiJson.decode(response) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/miso.rb b/oa-oauth/lib/omniauth/strategies/oauth/miso.rb deleted file mode 100644 index 0d9d817..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/miso.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to Miso via OAuth and retrieve basic - # user information. - # - # Usage: - # - # use OmniAuth::Strategies::Miso, 'consumerkey', 'consumersecret' - # - class Miso < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :site => 'https://gomiso.com', - } - super(app, :miso, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, - { - 'uid' => user_hash['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - { - 'nickname' => user_hash['username'], - 'name' => user_hash['full_name'], - 'image' => user_hash['profile_image_url'], - 'description' => user_hash['tagline'], - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('/api/oauth/v1/users/show.json').body)['user'] - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/netflix.rb b/oa-oauth/lib/omniauth/strategies/oauth/netflix.rb deleted file mode 100644 index e320ee2..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/netflix.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to Netflix via OAuth and retrieve basic user information. - # Usage: - # use OmniAuth::Strategies::Netflix, 'consumerkey', 'consumersecret' - # - class Netflix < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/oauth/access_token', - :authorize_url => 'https://api-user.netflix.com/oauth/login', - :request_token_path => '/oauth/request_token', - :site => 'http://api.netflix.com', - } - super(app, :netflix, consumer_key, consumer_secret, client_options, options, &block) - end - - def request_phase - request_token = consumer.get_request_token(:oauth_callback => callback_url) - session['oauth'] ||= {} - session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} - r = Rack::Response.new - if request_token.callback_confirmed? - r.redirect(request_token.authorize_url( - :oauth_consumer_key => consumer.key - )) - else - r.redirect(request_token.authorize_url( - :oauth_callback => callback_url, - :oauth_consumer_key => consumer.key - )) - end - r.finish - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, - { - 'uid' => user_hash['user']['user_id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash['user'], - }, - } - ) - end - - def user_info - user = user_hash['user'] - { - 'nickname' => user['nickname'], - 'first_name' => user['first_name'], - 'last_name' => user['last_name'], - 'name' => "#{user['first_name']} #{user['last_name']}" - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get("http://api.netflix.com/users/#{@access_token.params[:user_id]}?output=json").body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/orkut.rb b/oa-oauth/lib/omniauth/strategies/oauth/orkut.rb deleted file mode 100644 index 4b067da..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/orkut.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to Orkut via OAuth and retrieve basic user info. - # - # Usage: - # - # use OmniAuth::Strategies::Orkut, 'consumerkey', 'consumersecret' - # - class Orkut < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) - client_options = { - :site => 'https://www.google.com', - :request_token_path => '/accounts/OAuthGetRequestToken', - :access_token_path => '/accounts/OAuthGetAccessToken', - :authorize_path => '/accounts/OAuthAuthorizeToken' - } - super(app, :orkut, consumer_key, consumer_secret, client_options, options) - end - - def auth_hash - ui = user_info - OmniAuth::Utils.deep_merge(super, { - 'uid' => ui['uid'], - 'user_info' => ui, - 'extra' => {'user_hash' => user_hash} - }) - end - - def user_info - entry = user_hash['entry'] - { - 'uid' => entry['id'], - 'first_name' => entry['name']['givenName'], - 'last_name' => entry['name']['familyName'], - 'image' => entry['thumbnailUrl'] - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get("http://www.orkut.com/social/rest/people/@me/@self").body) - end - - def request_phase - request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => 'http://orkut.gmodules.com/social/rest'}) - session['oauth'] ||= {} - session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} - r = Rack::Response.new - - if request_token.callback_confirmed? - r.redirect(request_token.authorize_url) - else - r.redirect(request_token.authorize_url(:oauth_callback => callback_url)) - end - - r.finish - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/plurk.rb b/oa-oauth/lib/omniauth/strategies/oauth/plurk.rb deleted file mode 100644 index df82f10..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/plurk.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Plurk via OAuth and retrieve basic user info. - # - # Please note that this strategy relies on Plurk API 2.0, - # which is still in Beta. - # - # Usage: - # use OmniAuth::Strategies::Plurk - class Plurk < OmniAuth::Strategies::OAuth - # @param [Rack Application] app standard middleware application parameter - # @param [String] consumer_key App key [registered on plurk] (http://www.plurk.com/PlurkApp/register) - # @param [String] consumer_secret App secret registered on plurk - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/OAuth/access_token', - :authorize_path => '/OAuth/authorize', - :request_token_path => '/OAuth/request_token', - :site => 'http://www.plurk.com', - } - super(app, :plurk, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - user = self.user_hash - OmniAuth::Utils.deep_merge(super, - { - 'uid' => user['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user = self.user_hash - { - 'name' => user['full_name'], - 'nickname' => user['display_name'] || user['nick_name'], - 'location' => user['location'], - 'image' => user['has_profile_image'] == 1 ? "http://avatars.plurk.com/#{user['id']}-medium#{user['avatar']}.gif" : 'http://www.plurk.com/static/default_medium.gif', - 'urls' => {'Plurk' => 'http://plurk.com/' + user['nick_name']}, - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('/APP/Profile/getOwnProfile').body)['user_info'] - end - - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/qzone.rb b/oa-oauth/lib/omniauth/strategies/oauth/qzone.rb deleted file mode 100644 index c2ca8ab..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/qzone.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to qzone (QQ) via OAuth and retrieve basic - # user information. - # - # Usage: - # - # use OmniAuth::Strategies::Qzone, 'consumerkey', 'consumersecret' - # - class Qzone < OmniAuth::Strategies::OAuth - # Initialize the middleware - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/oauth/qzoneoauth_access_token', - :authorize_path => '/oauth/qzoneoauth_authorize', - :http_method => :get, - :request_token_path => '/oauth/qzoneoauth_request_token', - :scheme => :query_string, - :site => 'http://openapi.qzone.qq.com', - } - options[:authorize_params] = {:oauth_consumer_key => consumer_key} - super(app, :qzone, consumer_key, consumer_secret, client_options, options, &block) - end - - #HACK qzone is using a none-standard parameter oauth_overicode - def consumer_options - @consumer_options[:access_token_path] = '/oauth/qzoneoauth_access_token?oauth_vericode=' + request['oauth_vericode'] if request['oauth_vericode'] - @consumer_options - end - - def callback_phase - session['oauth'][name.to_s]['callback_confirmed'] = true - super - end - - def auth_hash - ui = user_info - OmniAuth::Utils.deep_merge(super, - { - 'uid' => ui['uid'], - 'user_info' => ui, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - { - 'uid' => @access_token.params[:openid], - 'nickname' => user_hash['nickname'], - 'name' => user_hash['nickname'], - 'image' => user_hash['figureurl'], - 'urls' => { - 'figureurl_1' => user_hash['figureurl_1'], - 'figureurl_2' => user_hash['figureurl_2'], - }, - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get("/user/get_user_info?format=json&openid=#{@access_token.params[:openid]}").body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/rdio.rb b/oa-oauth/lib/omniauth/strategies/oauth/rdio.rb deleted file mode 100644 index 43f49cc..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/rdio.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Rdio via OAuth and retrieve basic user information. - # - # Usage: - # use OmniAuth::Strategies::Rdio, 'consumerkey', 'consumersecret' - class Rdio < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/oauth/access_token', - :authorize_url => 'https://www.rdio.com/oauth/authorize', - :request_token_path => '/oauth/request_token', - :site => 'http://api.rdio.com', - } - super(app, :rdio, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_hash['key'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user = user_hash - { - 'nickname' => user['username'], - 'first_name' => user['firstName'], - 'last_name' => user['lastName'], - 'name' => "#{user['firstName']} #{user['lastName']}" - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.post('http://api.rdio.com/1/', {:method => 'currentUser', :extras => 'username'}).body)['result'] - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/smug_mug.rb b/oa-oauth/lib/omniauth/strategies/oauth/smug_mug.rb deleted file mode 100644 index 7f8e4b2..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/smug_mug.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to SmugMug via OAuth and retrieve basic user information. - # - # Usage: - # use OmniAuth::Strategies::SmugMug, 'consumerkey', 'consumersecret' - class SmugMug < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/services/oauth/getAccessToken.mg', - :authorize_path => '/services/oauth/authorize.mg', - :site => 'http://api.smugmug.com', - :request_token_path => '/services/oauth/getRequestToken.mg', - } - super(app, :smugmug, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_hash['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - # user info according to schema - def user_info - { - 'nickname' => user_hash['NickName'], - 'name' => user_hash['NickName'] - } - end - - # info as supplied by SmugMug - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('/services/api/json/1.2.2/?method=smugmug.auth.checkAccessToken').body)['Auth']['User'] - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/t163.rb b/oa-oauth/lib/omniauth/strategies/oauth/t163.rb deleted file mode 100644 index d349cec..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/t163.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to T163 via OAuth and retrieve basic - # user information. - # - # Usage: - # - # use OmniAuth::Strategies::T163, 'APIKey', 'APIKeySecret' - class T163 < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - @api_key = consumer_key - client_options = { - :access_token_path => '/oauth/access_token', - :authorize_path => '/oauth/authenticate', - :realm => 'OmniAuth', - :request_token_path => '/oauth/request_token', - :site => 'http://api.t.163.com', - } - super(app, :t163, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_hash['screen_name'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - { - 'username' => user_hash['name'], - 'name' => user_hash['realName'], - 'location' => user_hash['location'], - 'image' => user_hash['profile_image_url'], - 'description' => user_hash['description'], - 'email' => user_hash['email'], - 'urls' => { - 'T163' => 'http://t.163.com', - }, - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get("http://api.t.163.com/account/verify_credentials.json").body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/tqq.rb b/oa-oauth/lib/omniauth/strategies/oauth/tqq.rb deleted file mode 100644 index 115b9a2..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/tqq.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Tqq via OAuth and retrieve basic - # user information. - # - # Usage: - # use OmniAuth::Strategies::Tqq, 'APIKey', 'APIKeySecret' - class Tqq < OmniAuth::Strategies::OAuth - - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - @api_key = consumer_key - client_options = { - :access_token_path => '/cgi-bin/access_token', - :authorize_path => '/cgi-bin/authorize', - :http_method => :get, - :nonce => nonce, - :realm => 'OmniAuth', - :request_token_path => '/cgi-bin/request_token', - :scheme => :query_string, - :site => 'https://open.t.qq.com', - } - super(app, :tqq, consumer_key, consumer_secret, client_options, options, &block) - end - - def nonce - Base64.encode64(OpenSSL::Random.random_bytes(32)).gsub(/\W/, '')[0, 32] - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_hash['data']['uid'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - { - 'username' => user_hash['data']['name'], - 'name' => user_hash['data']['nick'], - 'location' => user_hash['data']['location'], - 'image' => user_hash['data']['head'], - 'description' => user_hash['description'], - 'urls' => { - 'Tqq' => 't.qq.com', - }, - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('http://open.t.qq.com/api/user/info?format=json').body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/trade_me.rb b/oa-oauth/lib/omniauth/strategies/oauth/trade_me.rb deleted file mode 100644 index 0cb091f..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/trade_me.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to TradeMe via OAuth and retrieve basic user information. - # Usage: - # use OmniAuth::Strategies::TradeMe, 'consumerkey', 'consumersecret' - # - class TradeMe < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/Oauth/AccessToken', - :authorize_path => '/Oauth/Authorize', - :request_token_path => '/Oauth/RequestToken', - :site => 'https://secure.trademe.co.nz', - } - super(app, :trademe, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_hash['MemberId'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - # user info according to schema - def user_info - { - 'nickname' => user_hash['Nickname'], - 'first_name' => user_hash['FirstName'], - 'last_name' => user_hash['LastName'], - 'name' => [user_hash['FirstName'], user_hash['LastName']].reject{|n| n.nil? || n.empty?}.join(' '), - } - end - - # info as supplied by TradeMe user summary - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('https://api.trademe.co.nz/v1/MyTradeMe/Summary.json').body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/trip_it.rb b/oa-oauth/lib/omniauth/strategies/oauth/trip_it.rb deleted file mode 100644 index 3b55349..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/trip_it.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'omniauth/oauth' - -module OmniAuth - module Strategies - # - # Authenticate to TripIt via OAuth and retrieve an access token for API usage - # - # Usage: - # - # use OmniAuth::Strategies::TripIt, 'consumerkey', 'consumersecret' - # - class TripIt < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/oauth/access_token', - :authorize_url => 'https://www.tripit.com/oauth/authorize', - :request_token_path => '/oauth/request_token', - :site => 'https://api.tripit.com', - } - super(app, :tripit, consumer_key, consumer_secret, client_options, options, &block) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb b/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb deleted file mode 100644 index 62511a1..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb +++ /dev/null @@ -1,85 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to TSina via OAuth and retrieve basic - # user information. - # - # Usage: - # use OmniAuth::Strategies::TSina, 'APIKey', 'APIKeySecret' - class Tsina < OmniAuth::Strategies::OAuth - - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - @api_key = consumer_key - client_options = { - :access_token_path => '/oauth/access_token', - :authorize_path => '/oauth/authorize', - :realm => 'OmniAuth', - :request_token_path => '/oauth/request_token', - :site => 'http://api.t.sina.com.cn', - } - super(app, :tsina, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => @access_token.params[:user_id], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - { - 'username' => user_hash['screen_name'], - 'name' => user_hash['name'], - 'location' => user_hash['location'], - 'image' => user_hash['profile_image_url'], - 'description' => user_hash['description'], - 'urls' => { - 'Tsina' => user_hash['url'] - } - } - end - - # MonkeyPatch session['oauth']['tsina']['callback_confirmed'] to true - def request_phase - request_token = consumer.get_request_token(:oauth_callback => callback_url) - session['oauth'] ||= {} - session['oauth'][name.to_s] = {'callback_confirmed' => true, 'request_token' => request_token.token, 'request_secret' => request_token.secret} - r = Rack::Response.new - - if request_token.callback_confirmed? - r.redirect(request_token.authorize_url) - else - r.redirect(request_token.authorize_url(:oauth_callback => callback_url)) - end - - r.finish - rescue ::Timeout::Error => e - fail!(:timeout, e) - end - - # MonkeyPath to symbolize tina parameters - def callback_phase - session[:oauth].stringify_keys! - session[:oauth][name.to_s].stringify_keys! if session[:oauth][name.to_s] - super - end - - def user_hash - # http://api.t.sina.com.cn/users/show/:id.json?source=appkey - # @access_token.params[:user_id] is the UID - # @api_key is the appkey - uid = @access_token.params[:user_id] - @user_hash ||= MultiJson.decode(@access_token.get("http://api.t.sina.com.cn/users/show/#{uid}.json?source=#{@api_key}").body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/tsohu.rb b/oa-oauth/lib/omniauth/strategies/oauth/tsohu.rb deleted file mode 100644 index 5e47b69..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/tsohu.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Tsohu via OAuth and retrieve basic - # user information. - # - # Usage: - # use OmniAuth::Strategies::Tsohu, 'APIKey', 'APIKeySecret' - class Tsohu < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - @api_key = consumer_key - client_options = { - :access_token_path => '/oauth/access_token', - :authorize_path => '/oauth/authorize', - :scheme => :header, - :site => 'http://api.t.sohu.com', - :request_token_path => '/oauth/request_token', - } - super(app, :tsohu, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_hash['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - { - 'username' => user_hash['screen_name'], - 'name' => user_hash['name'], - 'location' => user_hash['location'], - 'image' => user_hash['profile_image_url'], - 'description' => user_hash['description'], - 'urls' => { - 'Tsohu' => user_hash['url'] - } - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('http://api.t.sohu.com/account/verify_credentials.json').body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/tumblr.rb b/oa-oauth/lib/omniauth/strategies/oauth/tumblr.rb deleted file mode 100644 index 806a817..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/tumblr.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'omniauth/oauth' - -module OmniAuth - module Strategies - # Authenticate to Tumblr via OAuth and retrieve basic - # user information. - # - # Usage: - # use OmniAuth::Strategies::Tumblr, 'consumerkey', 'consumersecret' - class Tumblr < OmniAuth::Strategies::OAuth - # @option options [Boolean, true] :sign_in When true, use the "Sign in with Tumblr" flow instead of the authorization flow. - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :site => 'http://www.tumblr.com', - } - client_options[:authorize_path] = '/oauth/authorize' unless options[:sign_in] == false - super(app, :tumblr, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user['name'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user - }, - } - ) - end - - def user_info - { - 'nickname' => user['name'], - 'name' => user['title'], - 'image' => user['avatar_url'], - 'urls' => { - 'website' => user['url'], - } - } - end - - def user - tumblelogs = user_hash['tumblr']['tumblelog'] - if tumblelogs.kind_of?(Array) - @user ||= tumblelogs[0] - else - @user ||= tumblelogs - end - end - - def user_hash - url = 'http://www.tumblr.com/api/authenticate' - @user_hash ||= Hash.from_xml(@access_token.get(url).body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/twitter.rb b/oa-oauth/lib/omniauth/strategies/oauth/twitter.rb deleted file mode 100644 index f9697ba..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/twitter.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Twitter via OAuth and retrieve basic - # user information. - # - # Usage: - # use OmniAuth::Strategies::Twitter, 'consumerkey', 'consumersecret' - class Twitter < OmniAuth::Strategies::OAuth - # Initialize the middleware - # - # @option options [Boolean, true] :sign_in When true, use the "Sign in with Twitter" flow instead of the authorization flow. - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :site => 'https://api.twitter.com', - } - options[:authorize_params] = {:force_login => 'true'} if options.delete(:force_login) == true - client_options[:authorize_path] = '/oauth/authorize' unless options[:sign_in] == false - super(app, options[:name] || :twitter, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => @access_token.params[:user_id], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - { - 'nickname' => user_hash['screen_name'], - 'name' => user_hash['name'] || user_hash['screen_name'], - 'location' => user_hash['location'], - 'image' => user_hash['profile_image_url'], - 'description' => user_hash['description'], - 'urls' => { - 'Website' => user_hash['url'], - 'Twitter' => 'http://twitter.com/' + user_hash['screen_name'], - }, - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('/1/account/verify_credentials.json').body) - rescue ::Errno::ETIMEDOUT - raise ::Timeout::Error - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/type_pad.rb b/oa-oauth/lib/omniauth/strategies/oauth/type_pad.rb deleted file mode 100644 index 88e1eb6..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/type_pad.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Typepad via OAuth and retrieve basic - # user information. - # - # Usage: - # use OmniAuth::Strategies::Typepad, 'consumerkey', 'consumersecret', :application_id => 'my_type_pad_application_id' - # application_id is required. - class TypePad < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - # TypePad uses the application ID for one of the OAuth paths. - app_id = options[:application_id] - client_options = { - :access_token_path => '/secure/services/oauth/access_token', - :authorize_path => "/secure/services/api/#{app_id}/oauth-approve", - :http_method => :get, - # You *must* use query_string for the token dance. - :scheme => :query_string, - :site => 'https://www.typepad.com', - :request_token_path => '/secure/services/oauth/request_token', - } - options.merge! :scheme => :query_string, :http_method => :get - super(app, :type_pad, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - ui = user_info - OmniAuth::Utils.deep_merge( - super, { - 'uid' => ui['uid'], - 'user_info' => ui, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - { - 'uid' => user_hash['urlId'], - 'nickname' => user_hash['preferredUsername'], - 'name' => user_hash['displayName'], - 'image' => user_hash['avatarLink']['url'], - 'description' => user_hash['aboutMe'], - 'urls' => { - 'Profile' => user_hash['profilePageUrl'], - }, - } - end - - def user_hash - # For authenticated requests, you have to use header as your scheme. - # Failure to do so gives a unique response body - 'Auth is required'. - # 'Unauthorized' is the response body of a truly unauthorized request. - - # Also note that API requests hit a different site than the OAuth dance. - r = self.consumer.request(:get, 'https://api.typepad.com/users/@self.json', @access_token, :scheme => 'header') - @user_hash ||= MultiJson.decode(r.body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/vimeo.rb b/oa-oauth/lib/omniauth/strategies/oauth/vimeo.rb deleted file mode 100644 index af37862..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/vimeo.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to Vimeo via OAuth and retrieve basic user information. - # - # Usage: - # - # use OmniAuth::Strategies::Vimeo, 'consumerkey', 'consumersecret' - # - class Vimeo < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/oauth/access_token', - :authorize_path => '/oauth/authorize', - :request_token_path => '/oauth/request_token', - :site => 'http://vimeo.com', - } - super(app, :vimeo, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - user = user_hash['person'] - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user, - }, - } - ) - end - - def user_info - user = user_hash['person'] - { - 'nickname' => user['username'], - 'name' => user['display_name'], - 'location' => user['location'], - 'description' => user['bio'], - 'image' => user['portraits']['portrait'].select{|h| h['height'] == '300'}.first['_content'], - 'urls' => { - 'website' => user['url'], - 'vimeo' => user['profileurl'], - }, - } - end - - def user_hash - url = 'http://vimeo.com/api/rest/v2?method=vimeo.people.getInfo&format=json' - @user_hash ||= MultiJson.decode(@access_token.get(url).body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/yahoo.rb b/oa-oauth/lib/omniauth/strategies/oauth/yahoo.rb deleted file mode 100644 index 4f311d6..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/yahoo.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to Yahoo via OAuth and retrieve basic - # user information. - # - # Usage: - # - # use OmniAuth::Strategies::Yahoo, 'consumerkey', 'consumersecret' - # - class Yahoo < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/oauth/v2/get_token', - :authorize_path => '/oauth/v2/request_auth', - :request_token_path => '/oauth/v2/get_request_token', - :site => 'https://api.login.yahoo.com', - } - super(app, :yahoo, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - ui = user_info - OmniAuth::Utils.deep_merge( - super, { - 'uid' => ui['uid'], - 'user_info' => ui, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - profile = user_hash['profile'] - nickname = user_hash['profile']['nickname'] - { - 'uid' => profile['guid'], - 'nickname' => profile['nickname'], - 'name' => profile['givenName'] || nickname, - 'image' => profile['image']['imageUrl'], - 'description' => profile['message'], - 'urls' => { - 'Profile' => profile['profileUrl'], - }, - } - end - - def user_hash - uid = @access_token.params['xoauth_yahoo_guid'] - @user_hash ||= MultiJson.decode(@access_token.get("http://social.yahooapis.com/v1/user/#{uid}/profile?format=json").body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/yammer.rb b/oa-oauth/lib/omniauth/strategies/oauth/yammer.rb deleted file mode 100644 index 9464f39..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/yammer.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class Yammer < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/oauth/access_token', - :authorize_path => '/oauth/authorize', - :request_token_path => '/oauth/request_token', - :site => 'https://www.yammer.com', - } - super(app, :yammer, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_hash['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - user_hash = self.user_hash - { - 'nickname' => user_hash['name'], - 'name' => user_hash['full-name'], - 'location' => user_hash['location'], - 'image' => user_hash['mugshot-url'], - 'description' => user_hash['job-title'], - 'urls' => { - 'Yammer' => user_hash['web-url'], - }, - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('/api/v1/users/current.json').body) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth/you_tube.rb b/oa-oauth/lib/omniauth/strategies/oauth/you_tube.rb deleted file mode 100644 index e79a983..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth/you_tube.rb +++ /dev/null @@ -1,75 +0,0 @@ -# Based heavily on the Google strategy, monkeypatch and all -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # - # Authenticate to YouTube via OAuth and retrieve basic user info. - # - # Usage: - # - # use OmniAuth::Strategies::YouTube, 'consumerkey', 'consumersecret' - # - class YouTube < OmniAuth::Strategies::OAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :access_token_path => '/accounts/OAuthGetAccessToken', - :authorize_path => '/accounts/OAuthAuthorizeToken', - :request_token_path => '/accounts/OAuthGetRequestToken', - :site => 'https://www.google.com', - } - super(app, :you_tube, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - ui = user_info - OmniAuth::Utils.deep_merge( - super, { - 'uid' => ui['uid'], - 'user_info' => ui, - 'extra' => { - 'user_hash' => user_hash, - }, - } - ) - end - - def user_info - entry = user_hash['entry'] - { - 'uid' => entry['id']['$t'], - 'nickname' => entry['author'].first['name']['$t'], - 'first_name' => entry['yt$firstName'] && entry['yt$firstName']['$t'], - 'last_name' => entry['yt$lastName'] && entry['yt$lastName']['$t'], - 'image' => entry['media$thumbnail'] && entry['media$thumbnail']['url'], - 'description' => entry['yt$description'] && entry['yt$description']['$t'], - 'location' => entry['yt$location'] && entry['yt$location']['$t'], - } - end - - def user_hash - # YouTube treats 'default' as the currently logged-in user - # via http://apiblog.youtube.com/2010/11/update-to-clientlogin-url.html - @user_hash ||= MultiJson.decode(@access_token.get('http://gdata.youtube.com/feeds/api/users/default?alt=json').body) - end - - # Monkeypatch consumer.get_request_token but specify YouTube scope rather than Google Contacts - # TODO this is an easy patch to the underlying OAuth strategy a la OAuth2 - def request_phase - request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => 'http://gdata.youtube.com'}) - session['oauth'] ||= {} - session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} - r = Rack::Response.new - - if request_token.callback_confirmed? - r.redirect(request_token.authorize_url) - else - r.redirect(request_token.authorize_url(:oauth_callback => callback_url)) - end - - r.finish - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2.rb b/oa-oauth/lib/omniauth/strategies/oauth2.rb deleted file mode 100644 index ce655d5..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'cgi' -require 'uri' -require 'oauth2' -require 'omniauth/oauth' - -module OmniAuth - module Strategies - # Authentication strategy for connecting with APIs constructed using - # the [OAuth 2.0 Specification](http://tools.ietf.org/html/draft-ietf-oauth-v2-10). - # You must generally register your application with the provider and - # utilize an application id and secret in order to authenticate using - # OAuth 2.0. - class OAuth2 - include OmniAuth::Strategy - - # The options passed in to the strategy. - attr_accessor :options - # The `OAuth2::Client` for this strategy. - attr_accessor :client_id, :client_secret, :client_options - - # An error that is indicated in the OAuth 2.0 callback. - # This could be a `redirect_uri_mismatch` or other - class CallbackError < StandardError - attr_accessor :error, :error_reason, :error_uri - - def initialize(error, error_reason=nil, error_uri=nil) - self.error = error - self.error_reason = error_reason - self.error_uri = error_uri - end - end - - # Initialize a new OAuth 2.0 authentication provider. - - # @param [Rack Application] app standard middleware application argument - # @param [String] name the name for this provider to be used in its URL, e.g. `/auth/name` - # @param [String] client_id the client/application ID of this provider - # @param [String] client_secret the client/application secret of this provider - # @param [Hash] options that will be passed through to the OAuth2::Client (see [oauth2 docs](http://rubydoc.info/gems/oauth2)) - def initialize(app, name, client_id=nil, client_secret=nil, client_options={}, options={}, &block) - self.client_id = client_id - self.client_secret = client_secret - self.client_options = client_options - super - end - - def client - ::OAuth2::Client.new(client_id, client_secret, client_options.merge(options[:client_options] || {})) - end - - def callback_url - full_host + script_name + callback_path - end - - protected - - def request_phase - redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(options)) - end - - def callback_phase - if request.params['error'] || request.params['error_reason'] - raise CallbackError.new(request.params['error'], request.params['error_description'] || request.params['error_reason'], request.params['error_uri']) - end - - @access_token = build_access_token - @access_token = client.auth_code.refresh_token(@access_token.refresh_token) if @access_token.expired? - - super - rescue ::OAuth2::Error, CallbackError => e - fail!(:invalid_credentials, e) - rescue ::MultiJson::DecodeError => e - fail!(:invalid_response, e) - rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e - fail!(:timeout, e) - end - - def build_access_token - verifier = request.params['code'] - client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(options)) - rescue ::OAuth2::Error => e - raise e.response.inspect - end - - def auth_hash - credentials = {'token' => @access_token.token} - credentials.merge!('refresh_token' => @access_token.refresh_token) if @access_token.expires? - - OmniAuth::Utils.deep_merge(super, {'credentials' => credentials}) - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/angellist.rb b/oa-oauth/lib/omniauth/strategies/oauth2/angellist.rb deleted file mode 100644 index 8b47285..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/angellist.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to AngelList utilizing OAuth 2.0 and retrieve - # basic user information. - # - # @example Basic Usage - # use OmniAuth::Strategies::AngelList, 'API Key', 'Secret Key' - class AngelList < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application parameter - # @param [String] client_id the application id as [registered on AngelList](http://angel.co/api/oauth/faq) - # @param [String] client_secret the application secret as [registered on AngelList](http://bit.ly/api/oauth/faq ) - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :site => 'https://api.angel.co/', - :authorize_url => 'https://angel.co/api/oauth/authorize', - :token_url => 'https://angel.co/api/oauth/token' - } - - super(app, :angellist, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - } - } - ) - end - - def user_info - { - 'name' => user_data['name'], - 'bio' => user_data['bio'], - 'image' => user_data['image'], - 'urls' => { - 'AngelList' => user_data['angellist_url'], - 'Website' => user_data['online_bio_url'] - }, - } - end - - def user_data - @data ||= begin - @access_token.options[:mode] = :query - @access_token.get('/1/me').parsed - end - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/bitly.rb b/oa-oauth/lib/omniauth/strategies/oauth2/bitly.rb deleted file mode 100644 index 1d9c433..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/bitly.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Bitly utilizing OAuth 2.0 and retrieve - # basic user information. - # - # @example Basic Usage - # use OmniAuth::Strategies::Bitly, 'API Key', 'Secret Key' - class Bitly < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application parameter - # @param [String] client_id the application id as [registered on Bitly](http://bit.ly/a/account) - # @param [String] client_secret the application secret as [registered on Bitly](http://bit.ly/a/account) - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://bit.ly/oauth/authorize', - :token_url => 'https://api-ssl.bit.ly/oauth/access_token', - } - super(app, :bitly, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => @access_token['login'], - 'user_info' => user_data, - 'extra' => { - 'user_hash' => user_data, - }, - } - ) - end - - def user_data - { - 'login' => @access_token['login'], - 'client_id' => @access_token['apiKey'], - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/cobot.rb b/oa-oauth/lib/omniauth/strategies/oauth2/cobot.rb deleted file mode 100644 index b6ff5c3..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/cobot.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Cobot utilizing OAuth 2.0 and retrieve - # basic user information. - # - # @example Basic Usage - # use OmniAuth::Strategies::Cobot, 'Client ID', 'Client Secret' - class Cobot < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application parameter - # @param [String] client_id the application id as [registered on Cobot](https://www.cobot.me/oauth2_clients) - # @param [String] client_secret the application secret as [registered on Cobot](https://www.cobot.me/oauth2_clients) - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://www.cobot.me/oauth2/authorize', - :token_url => 'https://www.cobot.me/oauth2/access_token' - } - super(app, :cobot, client_id, client_secret, client_options, {:scope => 'read write'}.merge(options), &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['login'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - } - } - ) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('https://www.cobot.me/api/user').body) - end - - # OAuth2 by default uses 'Bearer %s' in the header - def build_access_token - access_token = super - access_token.options[:header_format] = "OAuth %s" - access_token - end - - def user_info - { - 'name' => user_data['login'], - 'email' => user_data['email'] - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/dailymile.rb b/oa-oauth/lib/omniauth/strategies/oauth2/dailymile.rb deleted file mode 100644 index 286b461..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/dailymile.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to DailyMile utilizing OAuth 2.0 and retrieve - # basic user information. - # - # @example Basic Usage - # use OmniAuth::Strategies::DailyMile, 'client_id', 'CLIENT_SECRET' - class Dailymile < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application parameter - # @param [String] client_id the application id as [registered on Dailymile](http://www.dailymile.com/api/consumers/new) - # @param [String] cliend_secret the application secret as [registered on Dailymile](http://www.dailymile.com/api/consumers/new) - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://api.dailymile.com/oauth/authorize', - :token_url => 'https://api.dailymile.com/oauth/token', - } - super(app, :dailymile, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['url'].split('/').last, - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - }, - } - ) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('/people/me.json')) - end - - def request_phase - options[:response_type] ||= 'code' - super - end - - def callback_phase - options[:grant_type] ||= 'authorization_code' - super - end - - def user_info - { - 'name' => user_data['display_name'], - 'nickname' => user_data['username'], - 'location' => user_data['location'], - 'image' => user_data['photo_url'], - 'description' => user_data['goal'], - 'urls' => { - 'dailymile' => user_data['url'], - }, - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/doit.rb b/oa-oauth/lib/omniauth/strategies/oauth2/doit.rb deleted file mode 100644 index 657d887..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/doit.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class Doit < OmniAuth::Strategies::OAuth2 - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://openapi.doit.im/oauth/authorize', - :token_url => 'https://openapi.doit.im/oauth/access_token', - } - super(app, :doit, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - }, - } - ) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('https://openapi.doit.im/v1/settings'), {'Authorization' => 'OAuth' + @access_token.token}) - end - - def request_phase - options[:response_type] ||= 'code' - super - end - - def callback_phase - options[:grant_type] ||= 'authorization_code' - super - end - - def user_info - { - 'account' => user_data['account'], - 'username'=> user_data['username'], - 'nickname'=> user_data['nickname'], - 'gender'=> user_data['gender'], - 'week_start'=> user_data['week_start'], - 'birthday_day'=> user_data['birthday_day'], - 'birthday_month'=> user_data['birthday_month'], - 'birthday_year'=> user_data['birthday_year'], - 'language'=> user_data['language'], - 'user_timezone'=> user_data['user_timezone'], - 'remind_email'=> user_data['remind_email'], - 'created'=> user_data['created'], - 'updated'=> user_data['updated'], - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb b/oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb deleted file mode 100644 index c984b8b..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/facebook.rb +++ /dev/null @@ -1,87 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Facebook utilizing OAuth 2.0 and retrieve - # basic user information. - # - # @example Basic Usage - # use OmniAuth::Strategies::Facebook, 'client_id', 'client_secret' - class Facebook < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application parameter - # @param [String] client_id the application id as [registered on Facebook](http://www.facebook.com/developers/) - # @param [String] client_secret the application secret as registered on Facebook - # @option options [String] :scope ('email,offline_access') comma-separated extended permissions such as `email` and `manage_pages` - def initialize(app, client_id=nil, client_secret=nil, options = {}, &block) - client_options = { - :site => 'https://graph.facebook.com/', - :token_url => '/oauth/access_token' - } - - options = { - :parse => :query - }.merge(options) - - super(app, :facebook, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - }, - } - ) - end - - def user_data - @access_token.options[:mode] = :query - @access_token.options[:param_name] = 'access_token' - @data ||= @access_token.get('/me').parsed - rescue ::OAuth2::Error => e - raise e.response.inspect - end - - def request_phase - options[:scope] ||= 'email,offline_access' - super - end - - def build_access_token - if facebook_session.nil? || facebook_session.empty? - super - else - @access_token = ::OAuth2::AccessToken.new(client, facebook_session['access_token'], {:mode => :query, :param_name => 'access_token'}) - end - end - - def facebook_session - session_cookie = request.cookies["fbs_#{client.id}"] - if session_cookie - @facebook_session ||= Rack::Utils.parse_query(request.cookies["fbs_#{client.id}"].gsub('"', '')) - else - nil - end - end - - def user_info - { - 'nickname' => user_data['username'], - 'email' => (user_data['email'] if user_data['email']), - 'first_name' => user_data['first_name'], - 'last_name' => user_data['last_name'], - 'name' => "#{user_data['first_name']} #{user_data['last_name']}", - 'image' => "http://graph.facebook.com/#{user_data['id']}/picture?type=square", - 'urls' => { - 'Facebook' => user_data['link'], - 'Website' => user_data['website'], - }, - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/foursquare.rb b/oa-oauth/lib/omniauth/strategies/oauth2/foursquare.rb deleted file mode 100644 index 3628244..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/foursquare.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class Foursquare < OmniAuth::Strategies::OAuth2 - # Initialize the middleware - # - # @option options [Boolean, true] :sign_in When true, use a sign-in flow instead of the authorization flow. - # @option options [Boolean, false] :mobile When true, use the mobile sign-in interface. - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - options[:sign_in] ||= true - client_options = { - :authorize_url => authorize_url(options), - :token_url => 'https://foursquare.com/oauth2/access_token', - } - super(app, :foursquare, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['response']['user']['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data['response']['user'], - }, - } - ) - end - - def authorize_url(options) - "https://foursquare.com/#{'mobile/' if options[:mobile]}oauth2/#{options[:sign_in] ? 'authenticate' : 'authorize'}" - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('https://api.foursquare.com/v2/users/self', { :params => { 'oauth_token' => @access_token.token } }).body) - end - - def request_phase - options[:response_type] ||= 'code' - super - end - - def callback_phase - options[:grant_type] ||= 'authorization_code' - super - end - - def user_info - { - 'nickname' => user_data['response']['user']['contact']['twitter'], - 'first_name' => user_data['response']['user']['firstName'], - 'last_name' => user_data['response']['user']['lastName'], - 'email' => user_data['response']['user']['contact']['email'], - 'name' => "#{user_data['response']['user']['firstName']} #{user_data['response']['user']['lastName']}".strip, - 'image' => user_data['response']['user']['photo'], - 'phone' => user_data['response']['user']['contact']['phone'], - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/github.rb b/oa-oauth/lib/omniauth/strategies/oauth2/github.rb deleted file mode 100644 index 33bd67c..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/github.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # OAuth 2.0 based authentication with GitHub. In order to - # sign up for an application, you need to [register an application](http://github.com/account/applications/new) - # and provide the proper credentials to this middleware. - class GitHub < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application argument - # @param [String] client_id the application ID for your client - # @param [String] client_secret the application secret - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :site => 'https://api.github.com', - :authorize_url => 'https://github.com/login/oauth/authorize', - :token_url => 'https://github.com/login/oauth/access_token' - } - super(app, :github, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - }, - } - ) - end - - def user_data - @access_token.options[:mode] = :query - @data ||= @access_token.get('/user').parsed - end - - def user_info - { - 'nickname' => user_data['login'], - 'email' => user_data['email'], - 'name' => user_data['name'], - 'urls' => { - 'GitHub' => "http://github.com/#{user_data['login']}", - 'Blog' => user_data['blog'], - }, - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/glitch.rb b/oa-oauth/lib/omniauth/strategies/oauth2/glitch.rb deleted file mode 100644 index 3c06c17..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/glitch.rb +++ /dev/null @@ -1,45 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class Glitch < OmniAuth::Strategies::OAuth2 - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - - # :scope (identity|read|write) is required for authorization and should be passed - # in the OmniAuth :provider options hash in your application - - client_options = { - :site => 'http://api.glitch.com', - :authorize_url => '/oauth2/authorize', - :token_url => '/oauth2/token' - } - super(app, :glitch, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['player_tsid'], - 'user_info' => user_info, - 'extra' => user_data, - } - ) - end - - def user_data - @access_token.options.merge!({:param_name => 'oauth_token', :mode => :query}) - response = @access_token.post('/simple/players.info') - @data ||= MultiJson.decode(response.body) - end - - def user_info - { - 'name' => user_data['user_name'], - 'nickname' => user_data['player_name'], - 'image' => user_data['avatar_url'], - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/gowalla.rb b/oa-oauth/lib/omniauth/strategies/oauth2/gowalla.rb deleted file mode 100644 index 85a4a3a..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/gowalla.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Gowalla utilizing OAuth 2.0 and retrieve - # basic user information. - # - # @example Basic Usage - # use OmniAuth::Strategies::Gowalla, 'API Key', 'Secret Key' - class Gowalla < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application parameter - # @param [String] client_id the application id as [registered on Gowalla](http://gowalla.com/api/keys) - # @param [String] client_secret the application secret as [registered on Gowalla](http://gowalla.com/api/keys) - # @option options ['read','read-write'] :scope ('read') the scope of your authorization request; must be `read` or `read-write` - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://gowalla.com/api/oauth/new', - :token_url => 'https://api.gowalla.com/api/oauth/token', - } - super(app, :gowalla, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['url'].split('/').last, - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - 'refresh_token' => refresh_token, - 'token_expires_at' => token_expires_at, - }, - } - ) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('/users/me.json')) - end - - def refresh_token - @refresh_token ||= @access_token.refresh_token - end - - def token_expires_at - @expires_at ||= @access_token.expires_at - end - - def request_phase - options[:scope] ||= 'read' - super - end - - def user_info - { - 'name' => "#{user_data['first_name']} #{user_data['last_name']}", - 'nickname' => user_data['username'], - 'first_name' => user_data['first_name'], - 'last_name' => user_data['last_name'], - 'location' => user_data['hometown'], - 'description' => user_data['bio'], - 'image' => user_data['image_url'], - 'urls' => { - 'Gowalla' => "http://www.gowalla.com#{user_data['url']}", - 'Website' => user_data['website'], - }, - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/instagram.rb b/oa-oauth/lib/omniauth/strategies/oauth2/instagram.rb deleted file mode 100644 index 67c027d..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/instagram.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Facebook utilizing OAuth 2.0 and retrieve - # basic user information. - # - # @example Basic Usage - # use OmniAuth::Strategies::Instagram, 'client_id', 'client_secret' - class Instagram < OmniAuth::Strategies::OAuth2 - # @option options [String] :scope separate the scopes by a space - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://api.instagram.com/oauth/authorize', - :token_url => 'https://api.instagram.com/oauth/access_token', - } - super(app, :instagram, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['data']['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data['data'], - } - } - ) - end - - def request_phase - options[:scope] ||= 'basic' - options[:response_type] ||= 'code' - super - end - - def callback_phase - options[:grant_type] ||= 'authorization_code' - super - end - - def user_data - @access_token.options.merge!({:param_name => 'access_token', :mode => :query}) - @data ||= MultiJson.decode(@access_token.get('/v1/users/self')) - end - - def user_info - { - 'nickname' => user_data['data']['username'], - 'name' => user_data['data']['full_name'], - 'image' => user_data['data']['profile_picture'], - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/liveid.rb b/oa-oauth/lib/omniauth/strategies/oauth2/liveid.rb deleted file mode 100644 index 2f9f7c2..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/liveid.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Windows Connect utilizing OAuth 2.0 and retrieve - # basic user information. - # - # OAuth 2.0 - MS Documentation - # http://msdn.microsoft.com/en-us/library/hh243647.aspx - # - # Sign-up for account: - # http://go.microsoft.com/fwlink/?LinkId=213332 - # - # @example Basic Usage of Liveid - # - # use OmniAuth::Strategies::Liveid, 'client_id', 'client_secret' - class Liveid < OmniAuth::Strategies::OAuth2 - # @option options [String] :scope separate the scopes by a space - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://oauth.live.com/authorize', - :token_url => 'https://oauth.live.com/token' - } - - super(app, :liveid, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, - { - 'uid' => user_data['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - } - } - ) - end - - def request_phase - options[:scope] ||= 'wl.signin wl.basic' - options[:response_type] ||= 'code' - super - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('https://apis.live.net/v5.0/me').body) - end - - def user_info - { - 'id' => user_data['id'], - 'name' => user_data['name'], - 'email' => '', - 'first_name' => user_data['first_name'], - 'last_name' => user_data['last_name'], - 'link' => user_data['link'], - 'gender' => user_data['gender'], - 'locale' => user_data['locale'] - } - end - - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/mailchimp.rb b/oa-oauth/lib/omniauth/strategies/oauth2/mailchimp.rb deleted file mode 100644 index d0f6b13..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/mailchimp.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class Mailchimp < OmniAuth::Strategies::OAuth2 - - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://login.mailchimp.com/oauth2/authorize', - :token_url => 'https://login.mailchimp.com/oauth2/token', - } - super(app, :mailchimp, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - data = user_data - OmniAuth::Utils.deep_merge( - super, { - 'uid' => @access_token.client.id, - 'extra'=> { - 'user_hash' => data - } - } - ) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get("https://login.mailchimp.com/oauth2/metadata").body) - rescue ::OAuth2::Error => e - if e.response.status == 302 - @data ||= MultiJson.decode(@access_token.get(e.response.headers['location'])) - else - raise e - end - end - end - end -end \ No newline at end of file diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/mailru.rb b/oa-oauth/lib/omniauth/strategies/oauth2/mailru.rb deleted file mode 100644 index 67b20d3..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/mailru.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Vkontakte utilizing OAuth 2.0 and retrieve - # basic user information. - # documentation available here: - # http://api.mail.ru/docs/guides/oauth/sites/ - # - # @example Basic Usage - # use OmniAuth::Strategies::Mailru, 'API Key', 'Secret Key', :private_key => 'Private Key' - class Mailru < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application parameter - # @param [String] client_id the application id as [registered in Mailru] - # @param [String] client_secret the application secret as [registered in Mailru] - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://connect.mail.ru/oauth/authorize', - :token_url => 'https://connect.mail.ru/oauth/token', - } - @private_key = options[:private_key] - super(app, :mailru, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['uid'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - }, - } - ) - end - - def request_phase - options[:response_type] ||= 'code' - super - end - - def calculate_signature(params) - str = params['uids'] + (params.sort.collect { |c| "#{c[0]}=#{c[1]}" }).join('') + @private_key - Digest::MD5.hexdigest(str) - end - - def user_data - request_params = { - 'method' => 'users.getInfo', - 'app_id' => client_id, - 'session_key' => @access_token.token, - 'uids' => @access_token['x_mailru_vid'] - } - - request_params.merge!('sig' => calculate_signature(request_params)) - @data ||= MultiJson.decode(client.request(:get, 'http://www.appsmail.ru/platform/api', request_params))[0] - end - - def user_info - { - 'nickname' => user_data['nick'], - 'email' => user_data['email'], - 'first_name' => user_data['first_name'], - 'last_name' => user_data['last_name'], - 'name' => "#{user_data['first_name']} #{user_data['last_name']}".strip, - 'image' => @data['pic'], - 'urls' => { - 'Mailru' => user_data['link'], - }, - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/mixi.rb b/oa-oauth/lib/omniauth/strategies/oauth2/mixi.rb deleted file mode 100644 index af4ee7e..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/mixi.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Facebook utilizing OAuth 2.0 and retrieve - # basic user information. - # - # @example Basic Usage - # use OmniAuth::Strategies::Mixi, 'client_id', 'client_secret' - class Mixi < OmniAuth::Strategies::OAuth2 - # @option options [String] :scope separate the scopes by a space - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://mixi.jp/connect_authorize.pl', - :token_url => 'https://secure.mixi-platform.com/2/token', - } - super(app, :mixi, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['entry']['id'], - 'user_info' => user_info, - 'credentials' => {'refresh_token' => @access_token.refresh_token}, - 'extra' => { - 'user_hash' => user_data['entry'], - }, - } - ) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get( - 'http://api.mixi-platform.com/2/people/@me/@self', - {'oauth_token' => @access_token.token} - )) - end - - def request_phase - options[:scope] ||= 'r_profile' - options[:display] ||= 'pc' - options[:response_type] ||= 'code' - super - end - - def callback_phase - options[:grant_type] ||= 'authorization_code' - super - end - - def user_info - { - 'nickname' => user_data['entry']['displayName'], - 'image' => user_data['entry']['thumbnailUrl'], - 'urls' => { - :profile => user_data['entry']['profileUrl'], - }, - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/renren.rb b/oa-oauth/lib/omniauth/strategies/oauth2/renren.rb deleted file mode 100644 index 20f266a..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/renren.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' -require 'digest/md5' -require 'net/http' - -module OmniAuth - module Strategies - # Authenticate to Renren utilizing OAuth 2.0 and retrieve - # basic user information. - # - # @example Basic Usage - # use OmniAuth::Strategies::Renren, 'client_id', 'client_secret' - class Renren < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application parameter - # @param [String] client_id the application id as [registered on Renren](http://dev.renren.com/) - # @param [String] client_secret the application secret as registered on Renren - # @option options [String] :scope ('publish_feed,status_update') comma-separated extended permissions such as `publish_feed` and `status_update` - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'http://graph.renren.com/oauth/authorize', - :token_url => 'http://graph.renren.com/oauth/token', - } - super(app, :renren, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['uid'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - }, - } - ) - end - - def user_data - @data ||= MultiJson.decode(Net::HTTP.post_form(URI.parse('http://api.renren.com/restserver.do'), signed_params).body)[0] - end - - def signed_params - params = {} - params[:api_key] = client.id - params[:method] = 'users.getInfo' - params[:call_id] = Time.now.to_i - params[:format] = 'json' - params[:v] = '1.0' - params[:uids] = session_key['user']['id'] - params[:session_key] = session_key['renren_token']['session_key'] - params[:sig] = Digest::MD5.hexdigest(params.map{|k,v| "#{k}=#{v}"}.sort.join + client.secret) - params - end - - def session_key - @session_key ||= MultiJson.decode(@access_token.get('/renren_api/session_key')) - end - - def request_phase - options[:scope] ||= 'publish_feed' - super - end - - def build_access_token - if renren_session.nil? || renrensession.empty? - super - else - @access_token = ::OAuth2::AccessToken.new(client, renren_session['access_token']) - end - end - - def renren_session - session_cookie = request.cookies["rrs_#{client.id}"] - if session_cookie - @renren_session ||= Rack::Utils.parse_query(request.cookies["rrs_#{client.id}"].gsub('"', '')) - else - nil - end - end - - def user_info - { - 'name' => user_data['name'], - 'image' => user_data['tinyurl'], - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/salesforce.rb b/oa-oauth/lib/omniauth/strategies/oauth2/salesforce.rb deleted file mode 100644 index 978490a..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/salesforce.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'omniauth/strategies/oauth2' - -module OmniAuth - module Strategies - class Salesforce < OmniAuth::Strategies::OAuth2 - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://login.salesforce.com/services/oauth2/authorize', - :token_url => 'https://login.salesforce.com/services/oauth2/token', - } - options.merge!(:response_type => 'code', :grant_type => 'authorization_code') - super(app, :salesforce, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - data = user_data - OmniAuth::Utils.deep_merge( - super, { - 'uid' => @access_token['id'], - 'credentials' => { - 'issued_at' => @access_token['issued_at'], - 'refresh_token' => @access_token.refresh_token, - 'instance_url' => @access_token['instance_url'], - 'signature' => @access_token['signature'], - }, - 'extra' => { - 'user_hash' => data, - }, - 'user_info' => { - 'email' => data['email'], - 'name' => data['display_name'], - }, - } - ) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get(@access_token['id'])) - rescue ::OAuth2::Error => e - if e.response.status == 302 - @data ||= MultiJson.decode(@access_token.get(e.response.headers['location'])) - else - raise e - end - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/sound_cloud.rb b/oa-oauth/lib/omniauth/strategies/oauth2/sound_cloud.rb deleted file mode 100644 index 233b5cd..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/sound_cloud.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to SoundCloud via OAuth2 and retrieve basic - # user information. - # - # Usage: - # use OmniAuth::Strategies::SoundCloud, 'consumerkey', 'consumersecret' - class SoundCloud < OmniAuth::Strategies::OAuth2 - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :site => 'https://api.soundcloud.com', - :authorize_url => 'https://soundcloud.com/connect', - :token_url => 'https://api.soundcloud.com/oauth2/token' - } - super(app, :soundcloud, consumer_key, consumer_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_hash['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_hash, - } - } - ) - end - - def user_info - user_hash = self.user_hash - { - 'name' => user_hash['full_name'], - 'nickname' => user_hash['username'], - 'location' => user_hash['city'], - 'description' => user_hash['description'], - 'image' => user_hash['avatar_url'], - 'urls' => { - 'Website' => user_hash['website'], - }, - } - end - - def user_hash - @user_hash ||= MultiJson.decode(@access_token.get('/me.json').body) - end - - # OAuth2 by default uses 'Bearer %s' in the header - def build_access_token - access_token = super - access_token.options[:header_format] = "OAuth %s" - access_token - end - - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/taobao.rb b/oa-oauth/lib/omniauth/strategies/oauth2/taobao.rb deleted file mode 100644 index 1361772..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/taobao.rb +++ /dev/null @@ -1,81 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' -require 'digest/md5' -require 'net/http' - -module OmniAuth - module Strategies - # Authenticate to Renren utilizing OAuth 2.0 and retrieve - # basic user information. - # - # @example Basic Usage - # use OmniAuth::Strategies::TaoBao, 'client_id', 'client_secret' - class Taobao < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application parameter - # @param [String] client_id the app key at taobao open platform - # @param [String] client_secret the app secret at taobao open platform - # @option options [String] - - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://oauth.taobao.com/authorize', - :token_url => 'https://oauth.taobao.com/token', - } - super(app, :taobao, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['uid'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - }, - } - ) - end - - def user_data - # TODO to be moved in options - url = 'http://gw.api.taobao.com/router/rest' - - query_param = { - :app_key => client_id, - - # TODO to be moved in options - # TODO add more default fields (http://my.open.taobao.com/apidoc/index.htm#categoryId:1-dataStructId:3) - :fields => 'user_id,uid,nick,sex,buyer_credit,seller_credit,location,created,last_visit,birthday,type,status,alipay_no,alipay_account,alipay_account,email,consumer_protection,alipay_bind', - :format => 'json', - :method => 'taobao.user.get', - :session => @access_token.token, - :sign_method => 'md5', - :timestamp => Time.now.strftime('%Y-%m-%d %H:%M:%S'), - :v => '2.0' - } - query_param = generate_sign(query_param) - res = Net::HTTP.post_form(URI.parse(url), query_param) - @data ||= MultiJson.decode(res.body)['user_get_response']['user'] - end - - def request_phase - options[:state] ||= '1' - super - end - - def user_info - { - 'name' => user_data['nick'], - 'email' => (user_data['email'] if user_data['email']), - } - end - - def generate_sign(params) - # params.sort.collect { |k, v| "#{k}#{v}" } - str = client_secret + params.sort {|a,b| "#{a[0]}"<=>"#{b[0]}"}.flatten.join + client_secret - params['sign'] = Digest::MD5.hexdigest(str).upcase! - params - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/teambox.rb b/oa-oauth/lib/omniauth/strategies/oauth2/teambox.rb deleted file mode 100644 index 7b225b9..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/teambox.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class Teambox < OmniAuth::Strategies::OAuth2 - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://teambox.com/oauth/authorize', - :token_url => 'https://teambox.com/oauth/token', - } - super(app, :teambox, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data - }, - } - ) - end - - def request_phase - options[:scope] ||= 'offline_access' - options[:response_type] ||= 'code' - super - end - - def callback_phase - options[:grant_type] ||= 'authorization_code' - super - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('/api/1/account')) - end - - def user_info - { - 'nickname' => user_data['username'], - 'name' => user_data['first_name'], - 'image' => user_data['avatar_url'], - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/thirty_seven_signals.rb b/oa-oauth/lib/omniauth/strategies/oauth2/thirty_seven_signals.rb deleted file mode 100644 index d783a19..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/thirty_seven_signals.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class ThirtySevenSignals < OmniAuth::Strategies::OAuth2 - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://launchpad.37signals.com/authorization/new', - :token_url => 'https://launchpad.37signals.com/authorization/token', - } - super(app, :thirty_seven_signals, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['identity']['id'], - 'user_info' => user_info, - 'extra' => { - 'accounts' => user_data['accounts'], - } - } - ) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('/authorization.json')) - end - - def user_info - { - 'email' => user_data['identity']['email_address'], - 'first_name' => user_data['identity']['first_name'], - 'last_name' => user_data['identity']['last_name'], - 'name' => [user_data['identity']['first_name'], user_data['identity']['last_name']].join(' ').strip, - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/viadeo.rb b/oa-oauth/lib/omniauth/strategies/oauth2/viadeo.rb deleted file mode 100644 index dd99077..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/viadeo.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Viadeo utilizing OAuth 2.0 and retrieve - # basic user information. - # - # @example Basic Usage - # use OmniAuth::Strategies::Viadeo, 'client_id', 'client_secret' - class Viadeo < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application parameter - # @param [String] client_id the application id as [registered on Viadeo](http://dev.viadeo.com/) - # @param [String] client_secret the application secret as registered on Facebook - def initialize(app, client_id=nil, client_secret=nil, options = {}, &block) - client_options = { - :site => 'https://api.viadeo.com/', - :authorize_url => 'https://secure.viadeo.com/oauth-provider/authorize2', - :token_url => 'https://secure.viadeo.com/oauth-provider/access_token2' - } - super(app, :viadeo, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - }, - } - ) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('/me').body) - end - - def request_phase - options[:response_type] ||= 'code' - super - end - - def callback_phase - options[:grant_type] ||= 'authorization_code' - super - end - - def user_info - { - 'name' => user_data['name'], - 'link' => user_data['link'], - 'first_name' => user_data['first_name'], - 'last_name' => user_data['last_name'], - 'gender' => user_data['gender'], - 'nickname' => user_data['nickname'], - 'has_picture' => user_data['has_picture'] , - 'picture_small' => user_data['picture_small'], - 'picture_large' => user_data['picture_large'], - 'headline' => user_data['headline'], - 'introduction' => user_data['introduction'], - 'interests' => user_data['interests'], - 'location' => user_data['location'], - 'is_premium' => user_data['is_premium'], - 'premium_since' => user_data['premium_since'] - } - end - - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/vkontakte.rb b/oa-oauth/lib/omniauth/strategies/oauth2/vkontakte.rb deleted file mode 100644 index d7fe983..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/vkontakte.rb +++ /dev/null @@ -1,104 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # Authenticate to Vkontakte utilizing OAuth 2.0 and retrieve - # basic user information. - # documentation available here: - # http://vkontakte.ru/developers.php?o=-17680044&p=Authorization&s=0 - # - # @example Basic Usage - # use OmniAuth::Strategies::Vkontakte, 'API Key', 'Secret Key' - class Vkontakte < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application parameter - # @param [String] client_id the application id as [registered in Vkontakte] - # @param [String] client_secret the application secret as [registered in Vkontakte] - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'http://api.vkontakte.ru/oauth/authorize', - :token_url => 'https://api.vkontakte.ru/oauth/token', - } - super(app, :vkontakte, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - # process user's info - user_data - OmniAuth::Utils.deep_merge( - super, { - 'uid' => @data['uid'], - 'user_info' => user_info, - 'extra' => user_hash, - } - ) - end - - def user_data - # http://vkontakte.ru/developers.php?o=-17680044&p=Description+of+Fields+of+the+fields+Parameter - @fields ||= ['uid', 'first_name', 'last_name', 'nickname', 'domain', 'sex', 'bdate', 'city', 'country', 'timezone', 'photo', 'photo_big'] - - # http://vkontakte.ru/developers.php?o=-1&p=getProfiles - response = @access_token.get('https://api.vkontakte.ru/method/getProfiles', - :params => {:uid => @access_token['user_id'], :fields => @fields.join(',')}, :parse => :json) - @data ||= response.parsed['response'][0] - - # we need these 2 additional requests since vkontakte returns only ids of the City and Country - # http://vkontakte.ru/developers.php?o=-17680044&p=getCities - response = @access_token.get('https://api.vkontakte.ru/method/getCities', - :params => {:cids => @data['city']}, :parse => :json) - cities = response.parsed['response'] - @city ||= cities.first['name'] if cities && cities.first - - # http://vkontakte.ru/developers.php?o=-17680044&p=getCountries - response = @access_token.get('https://api.vkontakte.ru/method/getCountries', - :params => {:cids => @data['country']}, :parse => :json) - countries = response.parsed['response'] - @country ||= countries.first['name'] if countries && countries.first - end - - def request_phase - options[:response_type] ||= 'code' - super - end - - def build_access_token - token = super - # indicates that `offline` permission was granted, no need to the token refresh - if token.expires_in == 0 - ::OAuth2::AccessToken.new(token.client, token.token, - token.params.reject{|k,_| [:refresh_token, :expires_in, :expires_at, :expires].include? k.to_sym} - ) - else - token - end - end - - def user_info - { - 'first_name' => @data['first_name'], - 'last_name' => @data['last_name'], - 'name' => "#{@data['first_name']} #{@data['last_name']}".strip, - 'nickname' => @data['nickname'], - 'birth_date' => @data['bdate'], - 'image' => @data['photo'], - 'location' => "#{@country}, #{@city}", - 'urls' => { - 'Vkontakte' => "http://vkontakte.ru/#{@data['domain']}", - }, - } - end - - def user_hash - { - 'user_hash' => { - 'gender' => @data['sex'], - 'timezone' => @data['timezone'], - # 200px maximum resolution of the avatar (http://vkontakte.ru/developers.php?o=-17680044&p=Description+of+Fields+of+the+fields+Parameter) - 'photo_big' => @data['photo_big'], - } - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/oauth2/we_pay.rb b/oa-oauth/lib/omniauth/strategies/oauth2/we_pay.rb deleted file mode 100644 index 3f887af..0000000 --- a/oa-oauth/lib/omniauth/strategies/oauth2/we_pay.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - # OAuth 2.0 based authentication with WePay. In order to - # sign up for an application, you need to [register an application](https://wepay.com/developer/register) - # and provide the proper credentials to this middleware. - class WePay < OmniAuth::Strategies::OAuth2 - # @param [Rack Application] app standard middleware application argument - # @param [String] client_id the application ID for your client - # @param [String] client_secret the application secret - def initialize(app, client_id=nil, client_secret=nil, options={}, &block) - client_options = { - :authorize_url => 'https://www.wepay.com/session/authorize', - :token_url => 'https://wepayapi.com/v1/oauth2/token', - } - super(app, :we_pay, client_id, client_secret, client_options, options, &block) - end - - def auth_hash - OmniAuth::Utils.deep_merge( - super, { - 'uid' => user_data['user_id'], - 'user_info' => user_info, - 'extra' => { - 'user_hash' => user_data, - }, - } - ) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('/v1/user'))['result'] - end - - def user_info - { - 'email' => user_data['email'], - 'name' => "#{user_data['firstName']} #{user_data['lastName']}".strip, - 'first_name' => user_data['firstName'], - 'last_name' => user_data['lastName'], - 'image' => user_data['picture'], - } - end - end - end -end diff --git a/oa-oauth/lib/omniauth/strategies/xauth.rb b/oa-oauth/lib/omniauth/strategies/xauth.rb deleted file mode 100644 index ebed62d..0000000 --- a/oa-oauth/lib/omniauth/strategies/xauth.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class XAuth - attr_reader :name - attr_accessor :consumer_key, :consumer_secret, :consumer_options - - include OmniAuth::Strategy - - def initialize(app, name, consumer_key=nil, consumer_secret=nil, consumer_options={}, options={}, &block) - self.consumer_key = consumer_key - self.consumer_secret = consumer_secret - self.consumer_options = consumer_options - super - end - - def request_phase - session['oauth'] ||= {} - if env['REQUEST_METHOD'] == 'GET' - get_credentials - else - session['omniauth.xauth'] = { 'x_auth_mode' => 'client_auth', 'x_auth_username' => request['username'], 'x_auth_password' => request['password'] } - redirect callback_path - end - end - - def get_credentials - OmniAuth::Form.build(consumer_options[:title] || "xAuth Credentials") do - text_field 'Username', 'username' - password_field 'Password', 'password' - end.to_response - end - - def consumer - ::OAuth::Consumer.new(consumer_key, consumer_secret, consumer_options.merge(options[:client_options] || options[:consumer_options] || {})) - end - - def callback_phase - @access_token = consumer.get_access_token(nil, {}, session['omniauth.xauth']) - super - rescue ::Net::HTTPFatalError => e - fail!(:service_unavailable, e) - rescue ::OAuth::Unauthorized => e - fail!(:invalid_credentials, e) - rescue ::MultiJson::DecodeError => e - fail!(:invalid_response, e) - ensure - session['omniauth.xauth'] = nil - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'credentials' => { - 'token' => @access_token.token, - 'secret' => @access_token.secret - }, 'extra' => { - 'access_token' => @access_token - } - }) - end - - end - end -end - diff --git a/oa-oauth/lib/omniauth/strategies/xauth/instapaper.rb b/oa-oauth/lib/omniauth/strategies/xauth/instapaper.rb deleted file mode 100644 index dfdac81..0000000 --- a/oa-oauth/lib/omniauth/strategies/xauth/instapaper.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'omniauth/oauth' -require 'multi_json' - -module OmniAuth - module Strategies - class Instapaper < OmniAuth::Strategies::XAuth - def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) - client_options = { - :token_url => 'https://www.instapaper.com/api/1/oauth/access_token', - } - super(app, :instapaper, consumer_key, consumer_secret, client_options, options, &block) - end - - def user_data - @data ||= MultiJson.decode(@access_token.get('/api/1/account/verify_credentials').body)[0] - end - - def user_info - { - 'nickname' => user_data['username'], - 'name' => user_data['username'], - } - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, - { - 'uid' => user_data['user_id'], - 'user_info' => user_info, - } - ) - end - - end - end -end - diff --git a/oa-oauth/lib/omniauth/version.rb b/oa-oauth/lib/omniauth/version.rb deleted file mode 100644 index 9f980b0..0000000 --- a/oa-oauth/lib/omniauth/version.rb +++ /dev/null @@ -1,19 +0,0 @@ -module OmniAuth - module Version - unless defined?(::OmniAuth::Version::MAJOR) - MAJOR = 0 - end - unless defined?(::OmniAuth::Version::MINOR) - MINOR = 3 - end - unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 - end - unless defined?(::OmniAuth::Version::PRE) - PRE = "rc3" - end - unless defined?(::OmniAuth::Version::STRING) - STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') - end - end -end diff --git a/oa-oauth/oa-oauth.gemspec b/oa-oauth/oa-oauth.gemspec deleted file mode 100644 index 89c0149..0000000 --- a/oa-oauth/oa-oauth.gemspec +++ /dev/null @@ -1,31 +0,0 @@ -# encoding: utf-8 -require File.expand_path('../lib/omniauth/version', __FILE__) - -Gem::Specification.new do |gem| - gem.add_dependency 'faraday', '~> 0.7.3' - gem.add_dependency 'multi_json', '~> 1.0.0' - gem.add_dependency 'multi_xml', '~> 0.3.0' - gem.add_dependency 'oa-core', OmniAuth::Version::STRING - gem.add_dependency 'oauth', '~> 0.4.0' - gem.add_dependency 'oauth2', '~> 0.5.0' - gem.add_development_dependency 'evernote', '~> 1.0' - gem.add_development_dependency 'rack-test', '~> 0.5' - gem.add_development_dependency 'rake', '~> 0.8' - gem.add_development_dependency 'rdiscount', '~> 1.6' - gem.add_development_dependency 'rspec', '~> 2.5' - gem.add_development_dependency 'simplecov', '~> 0.4' - gem.add_development_dependency 'vcr', '~> 1.10' - gem.add_development_dependency 'webmock', '~> 1.7' - gem.add_development_dependency 'yard', '~> 0.7' - gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober'] - gem.description = %q{OAuth strategies for OmniAuth.} - gem.email = ['michael@intridea.com', 'sferik@gmail.com'] - gem.files = `git ls-files`.split("\n") - gem.homepage = 'http://github.com/intridea/omniauth' - gem.name = 'oa-oauth' - gem.require_paths = ['lib'] - gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version= - gem.summary = gem.description - gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - gem.version = OmniAuth::Version::STRING -end diff --git a/oa-oauth/spec/fixtures/basecamp_200.xml b/oa-oauth/spec/fixtures/basecamp_200.xml deleted file mode 100644 index 8312acd..0000000 --- a/oa-oauth/spec/fixtures/basecamp_200.xml +++ /dev/null @@ -1,24 +0,0 @@ - - 0 - 2008-08-14T00:00:00Z - 1827370 - - AOL - - - - - - - <token>5fc2ab4f6c2f9cdf12ed01b88e7554f8ad21bbfb</token> - <updated-at type="datetime">2010-05-24T11:59:34Z</updated-at> - <uuid>b11312ca-227d-36fd-e3b5-af2f419-a650</uuid> - <first-name>Sally</first-name> - <last-name>Fried</last-name> - <company-id type="integer">1042368</company-id> - <user-name/> - <email-address>sfried@example.org</email-address> - <avatar-url> - http://asset3.37img.com/75521bbf128b89b7ec2ab5fe98ad21b4f6ad21e/avatar.png?r=3 - </avatar-url> -</person> diff --git a/oa-oauth/spec/fixtures/campfire_200.json b/oa-oauth/spec/fixtures/campfire_200.json deleted file mode 100644 index ef72564..0000000 --- a/oa-oauth/spec/fixtures/campfire_200.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "user": { - "id": 92718, - "name": "Kenneth Szell", - "email_address": "kens@example.org", - "admin": true, - "created_at": "2009-07-20T09:21:34Z", - "type": "Member" - } -} diff --git a/oa-oauth/spec/omniauth/strategies/google_oauth2_spec.rb b/oa-oauth/spec/omniauth/strategies/google_oauth2_spec.rb deleted file mode 100644 index 7ab0f84..0000000 --- a/oa-oauth/spec/omniauth/strategies/google_oauth2_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) - -describe OmniAuth::Strategies::GoogleOAuth2 do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/dopplr_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/dopplr_spec.rb deleted file mode 100644 index 859ba76..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/dopplr_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Dopplr do - it_should_behave_like "an oauth strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/douban_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/douban_spec.rb deleted file mode 100644 index 849b29a..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/douban_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Douban do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/dropbox_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/dropbox_spec.rb deleted file mode 100644 index ec0a1a5..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/dropbox_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Dropbox do - it_should_behave_like "an oauth strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/evernote_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/evernote_spec.rb deleted file mode 100644 index cc67239..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/evernote_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Evernote do - it_should_behave_like "an oauth strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/flattr_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/flattr_spec.rb deleted file mode 100644 index 3afe23c..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/flattr_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Flattr do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/flickr_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/flickr_spec.rb deleted file mode 100644 index 98944a3..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/flickr_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Flickr do - it_should_behave_like "an oauth strategy" -end - diff --git a/oa-oauth/spec/omniauth/strategies/oauth/goodreads_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/goodreads_spec.rb deleted file mode 100644 index d44200a..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/goodreads_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Goodreads do - it_should_behave_like 'an oauth strategy' -end - diff --git a/oa-oauth/spec/omniauth/strategies/oauth/google_health_sandbox_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/google_health_sandbox_spec.rb deleted file mode 100644 index 604a205..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/google_health_sandbox_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::GoogleHealthSandbox do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/google_health_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/google_health_spec.rb deleted file mode 100644 index 51c57fb..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/google_health_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::GoogleHealth do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/google_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/google_spec.rb deleted file mode 100644 index 9336939..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/google_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Google do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/hyves_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/hyves_spec.rb deleted file mode 100644 index 5bdb952..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/hyves_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Hyves do - it_should_behave_like "an oauth strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/identica_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/identica_spec.rb deleted file mode 100644 index a5df866..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/identica_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Identica do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/linked_in_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/linked_in_spec.rb deleted file mode 100644 index 535a1bb..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/linked_in_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::LinkedIn do - it_should_behave_like "an oauth strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/meetup_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/meetup_spec.rb deleted file mode 100644 index f9e79a3..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/meetup_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Meetup do - it_should_behave_like 'an oauth strategy' - it 'should use the authenticate (sign in) URL by default' do - s = strategy_class.new(app, 'abc', 'def') - s.consumer.options[:authorize_path].should == 'http://www.meetup.com/authenticate' - end - - it 'should use the authorize URL if :sign_in is false' do - s = strategy_class.new(app, 'abc', 'def', :sign_in => false) - s.consumer.options[:authorize_path].should == 'http://www.meetup.com/authorize' - end -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/miso_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/miso_spec.rb deleted file mode 100644 index 5d43693..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/miso_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Miso do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/netflix_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/netflix_spec.rb deleted file mode 100644 index f09f7ac..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/netflix_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Netflix do - it_should_behave_like "an oauth strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/oauth_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/oauth_spec.rb deleted file mode 100644 index 9d09a2c..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/oauth_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'spec_helper' - -describe "OmniAuth::Strategies::OAuth" do - - def app - Rack::Builder.new { - use OmniAuth::Test::PhonySession - use OmniAuth::Builder do - provider :oauth, 'example.org', 'abc', 'def', :site => 'https://api.example.org' - provider :oauth, 'example.org_with_authorize_params', 'abc', 'def', { :site => 'https://api.example.org' }, :authorize_params => {:abc => 'def'} - end - run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] } - }.to_app - end - - def session - last_request.env['rack.session'] - end - - before do - stub_request(:post, 'https://api.example.org/oauth/request_token'). - to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret&oauth_callback_confirmed=true") - end - - describe '/auth/{name}' do - context 'successful' do - before do - get '/auth/example.org' - end - it 'should redirect to authorize_url' do - last_response.should be_redirect - last_response.headers['Location'].should == 'https://api.example.org/oauth/authorize?oauth_token=yourtoken' - end - - it 'should redirect to authorize_url with authorize_params when set' do - get '/auth/example.org_with_authorize_params' - last_response.should be_redirect - [ - 'https://api.example.org/oauth/authorize?abc=def&oauth_token=yourtoken', - 'https://api.example.org/oauth/authorize?oauth_token=yourtoken&abc=def' - ].should be_include(last_response.headers['Location']) - end - - it 'should set appropriate session variables' do - session['oauth'].should == {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}} - end - end - - context 'unsuccessful' do - before do - stub_request(:post, 'https://api.example.org/oauth/request_token'). - to_raise(::Net::HTTPFatalError.new(%Q{502 "Bad Gateway"}, nil)) - get '/auth/example.org' - end - - it 'should call fail! with :service_unavailable' do - last_request.env['omniauth.error'].should be_kind_of(::Net::HTTPFatalError) - last_request.env['omniauth.error.type'] = :service_unavailable - end - - context "SSL failure" do - before do - stub_request(:post, 'https://api.example.org/oauth/request_token'). - to_raise(::OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed")) - get '/auth/example.org' - end - - it 'should call fail! with :service_unavailable' do - last_request.env['omniauth.error'].should be_kind_of(::OpenSSL::SSL::SSLError) - last_request.env['omniauth.error.type'] = :service_unavailable - end - end - end - end - - describe '/auth/{name}/callback' do - before do - stub_request(:post, 'https://api.example.org/oauth/access_token'). - to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret") - get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}} - end - - it 'should exchange the request token for an access token' do - last_request.env['omniauth.auth']['provider'].should == 'example.org' - last_request.env['omniauth.auth']['extra']['access_token'].should be_kind_of(OAuth::AccessToken) - end - - it 'should call through to the master app' do - last_response.body.should == 'true' - end - - context "bad gateway (or any 5xx) for access_token" do - before do - stub_request(:post, 'https://api.example.org/oauth/access_token'). - to_raise(::Net::HTTPFatalError.new(%Q{502 "Bad Gateway"}, nil)) - get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}} - end - - it 'should call fail! with :service_unavailable' do - last_request.env['omniauth.error'].should be_kind_of(::Net::HTTPFatalError) - last_request.env['omniauth.error.type'] = :service_unavailable - end - end - - context "SSL failure" do - before do - stub_request(:post, 'https://api.example.org/oauth/access_token'). - to_raise(::OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed")) - get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}} - end - - it 'should call fail! with :service_unavailable' do - last_request.env['omniauth.error'].should be_kind_of(::OpenSSL::SSL::SSLError) - last_request.env['omniauth.error.type'] = :service_unavailable - end - end - end - - describe '/auth/{name}/callback with expired session' do - before do - stub_request(:post, 'https://api.example.org/oauth/access_token'). - to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret") - get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {}} - end - - it 'should call fail! with :session_expired' do - last_request.env['omniauth.error'].should be_kind_of(::OmniAuth::NoSessionError) - last_request.env['omniauth.error.type'] = :session_expired - end - end -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/orkut_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/orkut_spec.rb deleted file mode 100644 index 7562ff4..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/orkut_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Orkut do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/plurk_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/plurk_spec.rb deleted file mode 100644 index 01c5d41..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/plurk_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Plurk do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/rdio_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/rdio_spec.rb deleted file mode 100644 index 4821c4e..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/rdio_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Rdio do - it_should_behave_like "an oauth strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/smug_mug_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/smug_mug_spec.rb deleted file mode 100644 index 3ee8292..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/smug_mug_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::SmugMug do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/t163_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/t163_spec.rb deleted file mode 100644 index f9f2113..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/t163_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::T163 do - it_should_behave_like "an oauth strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/trade_me_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/trade_me_spec.rb deleted file mode 100644 index 116ccae..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/trade_me_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::TradeMe do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/trip_it_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/trip_it_spec.rb deleted file mode 100644 index 354cb4d..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/trip_it_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::TripIt do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/tsina_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/tsina_spec.rb deleted file mode 100644 index a29452d..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/tsina_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Tsina do - it_should_behave_like "an oauth strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/tumblr_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/tumblr_spec.rb deleted file mode 100644 index 2508d29..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/tumblr_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Tumblr do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/twitter_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/twitter_spec.rb deleted file mode 100644 index cd28523..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/twitter_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Twitter do - it_should_behave_like 'an oauth strategy' - - def app - Rack::Builder.new { - use OmniAuth::Test::PhonySession - use OmniAuth::Builder do - provider :twitter, 'abc', 'def' - end - run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] } - }.to_app - end - - it 'should use the authorize path by default' do - s = strategy_class.new(app, 'abc', 'def') - s.consumer.options[:authorize_path].should == '/oauth/authorize' - end - - it 'should set options[:authorize_params] to { :force_login => "true" } if :force_login is true' do - s = strategy_class.new(app, 'abc', 'def', :force_login => true) - s.options[:authorize_params].should == { :force_login => 'true' } - end - - it 'should use the authorize path if :sign_in is false' do - s = strategy_class.new(app, 'abc', 'def', :sign_in => false) - s.consumer.options[:authorize_path].should == '/oauth/authorize' - end - - it 'should properly handle a timeout when fetching the user hash' do - stub_request(:post, 'https://api.twitter.com/oauth/access_token'). - to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret") - - stub_request(:get, "https://api.twitter.com/1/account/verify_credentials.json"). - to_raise(Errno::ETIMEDOUT) - - get '/auth/twitter/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"twitter" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}} - - last_request.env['omniauth.error'].should be_kind_of(::Timeout::Error) - last_request.env['omniauth.error.type'] = :service_unavailable - end -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/type_pad_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/type_pad_spec.rb deleted file mode 100644 index c3f691f..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/type_pad_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::TypePad do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/vimeo_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/vimeo_spec.rb deleted file mode 100644 index cfe2547..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/vimeo_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Vimeo do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/yahoo_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/yahoo_spec.rb deleted file mode 100644 index c2d979e..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/yahoo_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Yahoo do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/yammer_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/yammer_spec.rb deleted file mode 100644 index b63ed22..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/yammer_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Yammer do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth/you_tube_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth/you_tube_spec.rb deleted file mode 100644 index ad70973..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth/you_tube_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::YouTube do - it_should_behave_like 'an oauth strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/angellist_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/angellist_spec.rb deleted file mode 100644 index e396d4a..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/angellist_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::AngelList do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/bitly_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/bitly_spec.rb deleted file mode 100644 index 227f2e2..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/bitly_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Bitly do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/cobot_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/cobot_spec.rb deleted file mode 100644 index f22a718..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/cobot_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Cobot do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/dailymile_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/dailymile_spec.rb deleted file mode 100644 index 55e8c16..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/dailymile_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Dailymile do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/doit_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/doit_spec.rb deleted file mode 100644 index 9c64a9e..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/doit_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Doit do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/facebook_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/facebook_spec.rb deleted file mode 100644 index eda8c28..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/facebook_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Facebook do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/foursquare_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/foursquare_spec.rb deleted file mode 100644 index 4f9888c..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/foursquare_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Foursquare do - it_should_behave_like "an oauth2 strategy" - subject{ OmniAuth::Strategies::Foursquare.new(lambda{|env|[200,{},[""]]} , 'abc', 'def')} - - it 'should use the mobile authorize url when :mobile is true' do - subject.authorize_url(:mobile => true).should be_include("/mobile/") - end - - it 'should use the authorize endpoint if :sign_in is false' do - subject.authorize_url(:sign_in => false).should be_include("/authorize") - end - - it 'should default to the authenticate endpoint' do - subject.client.authorize_url.should be_include('/authenticate') - end -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/github_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/github_spec.rb deleted file mode 100644 index aa4f259..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/github_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::GitHub do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/glitch_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/glitch_spec.rb deleted file mode 100644 index e771ab6..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/glitch_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Glitch do - it_should_behave_like 'an oauth2 strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/gowalla_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/gowalla_spec.rb deleted file mode 100644 index bdf79a0..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/gowalla_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Gowalla do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/instagram_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/instagram_spec.rb deleted file mode 100644 index 2a00ec7..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/instagram_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Instagram do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/liveid_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/liveid_spec.rb deleted file mode 100644 index 6357c30..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/liveid_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Liveid do - it_should_behave_like 'an oauth2 strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/mailchimp_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/mailchimp_spec.rb deleted file mode 100644 index 2ea822d..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/mailchimp_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -# oa-oauth/spec/omniauth/strategies/rdio_spec.rb -require File.expand_path('../../../../spec_helper', __FILE__) - -describe OmniAuth::Strategies::Mailchimp do - it_should_behave_like "an oauth2 strategy" -end \ No newline at end of file diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/mailru_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/mailru_spec.rb deleted file mode 100644 index 0e64f88..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/mailru_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Mailru do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/salesforce_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/salesforce_spec.rb deleted file mode 100644 index 2bd7442..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/salesforce_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Salesforce do - it_should_behave_like 'an oauth2 strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/sound_cloud_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/sound_cloud_spec.rb deleted file mode 100644 index df47c0e..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/sound_cloud_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::SoundCloud do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/taobao_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/taobao_spec.rb deleted file mode 100644 index f995879..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/taobao_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Taobao do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/teambox_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/teambox_spec.rb deleted file mode 100644 index 8a969ea..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/teambox_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Teambox do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/thirty_seven_signals_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/thirty_seven_signals_spec.rb deleted file mode 100644 index 7f54fb9..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/thirty_seven_signals_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::ThirtySevenSignals do - it_should_behave_like 'an oauth2 strategy' -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/viadeo_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/viadeo_spec.rb deleted file mode 100644 index d692987..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/viadeo_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Viadeo do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/vkontakte_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/vkontakte_spec.rb deleted file mode 100644 index 99165fb..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/vkontakte_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::Vkontakte do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/omniauth/strategies/oauth2/we_pay_spec.rb b/oa-oauth/spec/omniauth/strategies/oauth2/we_pay_spec.rb deleted file mode 100644 index 83c3488..0000000 --- a/oa-oauth/spec/omniauth/strategies/oauth2/we_pay_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe OmniAuth::Strategies::WePay do - it_should_behave_like "an oauth2 strategy" -end diff --git a/oa-oauth/spec/spec_helper.rb b/oa-oauth/spec/spec_helper.rb deleted file mode 100644 index 4b3b371..0000000 --- a/oa-oauth/spec/spec_helper.rb +++ /dev/null @@ -1,31 +0,0 @@ -$:.unshift File.expand_path('..', __FILE__) -$:.unshift File.expand_path('../../lib', __FILE__) -require 'simplecov' -SimpleCov.start -require 'rspec' -require 'rack/test' -require 'webmock/rspec' -require 'vcr' -require 'omniauth/core' -require 'omniauth/test' -require 'omniauth/oauth' -require File.expand_path('../support/shared_examples', __FILE__) - -RSpec.configure do |config| - config.include WebMock::API - config.extend VCR::RSpec::Macros - config.include Rack::Test::Methods - config.extend OmniAuth::Test::StrategyMacros, :type => :strategy -end - -def strategy_class - meta = self.class.metadata - while meta.key?(:example_group) - meta = meta[:example_group] - end - meta[:describes] -end - -def app - lambda{|env| [200, {}, ['Hello']]} -end diff --git a/oa-oauth/spec/support/shared_examples.rb b/oa-oauth/spec/support/shared_examples.rb deleted file mode 100644 index 5e6cf95..0000000 --- a/oa-oauth/spec/support/shared_examples.rb +++ /dev/null @@ -1,29 +0,0 @@ -shared_examples_for "an oauth strategy" do - it 'should be initializable with only three arguments' do - lambda{ strategy_class.new(lambda{|env| [200, {}, ['Hello World']]}, 'key', 'secret') }.should_not raise_error - end - - it 'should be initializable with a block' do - lambda{ strategy_class.new(lambda{|env| [200, {}, ['Hello World']]}){|s| s.consumer_key = 'abc'} }.should_not raise_error - end - - it 'should handle the setting of client options' do - s = strategy_class.new(lambda{|env| [200, {}, ['Hello World']]}, 'key', 'secret', :client_options => {:abc => 'def'}) - s.consumer.options[:abc].should == 'def' - end -end - -shared_examples_for "an oauth2 strategy" do - it 'should be initializable with only three arguments' do - lambda{ strategy_class.new(lambda{|env| [200, {}, ['Hello World']]}, 'key', 'secret') }.should_not raise_error - end - - it 'should be initializable with a block' do - lambda{ strategy_class.new(lambda{|env| [200, {}, ['Hello World']]}){|s| s.client_id = 'abc'} }.should_not raise_error - end - - it 'should handle the setting of client options' do - s = strategy_class.new(lambda{|env| [200, {}, ['Hello World']]}, 'key', 'secret', :client_options => {:abc => 'def'}) - s.client.options[:abc].should == 'def' - end -end diff --git a/oa-openid/.gemtest b/oa-openid/.gemtest deleted file mode 100644 index e69de29..0000000 diff --git a/oa-openid/.rspec b/oa-openid/.rspec deleted file mode 100644 index bb259fe..0000000 --- a/oa-openid/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---color ---format=nested ---backtrace diff --git a/oa-openid/.yardopts b/oa-openid/.yardopts deleted file mode 100644 index 7a69ee4..0000000 --- a/oa-openid/.yardopts +++ /dev/null @@ -1,4 +0,0 @@ ---markup markdown ---markup-provider maruku -- -LICENSE diff --git a/oa-openid/Gemfile b/oa-openid/Gemfile deleted file mode 100644 index 8b4c6c7..0000000 --- a/oa-openid/Gemfile +++ /dev/null @@ -1,12 +0,0 @@ -require File.expand_path('../lib/omniauth/version', __FILE__) - -source 'http://rubygems.org' - -gem 'oa-core', OmniAuth::Version::STRING, :path => '../oa-core' -gem 'oa-oauth', OmniAuth::Version::STRING, :path => '../oa-oauth' - -platforms :jruby do - gem 'jruby-openssl', '~> 0.7' -end - -gemspec diff --git a/oa-openid/LICENSE b/oa-openid/LICENSE deleted file mode 100644 index 811fa0e..0000000 --- a/oa-openid/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/oa-openid/README.rdoc b/oa-openid/README.rdoc deleted file mode 100644 index ae2cf2e..0000000 --- a/oa-openid/README.rdoc +++ /dev/null @@ -1,51 +0,0 @@ -= OmniAuth::OpenID - -Provides strategies for authenticating to providers using the OpenID standard. - -== Installation - -To get just OpenID functionality: - - gem install oa-openid - -For the full auth suite: - - gem install omniauth - -== Stand-Alone Example - -Use the strategy as a middleware in your application: - - require 'omniauth/openid' - require 'openid/store/filesystem' - - use Rack::Session::Cookie - use OmniAuth::Strategies::OpenID, OpenID::Store::Filesystem.new('/tmp') - -Then simply direct users to '/auth/open_id' to prompt them for their OpenID identifier. You may also pre-set the identifier by passing an <tt>identifier</tt> parameter to the URL (Example: <tt>/auth/open_id?openid_url=yahoo.com</tt>). - -A list of all OpenID stores is available at http://github.com/openid/ruby-openid/tree/master/lib/openid/store/ - -== OmniAuth Builder - -If OpenID is one of several authentication strategies, use the OmniAuth Builder: - - require 'omniauth/openid' - require 'omniauth/basic' # for Campfire - require 'openid/store/filesystem' - - use OmniAuth::Builder do - provider :open_id, OpenID::Store::Filesystem.new('/tmp') - provider :campfire - end - -== Configured Identifiers - -You may pre-configure an OpenID identifier. For example, to use Google's main OpenID endpoint: - - use OmniAuth::Builder do - provider :open_id, nil, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id' - end - -Note the use of nil, which will trigger ruby-openid's default Memory Store. - diff --git a/oa-openid/Rakefile b/oa-openid/Rakefile deleted file mode 100644 index 69797fc..0000000 --- a/oa-openid/Rakefile +++ /dev/null @@ -1,6 +0,0 @@ -require 'bundler' -Bundler::GemHelper.install_tasks -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) -task :default => :spec -task :test => :spec diff --git a/oa-openid/lib/oa-openid.rb b/oa-openid/lib/oa-openid.rb deleted file mode 100644 index 75bdb28..0000000 --- a/oa-openid/lib/oa-openid.rb +++ /dev/null @@ -1 +0,0 @@ -require 'omniauth/openid' diff --git a/oa-openid/lib/omniauth/openid.rb b/oa-openid/lib/omniauth/openid.rb deleted file mode 100644 index 03a78f9..0000000 --- a/oa-openid/lib/omniauth/openid.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'omniauth/core' - -module OmniAuth - # OmniAuth::OpenID provides strategies for authenticating to providers - # using the OpenID standard. - # - # # Installation - # - # To get just OpenID functionality: - # - # gem install oa-openid - # - # For the full auth suite: - # - # gem install omniauth - # - # # Stand-Alone Example - # - # Use the strategy as a middleware in your application: - # - # require 'omniauth/openid' - # require 'openid/store/filesystem' - # - # use Rack::Session::Cookie - # use OmniAuth::Strategies::OpenID, OpenID::Store::Filesystem.new('/tmp') - # - # Then simply direct users to '/auth/open_id' to prompt them for their OpenID identifier. You may also pre-set the identifier by passing an <tt>identifier</tt> parameter to the URL (Example: <tt>/auth/open_id?openid_url=yahoo.com</tt>). - # - # A list of all OpenID stores is available at http://github.com/openid/ruby-openid/tree/master/lib/openid/store/ - # - # # OmniAuth Builder - # - # If OpenID is one of several authentication strategies, use the OmniAuth Builder: - # - # require 'omniauth/openid' - # require 'omniauth/oauth' # for Campfire - # require 'openid/store/filesystem' - # - # use OmniAuth::Builder do - # provider :open_id, OpenID::Store::Filesystem.new('/tmp') - # provider :campfire - # end - # - # # Configured Identifiers - # - # You may pre-configure an OpenID identifier. For example, to use Google's main OpenID endpoint: - # - # use OmniAuth::Builder do - # provider :open_id, nil, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id' - # end - # - # Note the use of nil, which will trigger ruby-openid's default Memory Store. - module OpenID; end - - module Strategies - autoload :OpenID, 'omniauth/strategies/open_id' - autoload :GoogleApps, 'omniauth/strategies/google_apps' - autoload :GoogleHybrid, 'omniauth/strategies/google_hybrid' - autoload :Steam, 'omniauth/strategies/steam' - end -end diff --git a/oa-openid/lib/omniauth/openid/gapps.rb b/oa-openid/lib/omniauth/openid/gapps.rb deleted file mode 100644 index f35b334..0000000 --- a/oa-openid/lib/omniauth/openid/gapps.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'openid/consumer' -require 'gapps_openid' - -module OpenID - # Because gapps_openid changes the discovery order - # (looking first for Google Apps, then anything else), - # we need to monkeypatch it to make it play nicely - # with others. - def self.discover(uri) - discovered = self.default_discover(uri) - - if discovered.last.empty? - info = discover_google_apps(uri) - return info if info - end - - return discovered - rescue OpenID::DiscoveryFailure => e - info = discover_google_apps(uri) - - if info.nil? - raise e - else - return info - end - end - - def self.discover_google_apps(uri) - discovery = GoogleDiscovery.new - discovery.perform_discovery(uri) - end -end diff --git a/oa-openid/lib/omniauth/strategies/google_apps.rb b/oa-openid/lib/omniauth/strategies/google_apps.rb deleted file mode 100644 index 233c69e..0000000 --- a/oa-openid/lib/omniauth/strategies/google_apps.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'omniauth/openid' - -module OmniAuth - module Strategies - class GoogleApps < OmniAuth::Strategies::OpenID - def initialize(app, store = nil, options = {}, &block) - options[:name] ||= 'google_apps' - super(app, store, options, &block) - end - - def get_identifier - OmniAuth::Form.build(:title => 'Google Apps Authentication') do - label_field('Google Apps Domain', 'domain') - input_field('url', 'domain') - end.to_response - end - - def identifier - options[:domain] || request['domain'] - end - end - end -end diff --git a/oa-openid/lib/omniauth/strategies/google_hybrid.rb b/oa-openid/lib/omniauth/strategies/google_hybrid.rb deleted file mode 100644 index a9aa677..0000000 --- a/oa-openid/lib/omniauth/strategies/google_hybrid.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'rack/openid' -require 'omniauth/openid' -require 'oauth' - -module OmniAuth - module Strategies - # OmniAuth strategy for connecting to Google via the OpenID+OAuth Hybrid Protocol. - # For help, check the example implementation on https://github.com/boyvanamstel/Google-Hybrid-Omniauth-implementation - class GoogleHybrid < OmniAuth::Strategies::OpenID - - protected - - def dummy_app - lambda{|env| [401, {"WWW-Authenticate" => Rack::OpenID.build_header( - :identifier => identifier, - :return_to => callback_url, - :required => @options[:required], - :optional => @options[:optional], - :"oauth[consumer]" => @options[:consumer_key], - :"oauth[scope]" => @options[:scope], - :method => 'post' - )}, []]} - end - - def auth_hash - # Based on https://gist.github.com/569650 by nov - oauth_response = ::OpenID::OAuth::Response.from_success_response(@openid_response) - - consumer = ::OAuth::Consumer.new( - @options[:consumer_key], - @options[:consumer_secret], - :site => 'https://www.google.com', - :access_token_path => '/accounts/OAuthGetAccessToken' - ) - request_token = ::OAuth::RequestToken.new( - consumer, - oauth_response.request_token, - "" # OAuth request token secret is also blank in OpenID/OAuth Hybrid - ) - @access_token = request_token.get_access_token - - OmniAuth::Utils.deep_merge(super(), { - 'uid' => @openid_response.display_identifier, - 'user_info' => user_info(@openid_response), - 'credentials' => { - 'scope' => @options[:scope], - 'token' => @access_token.token, - 'secret' => @access_token.secret - } - }) - end - end - end -end - diff --git a/oa-openid/lib/omniauth/strategies/open_id.rb b/oa-openid/lib/omniauth/strategies/open_id.rb deleted file mode 100644 index a1400f4..0000000 --- a/oa-openid/lib/omniauth/strategies/open_id.rb +++ /dev/null @@ -1,134 +0,0 @@ -require 'rack/openid' -require 'omniauth/openid/gapps' -require 'omniauth/openid' - -module OmniAuth - module Strategies - # OmniAuth strategy for connecting via OpenID. This allows for connection - # to a wide variety of sites, some of which are listed [on the OpenID website](http://openid.net/get-an-openid/). - class OpenID - include OmniAuth::Strategy - - attr_accessor :options - - IDENTIFIER_URL_PARAMETER = 'openid_url' - - AX = { - :email => 'http://axschema.org/contact/email', - :name => 'http://axschema.org/namePerson', - :nickname => 'http://axschema.org/namePerson/friendly', - :first_name => 'http://axschema.org/namePerson/first', - :last_name => 'http://axschema.org/namePerson/last', - :city => 'http://axschema.org/contact/city/home', - :state => 'http://axschema.org/contact/state/home', - :website => 'http://axschema.org/contact/web/default', - :image => 'http://axschema.org/media/image/aspect11' - } - - # Initialize the strategy as a Rack Middleware. - # - # @param app [Rack Application] Standard Rack middleware application argument. - # @param store [OpenID Store] The [OpenID Store](http://github.com/openid/ruby-openid/tree/master/lib/openid/store/) - # you wish to use. Defaults to OpenID::MemoryStore. - # @option options [Array] :required The identity fields that are required for the OpenID - # request. May be an ActiveExchange schema URL or an sreg identifier. - # @option options [Array] :optional The optional attributes for the OpenID request. May - # be ActiveExchange or sreg. - # @option options [Symbol, :open_id] :name The URL segment name for this provider. - def initialize(app, store = nil, options = {}, &block) - super(app, (options[:name] || :open_id), &block) - @options = options - @options[:required] ||= [AX[:email], AX[:name], AX[:first_name], AX[:last_name], 'email', 'fullname'] - @options[:optional] ||= [AX[:nickname], AX[:city], AX[:state], AX[:website], AX[:image], 'postcode', 'nickname'] - @store = store - end - - protected - - def dummy_app - lambda{|env| [401, {"WWW-Authenticate" => Rack::OpenID.build_header( - :identifier => identifier, - :return_to => callback_url, - :required => @options[:required], - :optional => @options[:optional], - :method => 'post' - )}, []]} - end - - def identifier - i = options[:identifier] || request[IDENTIFIER_URL_PARAMETER] - i = nil if i == '' - i - end - - def request_phase - identifier ? start : get_identifier - end - - def start - openid = Rack::OpenID.new(dummy_app, @store) - response = openid.call(env) - case env['rack.openid.response'] - when Rack::OpenID::MissingResponse, Rack::OpenID::TimeoutResponse - fail!(:connection_failed) - else - response - end - end - - def get_identifier - OmniAuth::Form.build(:title => 'OpenID Authentication') do - label_field('OpenID Identifier', IDENTIFIER_URL_PARAMETER) - input_field('url', IDENTIFIER_URL_PARAMETER) - end.to_response - end - - def callback_phase - openid = Rack::OpenID.new(lambda{|env| [200,{},[]]}, @store) - openid.call(env) - @openid_response = env.delete('rack.openid.response') - if @openid_response && @openid_response.status == :success - super - else - fail!(:invalid_credentials) - end - end - - def auth_hash - OmniAuth::Utils.deep_merge(super(), { - 'uid' => @openid_response.display_identifier, - 'user_info' => user_info(@openid_response) - }) - end - - def user_info(response) - sreg_user_info(response).merge(ax_user_info(response)) - end - - def sreg_user_info(response) - sreg = ::OpenID::SReg::Response.from_success_response(response) - return {} unless sreg - { - 'email' => sreg['email'], - 'name' => sreg['fullname'], - 'location' => sreg['postcode'], - 'nickname' => sreg['nickname'] - }.reject{|k,v| v.nil? || v == ''} - end - - def ax_user_info(response) - ax = ::OpenID::AX::FetchResponse.from_success_response(response) - return {} unless ax - { - 'email' => ax.get_single(AX[:email]), - 'first_name' => ax.get_single(AX[:first_name]), - 'last_name' => ax.get_single(AX[:last_name]), - 'name' => (ax.get_single(AX[:name]) || [ax.get_single(AX[:first_name]), ax.get_single(AX[:last_name])].join(' ')).strip, - 'location' => ("#{ax.get_single(AX[:city])}, #{ax.get_single(AX[:state])}" if Array(ax.get_single(AX[:city])).any? && Array(ax.get_single(AX[:state])).any?), - 'nickname' => ax.get_single(AX[:nickname]), - 'urls' => ({'Website' => Array(ax.get_single(AX[:website])).first} if Array(ax.get_single(AX[:website])).any?) - }.inject({}){|h,(k,v)| h[k] = Array(v).first; h}.reject{|k,v| v.nil? || v == ''} - end - end - end -end diff --git a/oa-openid/lib/omniauth/strategies/steam.rb b/oa-openid/lib/omniauth/strategies/steam.rb deleted file mode 100644 index 18f87ec..0000000 --- a/oa-openid/lib/omniauth/strategies/steam.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'omniauth/openid' -module OmniAuth - module Strategies - class Steam < OmniAuth::Strategies::OpenID - def initialize(app, store = nil, api_key = nil, options = {}, &block) - options[:identifier] ||= "http://steamcommunity.com/openid" - options[:name] ||= 'steam' - @api_key = api_key - super(app, store, options, &block) - end - - def user_info(response=nil) - player = user_hash['response']['players']['player'].first - nickname = player["personaname"] - name = player["realname"] - url = player["profileurl"] - country = player["loccountrycode"] - state = player["locstatecode"] - city = player["loccityid"] - - { - 'nickname' => nickname, - 'name' => name, - 'url' => url, - 'location' => "#{city}, #{state}, #{country}" - } - end - - def user_hash - # Steam provides no information back on a openid response other than a 64bit user id - # Need to use this information and make a API call to get user information from steam. - if @api_key - unless @user_hash - uri = URI.parse("http://api.steampowered.com/") - req = Net::HTTP::Get.new("#{uri.path}ISteamUser/GetPlayerSummaries/v0001/?key=#{@api_key}&steamids=#{@openid_response.display_identifier.split("/").last}") - res = Net::HTTP.start(uri.host, uri.port) {|http| - http.request(req) - } - end - @user_hash ||= MultiJson.decode(res.body) - else - {} - end - end - - def auth_hash - OmniAuth::Utils.deep_merge(super, { - 'uid' => @openid_response.display_identifier.split("/").last, - 'user_info' => user_info, - 'extra' => {'user_hash' => user_hash} - }) - end - end - end -end diff --git a/oa-openid/lib/omniauth/version.rb b/oa-openid/lib/omniauth/version.rb deleted file mode 100644 index 9f980b0..0000000 --- a/oa-openid/lib/omniauth/version.rb +++ /dev/null @@ -1,19 +0,0 @@ -module OmniAuth - module Version - unless defined?(::OmniAuth::Version::MAJOR) - MAJOR = 0 - end - unless defined?(::OmniAuth::Version::MINOR) - MINOR = 3 - end - unless defined?(::OmniAuth::Version::PATCH) - PATCH = 0 - end - unless defined?(::OmniAuth::Version::PRE) - PRE = "rc3" - end - unless defined?(::OmniAuth::Version::STRING) - STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.') - end - end -end diff --git a/oa-openid/oa-openid.gemspec b/oa-openid/oa-openid.gemspec deleted file mode 100644 index ff87433..0000000 --- a/oa-openid/oa-openid.gemspec +++ /dev/null @@ -1,26 +0,0 @@ -# encoding: utf-8 -require File.expand_path('../lib/omniauth/version', __FILE__) - -Gem::Specification.new do |gem| - gem.add_dependency 'oa-core', OmniAuth::Version::STRING - gem.add_dependency 'rack-openid', '~> 1.3.1' - gem.add_dependency 'ruby-openid-apps-discovery', '~> 1.2.0' - gem.add_development_dependency 'rack-test', '~> 0.5' - gem.add_development_dependency 'rake', '~> 0.8' - gem.add_development_dependency 'rdiscount', '~> 1.6' - gem.add_development_dependency 'rspec', '~> 2.5' - gem.add_development_dependency 'simplecov', '~> 0.4' - gem.add_development_dependency 'webmock', '~> 1.7' - gem.add_development_dependency 'yard', '~> 0.7' - gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober'] - gem.description = %q{OpenID strategies for OmniAuth.} - gem.email = ['michael@intridea.com', 'sferik@gmail.com'] - gem.files = `git ls-files`.split("\n") - gem.homepage = 'http://github.com/intridea/omniauth' - gem.name = 'oa-openid' - gem.require_paths = ['lib'] - gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version= - gem.summary = gem.description - gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - gem.version = OmniAuth::Version::STRING -end diff --git a/oa-openid/spec/omniauth/strategies/google_hybrid_spec.rb b/oa-openid/spec/omniauth/strategies/google_hybrid_spec.rb deleted file mode 100644 index 4c45e1d..0000000 --- a/oa-openid/spec/omniauth/strategies/google_hybrid_spec.rb +++ /dev/null @@ -1,63 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'rack/openid' -require 'omniauth/openid' -require 'oauth' - -describe "OmniAuth::Strategies::GoogleHybrid" do - - def app - Rack::Builder.new { - use OmniAuth::Test::PhonySession - use OmniAuth::Builder do - provider :google_hybrid, nil, - :name => 'google_hybrid', - :identifier => 'https://www.google.com/accounts/o8/id', - :scope => ["https://www.google.com/m8/feeds/", "https://mail.google.com/mail/feed/atom/"], - :consumer_key => '[your key here]', - :consumer_secret => '[your secret here]' - end - run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] } - }.to_app - end - - def session - last_request.env['rack.session'] - end - - def expired_query_string - 'openid=consumer&janrain_nonce=2011-07-21T20%3A14%3A56ZJ8LP3T&openid.assoc_handle=%7BHMAC-SHA1%7D%7B4e284c39%7D%7B9nvQeg%3D%3D%7D&openid.claimed_id=http%3A%2F%2Flocalhost%3A1123%2Fjohn.doe%3Fopenid.success%3Dtrue&openid.identity=http%3A%2F%2Flocalhost%3A1123%2Fjohn.doe%3Fopenid.success%3Dtrue&openid.mode=id_res&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.op_endpoint=http%3A%2F%2Flocalhost%3A1123%2Fserver%2F%3Fopenid.success%3Dtrue&openid.response_nonce=2011-07-21T20%3A14%3A56Zf9gC8S&openid.return_to=http%3A%2F%2Flocalhost%3A8888%2FDevelopment%2FWordpress%2Fwp_openid%2F%3Fopenid%3Dconsumer%26janrain_nonce%3D2011-07-21T20%253A14%253A56ZJ8LP3T&openid.sig=GufV13SUJt8VgmSZ92jGZCFBEvQ%3D&openid.signed=assoc_handle%2Cclaimed_id%2Cidentity%2Cmode%2Cns%2Cop_endpoint%2Cresponse_nonce%2Creturn_to%2Csigned' - end - - describe 'followed by /auth/google_hybrid/callback' do - context 'successful' do - #before do - # @identifier_url = 'https://www.google.com/accounts/o8/id' - # # TODO: change this mock to actually return some sort of OpenID response - # stub_request(:get, @identifier_url) - # get '/auth/google_hybrid/callback' - #end - - it "should set provider to google_hybrid" - it "should create auth_hash based on sreg" - it "should create auth_hash based on ax" - - it "should exchange OAuth request token for access token" - - #it 'should call through to the master app' do - # last_response.body.should == 'true' - #end - end - - context 'unsuccessful' do - describe 'returning with expired credentials' do - before do - get '/auth/google_hybrid/callback?' + expired_query_string - end - it 'it should redirect to invalid credentials' do - last_response.should be_redirect - last_response.headers['Location'].should =~ %r{invalid_credentials} - end - end - end - end -end diff --git a/oa-openid/spec/omniauth/strategies/open_id_spec.rb b/oa-openid/spec/omniauth/strategies/open_id_spec.rb deleted file mode 100644 index 363328a..0000000 --- a/oa-openid/spec/omniauth/strategies/open_id_spec.rb +++ /dev/null @@ -1,87 +0,0 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require 'rack/openid' -require 'omniauth/openid' - -describe OmniAuth::Strategies::OpenID, :type => :strategy do - - include OmniAuth::Test::StrategyTestCase - - def strategy - [OmniAuth::Strategies::OpenID] - end - - def expired_query_string - 'openid=consumer&janrain_nonce=2011-07-21T20%3A14%3A56ZJ8LP3T&openid.assoc_handle=%7BHMAC-SHA1%7D%7B4e284c39%7D%7B9nvQeg%3D%3D%7D&openid.claimed_id=http%3A%2F%2Flocalhost%3A1123%2Fjohn.doe%3Fopenid.success%3Dtrue&openid.identity=http%3A%2F%2Flocalhost%3A1123%2Fjohn.doe%3Fopenid.success%3Dtrue&openid.mode=id_res&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.op_endpoint=http%3A%2F%2Flocalhost%3A1123%2Fserver%2F%3Fopenid.success%3Dtrue&openid.response_nonce=2011-07-21T20%3A14%3A56Zf9gC8S&openid.return_to=http%3A%2F%2Flocalhost%3A8888%2FDevelopment%2FWordpress%2Fwp_openid%2F%3Fopenid%3Dconsumer%26janrain_nonce%3D2011-07-21T20%253A14%253A56ZJ8LP3T&openid.sig=GufV13SUJt8VgmSZ92jGZCFBEvQ%3D&openid.signed=assoc_handle%2Cclaimed_id%2Cidentity%2Cmode%2Cns%2Cop_endpoint%2Cresponse_nonce%2Creturn_to%2Csigned' - end - - describe '/auth/open_id without an identifier URL' do - before do - get '/auth/open_id' - end - - it 'should respond with OK' do - last_response.should be_ok - end - - it 'should respond with HTML' do - last_response.content_type.should == 'text/html' - end - - it 'should render an identifier URL input' do - last_response.body.should =~ %r{<input[^>]*#{OmniAuth::Strategies::OpenID::IDENTIFIER_URL_PARAMETER}} - end - end - - #describe '/auth/open_id with an identifier URL' do - # context 'successful' do - # before do - # @identifier_url = 'http://me.example.org' - # # TODO: change this mock to actually return some sort of OpenID response - # stub_request(:get, @identifier_url) - # get '/auth/open_id?openid_url=' + @identifier_url - # end - # - # it 'should redirect to the OpenID identity URL' do - # last_response.should be_redirect - # last_response.headers['Location'].should =~ %r{^#{@identifier_url}.*} - # end - # - # it 'should tell the OpenID server to return to the callback URL' do - # return_to = CGI.escape(last_request.url + '/callback') - # last_response.headers['Location'].should =~ %r{[\?&]openid.return_to=#{return_to}} - # end - # end - #end - - describe 'followed by /auth/open_id/callback' do - context 'successful' do - #before do - # @identifier_url = 'http://me.example.org' - # # TODO: change this mock to actually return some sort of OpenID response - # stub_request(:get, @identifier_url) - # get '/auth/open_id/callback' - #end - - it "should set provider to open_id" - it "should create auth_hash based on sreg" - it "should create auth_hash based on ax" - - #it 'should call through to the master app' do - # last_response.body.should == 'true' - #end - end - - context 'unsuccessful' do - describe 'returning with expired credentials' do - before do - get '/auth/open_id/callback?' + expired_query_string - end - it 'it should redirect to invalid credentials' do - last_response.should be_redirect - last_response.headers['Location'].should =~ %r{invalid_credentials} - end - end - end - end - -end diff --git a/oa-openid/spec/spec_helper.rb b/oa-openid/spec/spec_helper.rb deleted file mode 100644 index 9b95fdf..0000000 --- a/oa-openid/spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'simplecov' -SimpleCov.start -require 'rspec' -require 'rack/test' -require 'webmock/rspec' -require 'omniauth/core' -require 'omniauth/test' -require 'omniauth/openid' - -RSpec.configure do |config| - config.include WebMock::API - config.include Rack::Test::Methods - config.extend OmniAuth::Test::StrategyMacros, :type => :strategy -end diff --git a/omniauth.gemspec b/omniauth.gemspec deleted file mode 100644 index e3e7bc4..0000000 --- a/omniauth.gemspec +++ /dev/null @@ -1,18 +0,0 @@ -# encoding: utf-8 -require File.expand_path('../lib/omniauth/version', __FILE__) - -Gem::Specification.new do |gem| - %w(oa-core oa-oauth oa-identity oa-openid oa-enterprise oa-more).each do |subgem| - gem.add_runtime_dependency subgem, OmniAuth::Version::STRING - end - gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober'] - gem.description = %q{OmniAuth is an authentication framework that separates the concept of authentiation from the concept of identity, providing simple hooks for any application to have one or multiple authentication providers for a user.} - gem.email = ['michael@intridea.com', 'sferik@gmail.com'] - gem.files = Dir.glob("lib/**/*") + %w(README.md LICENSE.md) - gem.homepage = 'http://github.com/intridea/omniauth' - gem.name = 'omniauth' - gem.require_paths = ['lib'] - gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') - gem.summary = %q{Rack middleware for standardized multi-provider authentication} - gem.version = OmniAuth::Version::STRING -end diff --git a/oa-core/spec/omniauth/auth_hash_spec.rb b/spec/omniauth/auth_hash_spec.rb similarity index 100% rename from oa-core/spec/omniauth/auth_hash_spec.rb rename to spec/omniauth/auth_hash_spec.rb diff --git a/spec/omniauth/strategy_spec.rb b/spec/omniauth/strategy_spec.rb index 3b0a19c..7137f6b 100644 --- a/spec/omniauth/strategy_spec.rb +++ b/spec/omniauth/strategy_spec.rb @@ -243,6 +243,35 @@ describe OmniAuth::Strategy do end end + context 'receiving an OPTIONS request' do + shared_examples_for "an OPTIONS request" do + it 'should respond with 200' do + response[0].should == 200 + end + + it 'should set the Allow header properly' do + response[1]['Allow'].should == "GET, POST" + end + end + + context 'to the request path' do + let(:response) { strategy.call(make_env('/auth/test', 'REQUEST_METHOD' => 'OPTIONS')) } + it_should_behave_like 'an OPTIONS request' + end + + context 'to the request path' do + let(:response) { strategy.call(make_env('/auth/test/callback', 'REQUEST_METHOD' => 'OPTIONS')) } + it_should_behave_like 'an OPTIONS request' + end + + context 'to some other path' do + it 'should not short-circuit the request' do + env = make_env('/other', 'REQUEST_METHOD' => 'OPTIONS') + strategy.call(env).should == app.call(env) + end + end + end + context 'test mode' do before do OmniAuth.config.test_mode = true diff --git a/tasks/all.rb b/tasks/all.rb deleted file mode 100644 index e69f2c8..0000000 --- a/tasks/all.rb +++ /dev/null @@ -1,134 +0,0 @@ -require 'fileutils' - -PROJECTS = %w(oa-core oa-enterprise oa-identity oa-more oa-oauth oa-openid omniauth) - -def root - File.expand_path('../../', __FILE__) -end - -require root + '/lib/omniauth/version' - -def version - ::OmniAuth::Version.constants.each do |const| - ::OmniAuth::Version.send(:remove_const, const) - end - load root + '/lib/omniauth/version.rb' - OmniAuth::Version::STRING -end - -PROJECTS.each do |project| - namespace project.to_sym do - dir = root + (project == 'omniauth' ? '' : "/#{project}") - package_dir = "#{dir}/pkg" - coverage_dir = "#{dir}/coverage" - temp_dir = "#{dir}/tmp" - gem = "#{project}-#{version}.gem" - gemspec = "#{project}.gemspec" - - task :clean do - rm_rf package_dir - rm_rf coverage_dir - rm_rf temp_dir - end - - task :build => :clean do - cd dir - sh "gem build #{gemspec}" - mkdir_p package_dir unless File.directory?(package_dir) - mv gem, "#{package_dir}/#{gem}" - end - - task :install => :build do - sh "gem install #{package_dir}/#{gem}" - end - - task :push => :build do - sh "gem push #{package_dir}/#{gem}" - end - - task :version do - puts "#{project}: #{version}" - end - - namespace :version do - - destination = "#{dir}/lib/omniauth/version.rb" - - task :write do - write_version(destination, ENV['MAJOR'], ENV['MINOR'], ENV['PATCH'], ENV['PRE']) - end - - namespace :bump do - - task :major do - bump_version(destination, 0) - end - - task :minor do - bump_version(destination, 1) - end - - task :patch do - bump_version(destination, 2) - end - - end - - end - - task :spec do - cd dir - sh "#{$0} spec" - end - - end -end - -namespace :all do - task :clean => PROJECTS.map{|project| "#{project}:clean"} - task :build => PROJECTS.map{|project| "#{project}:build"} - task :install => PROJECTS.map{|project| "#{project}:install"} - task :push => PROJECTS.map{|project| "#{project}:push"} - task "version" => PROJECTS.map{|project| "#{project}:version"} - task "version:write" => PROJECTS.map{|project| "#{project}:version:write"} + [:version] - task "version:bump:major" => PROJECTS.map{|project| "#{project}:version:bump:major"} + [:version] - task "version:bump:minor" => PROJECTS.map{|project| "#{project}:version:bump:minor"} + [:version] - task "version:bump:patch" => PROJECTS.map{|project| "#{project}:version:bump:patch"} + [:version] - task :spec do - errors = [] - PROJECTS.map do |project| - next if project == "omniauth" - Rake::Task["#{project}:spec"].invoke || errors << project - end - fail("Errors in #{errors.join(', ')}") unless errors.empty? - end -end - -def write_version(destination, major=nil, minor=nil, patch=nil, pre=nil) - source = "#{root}/lib/omniauth/version.rb" - v = version.split('.') - major ||= v[0] - minor ||= v[1] - patch ||= v[2] - pre ||= v[3] - pre = pre ? pre.inspect : "nil" - - ruby = File.read(source) - ruby.gsub! /^(\s*)MAJOR = .*?$/, "\\1MAJOR = #{major}" - fail "Could not insert MAJOR in #{source}" unless $1 - ruby.gsub! /^(\s*)MINOR = .*?$/, "\\1MINOR = #{minor}" - fail "Could not insert MINOR in #{source}" unless $1 - ruby.gsub! /^(\s*)PATCH = .*?$/, "\\1PATCH = #{patch}" - fail "Could not insert PATCH in #{source}" unless $1 - ruby.gsub! /^(\s*)PRE = .*?$/, "\\1PRE = #{pre}" - fail "Could not insert PRE in #{source}" unless $1 - File.open(destination, 'w') do |file| - file.write ruby - end -end - -def bump_version(destination, position) - v = version.split('.').map{|s| s.to_i} - v[position] += 1 - write_version(destination, *v) -end