feat(client): redact sensitive headers in thrown exceptions (#290)#665
Open
jsavyasachi wants to merge 1 commit into
Open
feat(client): redact sensitive headers in thrown exceptions (#290)#665jsavyasachi wants to merge 1 commit into
jsavyasachi wants to merge 1 commit into
Conversation
) A non-success response throws a slingshot exception whose data carries the full response and the originating request, including any Authorization (or other credential) headers. Those values end up in logs verbatim. Add a :redact-headers request option: any header whose lower-cased name is in the set has its value replaced with "REDACTED" in both the response and the attached request headers (and in the :throw-entire-message? message). Defaults to #{"authorization" "proxy-authorization"} so credentials are kept out of logs by default; pass a custom set to override, or #{} to disable. Closes dakrone#290.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #290.
A non-success response throws a slingshot exception whose data carries the full response and the originating request (clj-http attaches it under
:request). That request map includes any credential headers -Authorization,Proxy-Authorization- so they land in logs verbatim wherever the exception is printed. Redacting at each log site is error-prone, as the issue notes.This adds a
:redact-headersrequest option: any header whose lower-cased name is in the set has its value replaced with"REDACTED", in both the response headers and the attached request headers (and in the:throw-entire-message?message string). It defaults to#{"authorization" "proxy-authorization"}, so credentials are kept out of logs by default. Pass your own set to override it, or#{}to disable.Per the discussion this covers both request and response headers. Tests cover the default, a custom set on response headers, and disabling.
Verified locally: full
lein with-profile dev,1.10 test :allgreen