-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AuthenticatedControllerAction sets Raven current_user for APIs (#13825)
We were not capturing the current user on IDT API requests for Sentry reporting. This refactor makes the `set_raven_user` method a controller concern we can share in any controller that needs to capture `current_user` for error reporting. See https://dsva.slack.com/archives/CD5DAQNCU/p1585581882005900
- Loading branch information
Showing
7 changed files
with
81 additions
and
53 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
CVES: | ||
CVE-2020-5267: 2020-03-29 | ||
# placeholder to make non-nil array | ||
CVE-no-such-number: 2020-01-01 |
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
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
23 changes: 23 additions & 0 deletions
23
app/controllers/concerns/authenticated_controller_action.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,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module AuthenticatedControllerAction | ||
extend ActiveSupport::Concern | ||
|
||
def set_raven_user | ||
return unless sentry_reporting_is_live? | ||
|
||
if current_user | ||
# Raven sends error info to Sentry. | ||
Raven.user_context( | ||
email: current_user.email, | ||
css_id: current_user.css_id, | ||
station_id: current_user.station_id, | ||
regional_office: current_user.regional_office | ||
) | ||
end | ||
end | ||
|
||
def sentry_reporting_is_live? | ||
ENV["SENTRY_DSN"] | ||
end | ||
end |
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