refactor: use Adminer's own login helpers in the passwordless login plugin - #55
Merged
Conversation
…lugin ## The Issue The plugin seeded `$_SESSION['pwds']` and built the redirect URL by hand, both Adminer internals that can change between releases. The plain text password only worked because `get_password()` falls back for non-array values, Adminer itself encrypts it when it keeps a key in a cookie. ## How This PR Solves The Issue `Adminer\set_password()` now stores the credentials the way Adminer's own login does, and `Adminer\auth_url()` + `Adminer\redirect()` build the same redirect it sends after a manual login. The `$_SESSION['db']` entry is dropped, it is only read to list previous logins. The idea comes from TimWolla/docker-adminer#231, which overrides the login form and submits it with JavaScript. That works in a plugin too, `loginForm()` may print the `auth[...]` fields and return a non-null value to suppress the built-in form, but it needs JavaScript, an extra round trip and a guard against resubmitting a failed login. Calling the helpers keeps the current flow. ## Automated Testing Overview `url_escape()` leaves slashes literal, so the expected SQLite redirect location no longer contains `%2F`. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
The Issue
The plugin seeded
$_SESSION['pwds']and built the redirect URL by hand, both Adminer internals that can change between releases. The plain text password only worked becauseget_password()falls back for non-array values, Adminer itself encrypts it when it keeps a key in a cookie.How This PR Solves The Issue
Adminer\set_password()now stores the credentials the way Adminer's own login does, andAdminer\auth_url()+Adminer\redirect()build the same redirect it sends after a manual login. The$_SESSION['db']entry is dropped, it is only read to list previous logins.The idea comes from TimWolla/docker-adminer#231, which overrides the login form and submits it with JavaScript. That works in a plugin too,
loginForm()may print theauth[...]fields and return a non-null value to suppress the built-in form, but it needs JavaScript, an extra round trip and a guard against resubmitting a failed login. Calling the helpers keeps the current flow.Manual Testing Instructions
Automated Testing Overview
url_escape()leaves slashes literal, so the expected SQLite redirect location no longer contains%2F.