Skip to content

feat: sanitize authentication errors for safer browser messages#8

Merged
appleboy merged 2 commits intomainfrom
sanitizer
Feb 27, 2026
Merged

feat: sanitize authentication errors for safer browser messages#8
appleboy merged 2 commits intomainfrom
sanitizer

Conversation

@appleboy
Copy link
Member

  • Introduce error sanitization for OAuth and token exchange errors to prevent sensitive information disclosure in browser messages
  • Show user-friendly, sanitized error messages in the browser, while retaining full error details in the terminal output
  • Add tests verifying that browser messages do not leak backend details and remain generic
  • Add utility functions for error sanitization and testing their correctness

- Introduce error sanitization for OAuth and token exchange errors to prevent sensitive information disclosure in browser messages
- Show user-friendly, sanitized error messages in the browser, while retaining full error details in the terminal output
- Add tests verifying that browser messages do not leak backend details and remain generic
- Add utility functions for error sanitization and testing their correctness

Signed-off-by: appleboy <appleboy.tw@gmail.com>
Copilot AI review requested due to automatic review settings February 27, 2026 08:59
Copy link

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

This PR adds an error-sanitization layer for the browser-facing OAuth callback UI so that sensitive backend/auth details remain in terminal output while the browser only shows generic, user-friendly messages.

Changes:

  • Introduces sanitizeOAuthError and sanitizeTokenExchangeError helpers to generate browser-safe messages.
  • Updates the callback handler to render sanitized messages in the browser while still returning detailed errors to the caller (terminal/TUI path).
  • Adds/updates tests to verify browser pages don’t leak detailed OAuth/token-exchange failure information.

Reviewed changes

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

File Description
callback.go Writes only sanitized failure messages to the browser and preserves detailed errors in returned error.
callback_test.go Extends callback flow tests to assert browser output is sanitized while terminal error retains details.
error_sanitizer.go Adds sanitization utilities used by the callback handler.
error_sanitizer_test.go Adds unit tests for sanitization helpers and substring-check utility.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Remove the containsAny helper function and its associated tests
- Change sanitizeTokenExchangeError to ignore the error parameter entirely for improved security

Signed-off-by: appleboy <appleboy.tw@gmail.com>
@appleboy appleboy merged commit 0e84a78 into main Feb 27, 2026
16 checks passed
@appleboy appleboy deleted the sanitizer branch February 27, 2026 09:46
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.

2 participants