AuthPanel: tolerate authenticators that throw on getIdentificationProvider()#180
Merged
Merged
Conversation
…vider()
Some authenticators operate without an identifier, most notably the session
authenticator with its default `identify` => false. On cakephp/authentication
4.x, AuthenticationService::getIdentificationProvider() then throws
("Identifier is required for ...") instead of returning null, which took the
whole request down as soon as the debug panel collected its data.
Wrap the call in a try/catch (matching the existing roles() handling) so the
panel degrades to "no identification provider" instead of crashing. This keeps
the panel working across Authentication versions regardless of the upstream fix.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #180 +/- ##
============================================
+ Coverage 78.06% 78.13% +0.06%
- Complexity 491 492 +1
============================================
Files 32 32
Lines 1313 1317 +4
============================================
+ Hits 1025 1029 +4
Misses 288 288 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #179.
Problem
Enabling the panel:
made every request throw once a session based login was active:
The session authenticator (default
identify=> false) authenticates from stored session data and has no identifier. On cakephp/authentication 4.xAuthenticationService::getIdentificationProvider()calls the authenticator'sgetIdentifier(), which throws in that case, soAuthPanel::shutdown()blew up while collecting data.Fix
Wrap the
getIdentificationProvider()call in a try/catch (matching the existingroles()handling in the same method) and fall back to "no identification provider". The panel is diagnostic code and must never take down the request.This keeps the panel working across Authentication versions regardless of the upstream fix (cakephp/authentication#808), which makes
getIdentificationProvider()returnnullfor identifier-less authenticators.