auth-oauth2: log callback failures to system logs#304
Open
pmdrs wants to merge 1 commit into
Open
Conversation
OAuth2AuthenticationTrait::callback() had a TODO comment and a bare
catch (Exception $ex) { return false; } that silently swallowed all
authentication errors. Admins had zero visibility when an IdP returned
invalid_client/invalid_grant, when the OAuth2 state did not match, or
when sign-in/auto-registration failed after a successful token
exchange.
Add $ost->logWarning()/logError() calls on each failure path. No
behavior change - the method still returns the same values; it now
also records a diagnostic entry in the System Logs (ost_syslog).
1802fda to
0e8b04d
Compare
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.
Summary
OAuth2AuthenticationTrait::callback()has a//TODO: Log any errors to system logscomment that was never implemented, paired with a barecatch (Exception $ex) { return false; }. Every authentication failure in the OAuth2 callback flow — staff, end-user, and email-account variants all share this trait — is currently invisible to admins: nothing is written to the System Logs (ost_syslog), and the user/agent is just silently bounced back to the login screen.This PR adds
$ost->logWarning()/logError()calls on each failure branch. No behavior changes — return values are identical; this only adds diagnostics.Reproduction (currently silent)
invalid_client/invalid_grant), thecatch (Exception $ex)swallows it, and the user is redirected back to login with no message.A second silent path: the token exchange succeeds but
signIn()can't match/auto-register the returned attributes to a local account (e.g. missingusername/emailclaim from the IdP) — also currently unlogged.Test plan
logWarning/logErrorentry now appears in System Logs on failed callback.OAuth2AuthenticationTrait) still authenticate correctly.