Enhance publiser password management tool

Add support for multiple users in the password utility. New
features allow listing existing users and removing specific users
from the `.htpasswd` file without overwriting others.
This commit is contained in:
Ruben 2026-08-30 22:24:16 +02:00
parent 747e730366
commit 6525b561c2
2 changed files with 59 additions and 14 deletions

View file

@ -25,13 +25,15 @@ Standalone admin app for authoring, managing, and scheduling `content/nyheter/`
`content/publiser/.htaccess` sets `DirectorySlash On` (the site-wide default is `Off` - see Critical section below) and forwards the `Authorization` header via `RewriteRule ... [E=HTTP_AUTHORIZATION:...]` for SAPIs (LSAPI/CGI/FastCGI, used on cPanel) that strip it by default.
Auth itself is checked in PHP (`publiserRequireAuth()` in `index.php`), not via Apache's `AuthUserFile` - that directive needs an absolute path that differs between the podman dev container and cPanel, so a bcrypt `.htpasswd` (same format `mod_authn_file` would use) is read and verified manually instead. Set the login with:
Auth itself is checked in PHP (`publiserRequireAuth()` in `index.php`), not via Apache's `AuthUserFile` - that directive needs an absolute path that differs between the podman dev container and cPanel, so a bcrypt `.htpasswd` (same format `mod_authn_file` would use) is read and verified manually instead. Manage logins with:
```bash
php custom/tools/set-publiser-password.php <username> <password>
php custom/tools/set-publiser-password.php <username> <password> # add, or update if it exists
php custom/tools/set-publiser-password.php --list
php custom/tools/set-publiser-password.php --remove <username>
```
This writes `content/publiser/.htpasswd` (gitignored, `0644` - see comment in the script for why world-readable is fine here).
Supports multiple users - adding/updating one username preserves everyone else's entry in `content/publiser/.htpasswd` (gitignored, `0644` - see comment in the script for why world-readable is fine here). There's no per-user attribution anywhere in the tool (all edits are just "whoever is logged in"); this only lets more than one person log in.
## Content Model