Skip to content

fix: show error page when Auth0 returns a login error - #967

Merged
kishore7snehil merged 5 commits into
6.xfrom
fix/login-error-feedback
Sep 25, 2026
Merged

kishore7snehil merged 5 commits into
6.xfrom
fix/login-error-feedback

Conversation

@kishore7snehil

@kishore7snehil kishore7snehil commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

When Auth0 returns an error on the login callback (`?error=access_denied`, blocked account,
breached-password policy, a Login Action denying access, etc.), the plugin was silently
redirecting to the site root with no message shown. The same behavior applied when the OAuth
token exchange threw an exception. The default handler uses a fixed generic message rather
than the request-supplied `error_description` - both parameters are attacker-controllable
and displaying them verbatim would allow arbitrary text to appear on the login page without
going through Auth0.

Changes

  • `src/Actions/Authentication.php` - registry: registered `auth0_login_failed` action wired to `onLoginFailed()` with two arguments
  • `src/Actions/Authentication.php` - `onLogin()`: reads `error_description` from the callback alongside `error`; replaced silent redirect on `?error=` path with `do_action('auth0_login_failed', ...)`
  • `src/Actions/Authentication.php` - `onLoginFailed()`: new method - calls `wp_die()` with a fixed generic message and HTTP 200; passes sanitized `$error` and `$errorDescription` to the hook for custom handlers
  • `src/Actions/Authentication.php` - `onExchangeFailed()`: replaced silent `wp_redirect('/')` with `wp_die()`
  • `UPGRADING.md`: noted the authentication error behavior change under the 5.x to 6.x section

References

Closes #964

Testing

Tested manually against the Docker environment (auth0-PHP 9.x, WordPress 7.0, PHP 8.4).

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not the default branch

When Auth0 returns ?error= on the login callback, the plugin was silently
redirecting to /. Reads error_description alongside error, fires a new
auth0_login_failed hook, and calls wp_die() with a fixed generic message.
Same treatment for onExchangeFailed() which also silently redirected.

Default handler shows a fixed message rather than request-supplied values
- both parameters are attacker-controllable (reflected content injection).
Hook passes sanitized $error and $errorDescription for custom handlers.
Comment thread src/Actions/Authentication.php Outdated
Comment thread src/Actions/Authentication.php Outdated
}

public function onExchangeFailed(Throwable $_)
public function onLoginFailed(string $error, string $errorDescription): void

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Small thing: $error and $errorDescription are not used here, and Psalm (in the dev deps) may flag them as unused. Maybe reference them or add a suppression. Also this message says log in while onExchangeFailed says sign-in, worth keeping the wording consistent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 5f18e93.

Comment thread src/Actions/Authentication.php Outdated
Comment thread src/Actions/Authentication.php Outdated
- Strip CR/LF from error and description before error_log to prevent log line injection
- Prefix unused onLoginFailed params with _ to satisfy static analysis
- Unify error message wording between onLoginFailed and onExchangeFailed
- Extend registry to support optional priority in [method, args, priority] format
- Register onLoginFailed at priority 20 so custom handlers at the default priority 10 run first
@kishore7snehil
kishore7snehil merged commit 2264b30 into 6.x Sep 25, 2026
1 check passed
@kishore7snehil
kishore7snehil deleted the fix/login-error-feedback branch September 25, 2026 10:05
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