Skip to content

refactor: use Adminer's own login helpers in the passwordless login plugin - #55

Merged
stasadev merged 1 commit into
mainfrom
20260820_stasadev_login
Aug 20, 2026
Merged

refactor: use Adminer's own login helpers in the passwordless login plugin#55
stasadev merged 1 commit into
mainfrom
20260820_stasadev_login

Conversation

@stasadev

@stasadev stasadev commented Aug 20, 2026

Copy link
Copy Markdown
Member

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.

Manual Testing Instructions

ddev add-on get ddev/ddev-adminer --pr 55
ddev restart

Automated Testing Overview

url_escape() leaves slashes literal, so the expected SQLite redirect location no longer contains %2F.

…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>
@stasadev
stasadev merged commit 5c89675 into main Aug 20, 2026
2 checks passed
@stasadev
stasadev deleted the 20260820_stasadev_login branch August 20, 2026 13:58
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.

1 participant