From 4f3969e5fbf4b59f8f20ef464c26f9ff0eeed9dc Mon Sep 17 00:00:00 2001 From: Daniel Pierce Date: Mon, 29 Apr 2024 15:02:47 -0400 Subject: [PATCH] Revert "Use db auth for now" This reverts commit ea0059b177d9d7f1d9de4a7aa68a97d966a8dd4f. --- .docker.env | 10 +++++----- .env | 10 +++++----- app/helpers/application_helper.rb | 6 +++--- app/models/user.rb | 3 +-- app/views/_user_util_links.html.erb | 27 +++++++++++++++++++++++++++ config/initializers/devise.rb | 18 +++++++++--------- config/routes.rb | 10 +++++----- 7 files changed, 55 insertions(+), 29 deletions(-) create mode 100644 app/views/_user_util_links.html.erb diff --git a/.docker.env b/.docker.env index beb5e5b..3020d9b 100644 --- a/.docker.env +++ b/.docker.env @@ -1,9 +1,9 @@ # Hyrax -#CAS_HOST=idp-stg.login.iu.edu -#CAS_LOGIN_URL=/idp/profile/cas/login -#CAS_VALIDATE_URL=/idp/profile/cas/serviceValidate -#CAS_LOGOUT_URL=/idp/profile/cas/logout -#CAS_CALLBACK_URL=/users/auth/cas/callback +CAS_HOST=idp-stg.login.iu.edu +CAS_LOGIN_URL=/idp/profile/cas/login +CAS_VALIDATE_URL=/idp/profile/cas/serviceValidate +CAS_LOGOUT_URL=/idp/profile/cas/logout +CAS_CALLBACK_URL=/users/auth/cas/callback DATABASE_URL=postgresql://rdc_user:rdc_pass@postgres:5432/rdc?pool=5 HYRAX_ACTIVE_JOB_QUEUE=async REDIS_URL=redis://:rdc_redis@redis:6379 diff --git a/.env b/.env index 19d1b74..75d59a0 100644 --- a/.env +++ b/.env @@ -1,8 +1,8 @@ -#CAS_HOST=idp-stg.login.iu.edu -#CAS_LOGIN_URL=/idp/profile/cas/login -#CAS_VALIDATE_URL=/idp/profile/cas/serviceValidate -#CAS_LOGOUT_URL=/idp/profile/cas/logout -#CAS_CALLBACK_URL=/users/auth/cas/callback +CAS_HOST=idp-stg.login.iu.edu +CAS_LOGIN_URL=/idp/profile/cas/login +CAS_VALIDATE_URL=/idp/profile/cas/serviceValidate +CAS_LOGOUT_URL=/idp/profile/cas/logout +CAS_CALLBACK_URL=/users/auth/cas/callback CH12N_TOOL=fits_servlet DATABASE_URL=postgresql://postgres@localhost:5437/hyrax-dev?pool=5 FCREPO_URL=http://fedoraAdmin:fedoraAdmin@fcrepo:8989/fcrepo/rest diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2379f67..de06f7a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,6 +1,6 @@ module ApplicationHelper # Needed for devise omniauth without :database_authenticatable - # def new_session_path(scope) - # new_user_session_path - # end + def new_session_path(scope) + new_user_session_path + end end diff --git a/app/models/user.rb b/app/models/user.rb index 194e240..6ad1de1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -13,8 +13,7 @@ class User < ApplicationRecord # Connects this user object to Blacklights Bookmarks. include Blacklight::User - # devise :omniauthable, :omniauth_providers => [:cas] - devise :database_authenticatable, :registerable, :rememberable, :validatable + devise :omniauthable, :omniauth_providers => [:cas] # Method added by Blacklight; Blacklight uses #to_s on your # user class to get a user-displayable login/identifier for diff --git a/app/views/_user_util_links.html.erb b/app/views/_user_util_links.html.erb new file mode 100644 index 0000000..ffc8ebb --- /dev/null +++ b/app/views/_user_util_links.html.erb @@ -0,0 +1,27 @@ + diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 8e52fad..20a42c9 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -272,15 +272,15 @@ # Add a new OmniAuth provider. Check the wiki for more information on setting # up on your models and hooks. # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' - # if ENV.fetch('CAS_HOST', nil).present? # Not set during image build - # config.omniauth :cas, - # :host => ENV.fetch('CAS_HOST'), - # :login_url => ENV.fetch('CAS_LOGIN_URL'), - # :service_validate_url => ENV.fetch('CAS_VALIDATE_URL'), - # :logout_url => ENV.fetch('CAS_LOGOUT_URL'), - # :callback_url => ENV.fetch('CAS_CALLBACK_URL'), - # :ssl => true - # end + if ENV.fetch('CAS_HOST', nil).present? # Not set during image build + config.omniauth :cas, + :host => ENV.fetch('CAS_HOST'), + :login_url => ENV.fetch('CAS_LOGIN_URL'), + :service_validate_url => ENV.fetch('CAS_VALIDATE_URL'), + :logout_url => ENV.fetch('CAS_LOGOUT_URL'), + :callback_url => ENV.fetch('CAS_CALLBACK_URL'), + :ssl => true + end # ==> Warden configuration # If you want to use other strategies, that are not supported by Devise, or diff --git a/config/routes.rb b/config/routes.rb index aaf8bc1..e461901 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,11 +9,11 @@ resource :catalog, only: [:index], as: 'catalog', path: '/catalog', controller: 'catalog' do concerns :searchable end - devise_for :users #, controllers: { omniauth_callbacks: "users/omniauth_callbacks" } - # devise_scope :user do - # get 'sign_in', to: 'devise/sessions#new', as: :new_user_session - # get 'sign_out', to: 'devise/sessions#destroy', as: :destroy_user_session - # end + devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" } + devise_scope :user do + get 'sign_in', to: 'devise/sessions#new', as: :new_user_session + get 'sign_out', to: 'devise/sessions#destroy', as: :destroy_user_session + end mount Hydra::RoleManagement::Engine => '/' mount Qa::Engine => '/authorities'