Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture exception in the controller to examine exact parameters #895

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/controllers/oidc_events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ def backchannel_logout
LogoutNotice.new(user_id).persist
head :ok
end
rescue OidcClient::BackchannelLogoutFailure
rescue OidcClient::BackchannelLogoutFailure => e
capture_sensitive_exception(e, { parameters: params.hash })
head :bad_request
end

Expand All @@ -24,4 +25,13 @@ def oidc_client
OidcClient.new
end
end

def capture_sensitive_exception(error, extra_info = {})
captured = SensitiveException.create!(
message: error.message,
full_message: error.full_message,
extra_info: extra_info.to_json,
)
GovukError.notify("CapturedSensitiveException", { extra: { sensitive_exception_id: captured.id } })
end
end
3 changes: 1 addition & 2 deletions app/lib/oidc_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ def logout_token(logout_token_jwt)
rescue JSON::JWS::VerificationFailed => e
capture_sensitive_exception(e)
raise BackchannelLogoutFailure
rescue NoMethodError => e
capture_sensitive_exception(e, { logout_token_jwt: })
rescue NoMethodError
raise BackchannelLogoutFailure
end

Expand Down