Skip to content

Commit

Permalink
Revert "Use db auth for now"
Browse files Browse the repository at this point in the history
This reverts commit ea0059b.
  • Loading branch information
dlpierce committed Apr 29, 2024
1 parent 45dd7f2 commit 4f3969e
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 29 deletions.
10 changes: 5 additions & 5 deletions .docker.env
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions .env
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions app/views/_user_util_links.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<ul id="user_utility_links" class="navbar-nav navbar-dark">
<%= render 'shared/locale_picker' if available_translations.size > 1 %>
<% if user_signed_in? %>
<li class="nav-item">
<%= render_notifications(user: current_user) %>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only"><%= t("hyrax.toolbar.profile.sr_action") %></span>
<span><%= current_user.name %></span>
<span class="sr-only"> <%= t("hyrax.toolbar.profile.sr_target") %></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<%= link_to "My Profile", hyrax.dashboard_profile_path(current_user), class: 'dropdown-item' %>
<%= link_to t("hyrax.toolbar.dashboard.menu"), hyrax.dashboard_path, class: "dropdown-item" %>
<div class="dropdown-divider"></div>
<%= link_to t("hyrax.toolbar.profile.logout"), main_app.destroy_user_session_path, class: "dropdown-item" %>
</div>
</li>
<% else %>
<li class="nav-item">
<%= link_to main_app.user_cas_omniauth_authorize_path, method: :post, class: 'nav-link' do %>
<span class="fa fa-sign-in" aria-hidden="true"></span> <%= t("hyrax.toolbar.profile.login") %>
<% end %>
</li>
<% end %>
</ul>
18 changes: 9 additions & 9 deletions config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 4f3969e

Please sign in to comment.