diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 9b65b77..74337c0 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -7,7 +7,7 @@ handle_omniauth(scheme) end end - + ## # Processes callbacks from an omniauth provider and directs the user to # the appropriate page: @@ -19,6 +19,9 @@ # @scheme [IdentifierScheme] The IdentifierScheme for the provider # ------------------------------------------------------------- def handle_omniauth(scheme) + +puts "now weez handlin it #{scheme}" + user = User.from_omniauth(request.env["omniauth.auth"].nil? ? request.env : request.env["omniauth.auth"]) # If the user isn't logged in diff --git a/app/models/user.rb b/app/models/user.rb index 52672c4..6ad36e1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,8 +6,9 @@ # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable - devise :invitable, :database_authenticatable, :registerable, :recoverable, :rememberable, - :trackable, :validatable, :confirmable, :omniauthable, :omniauth_providers => [:shibboleth] + devise :invitable, :database_authenticatable, :registerable, :recoverable, + :rememberable, :trackable, :validatable, :confirmable, :omniauthable, + :omniauth_providers => [:shibboleth, :orcid] ## # Associations diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 0f64f83..4dc0f0c 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -265,6 +265,16 @@ # so you need to do it manually. For the users scope, it would be: # config.omniauth_path_prefix = '/my_engine/users/auth' + config.omniauth :orcid, 'APP-T96TCS5F64T5EB2O', + '8def5f5c-25f3-4faf-9bb9-0740cde89daa', {"scope": "/authenticate"} + # config.omniauth :orcid, 'APP-Z80XR6IBPK2D4DWN', '92e159d6-5947-4c1a-9b9e-44560ba9370b', {"scope": "/authenticate"} #{"scope": "/orcid-profile/read-limited"} + + # config.omniauth :shibboleth, {uid_field: 'eppn', + # info_fields: {email: 'mail', name: 'cn', last_name: 'sn'}, + # extra_fields: [:schacHomeOrganization]} #, debug: true} + + config.omniauth_path_prefix = "/users/auth" + # Configure the system to redirect to the home page after a session timeout config.warden do |manager| manager.failure_app = CustomFailure diff --git a/test/routing_test.rb b/test/routing_test.rb index c46f42d..b23a0a5 100644 --- a/test/routing_test.rb +++ b/test/routing_test.rb @@ -1,7 +1,9 @@ require 'test_helper' class RoutingTest < ActionDispatch::IntegrationTest - + + include Devise::Test::IntegrationHelpers + setup do scaffold_plan end @@ -46,16 +48,8 @@ # OAuth - Based on providers identified in the en-UK locale file # ------------------------------------------------------------------- - test "GET /users/auth/[:provider] should resolve to OmniauthCallbackController#passthru" do - target = {controller: "users/omniauth_callbacks", action: "passthru"} - - IdentifierScheme.all.each do |scheme| - assert_routing "/users/auth/#{scheme.name.downcase}", target - end - end - test "POST /auth/[:provider]/callback should resolve to OmniauthCallbackController#[:provider]" do - IdentifierScheme.all.each do |scheme| + IdentifierScheme.where(active: true).all.each do |scheme| target = {controller: "users/omniauth_callbacks", action: "#{scheme.name.downcase}"} assert_routing "/users/auth/#{scheme.name.downcase}/callback", target end