Skip to content

Add Authorization Bearer token pattern #124

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

Merged
merged 4 commits into from
May 26, 2025

Conversation

rewinfrey
Copy link
Contributor

Pulled out from https://github.com/github/blackbird-mw/pull/3756.

This adds a regex pattern for redacting Authorization: Bearer <token>.

@Copilot Copilot AI review requested due to automatic review settings May 20, 2025 22:43
@rewinfrey rewinfrey requested a review from GrantBirki as a code owner May 20, 2025 22:43
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Introduces support for redacting Authorization: Bearer <token> headers in the logging middleware.

  • Adds a case-insensitive regex to lib/patterns/default.rb to match and redact bearer tokens.
  • Expands spec/lib/redacting_logger_spec.rb with a test case ensuring the new header is redacted.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/patterns/default.rb Adds a regex pattern for case-insensitive Authorization: Bearer token redaction
spec/lib/redacting_logger_spec.rb Adds a test case to verify redaction of the bearer header
Comments suppressed due to low confidence (1)

spec/lib/redacting_logger_spec.rb:166

  • It may be useful to add a test case for a lowercase authorization: bearer header to ensure the pattern's case-insensitivity is correctly applied.
message: '-H  "Authorization: Bearer ab123456789a1abcd1~_.-+456ABCDE=" -H "Content-Type: application/json"',

@rewinfrey rewinfrey requested a review from look May 22, 2025 16:49
look
look previously approved these changes May 22, 2025
Copy link
Member

@look look left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for upstreaming this @rewinfrey.

GrantBirki
GrantBirki previously approved these changes May 26, 2025
Copy link
Member

@GrantBirki GrantBirki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rewinfrey thank you very much for upstreaming these changes and helping to improve this gem! 🙇 ❤️

@GrantBirki GrantBirki merged commit f23471a into main May 26, 2025
11 checks passed
@GrantBirki GrantBirki deleted the rewinfrey/add-pattern-for-bearer-tokens branch May 26, 2025 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants