Skip to content

Commit

Permalink
[wip] Troubleshooting and diagnosis errors encountered when integrating
Browse files Browse the repository at this point in the history
Devise and OmniAuth routes for `session_path` and CAS authentication.

Co-authored-by: Robert-Anthony Lee-Faison <leefaisonr@users.noreply.github.com>
  • Loading branch information
jrgriffiniii and leefaisonr committed May 31, 2024
1 parent 02c5cd6 commit 9713b38
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ group :test do
gem "database_cleaner-active_record"
gem "selenium-webdriver"
end

gem "pry-byebug"
11 changes: 10 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ GEM
super_diff
thor
zeitwerk (~> 2.1)
coderay (1.1.3)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
commonmarker (0.23.10)
Expand All @@ -167,7 +168,7 @@ GEM
activesupport
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
devise (4.9.4)
devise (4.8.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
Expand Down Expand Up @@ -247,6 +248,7 @@ GEM
net-smtp
marcel (1.0.4)
matrix (0.4.2)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (5.23.1)
msgpack (1.7.2)
Expand Down Expand Up @@ -315,6 +317,12 @@ GEM
patience_diff (1.2.0)
optimist (~> 3.0)
pg (1.5.6)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
psych (5.1.2)
stringio
public_suffix (5.0.5)
Expand Down Expand Up @@ -524,6 +532,7 @@ DEPENDENCIES
omniauth-cas (~> 3.0)
omniauth-orcid
pg
pry-byebug
puma (= 5.6.8)
rack (= 2.2.8.1)
rails (~> 7.1.0)
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :authenticate_user!
# include Devise::Controllers::UrlHelpers
# include Rails.application.routes.url_helpers
# include Rails.application.routes.mounted_helpers

def new_session_path(_scope)
new_user_session_path
end

def session_path(_scope)
new_user_session_path
end

def after_sign_in_path_for(_resource)
"/users/#{@user.id}"
end
Expand Down
3 changes: 2 additions & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,11 @@

## For CAS
config.omniauth :cas, host: "fed.princeton.edu", url: "https://fed.princeton.edu/cas"
OmniAuth.config.allowed_request_methods = [:get, :post]

## For OCID Failure
config.omniauth :orcid, callback: "/auth/orcid/callback"
OmniAuth.config.allowed_request_methods = [:get, :post]
OmniAuth.config.request_validation_phase = OmniAuth::AuthenticityTokenProtection.new(allow_if: ->(_env) { true })

# ==> Mountable engine configurations
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

devise_scope :user do
get "sign_in", to: "devise/sessions#new", as: :new_user_session
# get "sign_in", to: "users/omniauth_callbacks#passthru", as: :new_user_session
get "sign_in", to: "users/omniauth_callbacks#passthru", as: :session
get "sign_out", to: "devise/sessions#destroy", as: :destroy_user_session
end
end

0 comments on commit 9713b38

Please sign in to comment.