-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mobile: Relocate logging of sso information to controller concern (#1…
…2486) * Add logging for contact information updates * Add more logging locations and start tweaking tests * Add expiration to test * Move logging and tests to profile base controller * Please rubocop * Remove duplicate logging * Remove duplicate logging * Move files back * Remove unnecessary file * Make rubocop happy * Relocate sso logging logic to a controller concern and include that in payment information * Zeitwerk fix
- Loading branch information
1 parent
ecdd161
commit 45d5818
Showing
3 changed files
with
61 additions
and
49 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
modules/mobile/app/controllers/mobile/concerns/sso_logging.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mobile::Concerns::SSOLogging | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
after_action :log_sso_info, only: %i[create update destroy] | ||
|
||
def log_sso_info | ||
action = request.controller_instance.controller_path.classify.to_s | ||
action += 'Controller#' | ||
action += request.parameters['action'].to_s | ||
|
||
Rails.logger.warn( | ||
"#{action} request completed", sso_logging_info | ||
) | ||
end | ||
|
||
def sso_logging_info | ||
{ user_uuid: @current_user&.uuid, | ||
sso_cookie_contents: sso_cookie_content, | ||
request_host: request.host } | ||
end | ||
|
||
def sso_cookie_content | ||
return nil if @current_user.blank? | ||
|
||
{ 'patientIcn' => @current_user.icn, | ||
'signIn' => @current_user.identity.sign_in.deep_transform_keys { |key| key.to_s.camelize(:lower) }, | ||
'credential_used' => @current_user.identity.sign_in[:service_name], | ||
'expirationTime' => if sis_authentication? | ||
sign_in_expiration_time | ||
else | ||
@current_user.identity.expiration_timestamp | ||
end } | ||
end | ||
|
||
def sign_in_expiration_time | ||
if sis_authentication? | ||
if sign_in_service_session | ||
sign_in_service_session.refresh_expiration.iso8601(0) | ||
else | ||
@session_object.ttl_in_time.iso8601(0) | ||
end | ||
else | ||
@current_user.identity.expiration_timestamp | ||
end | ||
end | ||
|
||
def sign_in_service_session | ||
return unless @access_token | ||
|
||
@sign_in_service_session ||= SignIn::OAuthSession.find_by(handle: @access_token.session_handle) | ||
end | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
modules/mobile/app/controllers/mobile/v0/payment_information_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters