Skip to content

fix: preserve authentication failure cause in onAuthenticationFailure#52

Merged
turegjorup merged 1 commit into
developfrom
feature/preserve-authentication-failure-cause
Jun 11, 2026
Merged

fix: preserve authentication failure cause in onAuthenticationFailure#52
turegjorup merged 1 commit into
developfrom
feature/preserve-authentication-failure-cause

Conversation

@turegjorup

Copy link
Copy Markdown
Contributor

Summary

OpenIdLoginAuthenticator::onAuthenticationFailure() previously threw a bare AuthenticationException('Error occurred validating openid login'), dropping the original failure entirely — logs and error reporters could not tell a timeout from a signature mismatch from a wrong nonce.

It now chains the original exception via previous and includes its message in the new exception's message. Symfony's security component still renders only the safe message key to the user, so nothing sensitive is exposed.

This is the last unmerged piece of feature/exception-flow (commit 222bf32), ported onto current develop; the rest of that branch was superseded by the 5.0 exception-contract work (#41 et al.), and the branch is deleted with this PR.

Files Changed

  • src/Security/OpenIdLoginAuthenticator.php - chain previous and preserve the cause message in onAuthenticationFailure()
  • tests/Security/OpenIdLoginAuthenticatorTest.php - assert the thrown exception chains the original as previous and preserves its message
  • CHANGELOG.md - entry under [Unreleased] / Changed

Test Plan

  • task test:coverage — all tests pass, coverage stays at 100% (methods + lines)
  • task analyze:php — PHPStan max level + custom exception-contract rules: no errors (the new throw satisfies WrappedExceptionChainsPrevious)
  • task lint — php-cs-fixer, composer normalize/audit, markdownlint, prettier: all clean

🤖 Generated with Claude Code

onAuthenticationFailure() now chains the original exception via previous
and includes its message, so logs and error reporters retain the actual
cause (timeout vs. signature mismatch vs. wrong nonce). Symfony's
security component still renders only the safe message key to the user.

Ported from feature/exception-flow (222bf32); the rest of that branch
was superseded by the 5.0 exception-contract work.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (af98ef0) to head (b501e1f).

Additional details and impacted files
@@             Coverage Diff             @@
##             develop       #52   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity        62        62           
===========================================
  Files              9         9           
  Lines            282       282           
===========================================
  Hits             282       282           
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@turegjorup turegjorup self-assigned this Jun 11, 2026
@turegjorup turegjorup merged commit 867706f into develop Jun 11, 2026
16 checks passed
@turegjorup turegjorup deleted the feature/preserve-authentication-failure-cause branch June 11, 2026 14:55
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