From da6fd5b8001f70b64af9d5c3edbdab134a5ff34d Mon Sep 17 00:00:00 2001 From: Dan Milne Date: Mon, 27 Oct 2025 23:54:34 +1100 Subject: [PATCH] More logs --- app/controllers/api/forward_auth_controller.rb | 5 ++++- app/controllers/concerns/authentication.rb | 8 +++++++- config/puma.rb | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/forward_auth_controller.rb b/app/controllers/api/forward_auth_controller.rb index 51603bd..a163ae8 100644 --- a/app/controllers/api/forward_auth_controller.rb +++ b/app/controllers/api/forward_auth_controller.rb @@ -94,7 +94,10 @@ module Api def extract_session_id # Extract session ID from cookie # Rails uses signed cookies by default - cookies.signed[:session_id] + session_id = cookies.signed[:session_id] + Rails.logger.info "ForwardAuth: Session cookie present: #{session_id.present?}, value: #{session_id&.to_s&.first(10)}..." + Rails.logger.info "ForwardAuth: All cookies: #{cookies.to_h.keys.join(', ')}" + session_id end def extract_app_from_headers diff --git a/app/controllers/concerns/authentication.rb b/app/controllers/concerns/authentication.rb index 30acf9f..4f53bef 100644 --- a/app/controllers/concerns/authentication.rb +++ b/app/controllers/concerns/authentication.rb @@ -35,7 +35,11 @@ module Authentication end def after_authentication_url - session.delete(:return_to_after_authenticating) || root_url + return_url = session[:return_to_after_authenticating] + Rails.logger.info "Authentication: after_authentication_url - session[:return_to_after_authenticating] = #{return_url.inspect}" + final_url = session.delete(:return_to_after_authenticating) || root_url + Rails.logger.info "Authentication: Final redirect URL: #{final_url}" + final_url end def start_new_session_for(user) @@ -56,6 +60,8 @@ module Authentication # Set domain for cross-subdomain authentication if we can extract it cookie_options[:domain] = domain if domain.present? + Rails.logger.info "Authentication: Setting session cookie with options: #{cookie_options.except(:value).merge(value: cookie_options[:value]&.to_s&.first(10) + '...')}" + Rails.logger.info "Authentication: Extracted domain from #{request.host}: #{domain.inspect}" cookies.signed.permanent[:session_id] = cookie_options end end diff --git a/config/puma.rb b/config/puma.rb index 5771f2b..d7257cc 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -31,6 +31,7 @@ threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. port ENV.fetch("PORT", 3000) + # Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart