From 14de7bd5735af0a14f3076a4f901f2bdcfe88d70 Mon Sep 17 00:00:00 2001 From: Clarth Date: Tue, 1 Dec 2026 17:20:55 -0500 Subject: [PATCH] Public-ready README with AI disclosure; generic example text --- README.md | 126 ++++++++++++++++++++++++++++++++++----------------- src/help.php | 2 +- 2 files changed, 86 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index b4a0ecf..8b21911 100644 --- a/README.md +++ b/README.md @@ -1,68 +1,88 @@ # tinyauth-web -A small PHP web UI to edit the tinyauth environment file, and to start, stop, restart and check the tinyauth systemd service. Login goes through tinyauth itself (OIDC). +A small PHP web interface for managing a [tinyauth](https://tinyauth.app) install that runs under systemd. From the browser you can: + +- edit the tinyauth env file (add, change, and delete variables), +- start, stop, restart, and check the tinyauth service, +- create OIDC clients and forward-auth app rules without looking up variable names, +- log in with tinyauth itself, and limit access to one group. + +No database is needed, and it runs on any PHP 8.1+ setup with nginx or Apache. It doesn't need the curl extension. + +> **About this project:** This was built with the help of an AI model. A person designed it, chose its features, tested it against tinyauth v5.2.0, and reviewed the basics of the code. The author is not a PHP expert, so review it carefully before running it anywhere important. Bug reports and pull requests are welcome. + +> **Not affiliated with tinyauth.** This is an unofficial companion tool. Tinyauth is a separate project. ## Features -- Login with tinyauth (OIDC). Only members of one chosen group may use the tool. -- First run: the first person to log in picks the allowed group from their own groups. -- Edit, add and delete variables in the env file. Secret values are never shown; leave blank to keep. -- Every save writes a backup to `data/backups/` first. -- Start, stop, restart and status, through a narrow sudoers rule. -- Permission checks page shows what is missing. +- **Login through tinyauth (OIDC).** The first person to log in picks the group allowed to use the tool. Everyone else sees an access-denied page. +- **Safe env editing.** Each save makes a timestamped backup first. Secret values are masked and never shown; leave a secret blank to keep it. +- **Core settings.** Install-level variables (addresses, URLs, cookies, LDAP connection, keys, database, logs) sit in a closed section, so the page stays clean. You can change the list of core keys in `config.php`. +- **Paste many variables at once.** Paste `KEY=VALUE` lines, review them in a popup, choose Keep or Update for anything that already exists, then apply. A single bad line stops the whole paste, and the popup says why. +- **Guided forms.** Create an OIDC client (with a generated secret if you want one) or an app ACL in a few fields. +- **Help everywhere.** Each common key and form field has a **?** tooltip with a plain-language explanation, an expert one, and an example. A full key reference lists every setting tinyauth accepts. +- **Service control.** Start, stop, restart, and status, through a narrow sudo rule that allows only those four commands on the tinyauth unit. +- **Permission checks.** A panel shows what's missing (sudo rules, file permissions), so setup problems are easy to spot. +- **Light and dark themes.** ## Layout | Path | Purpose | | --- | --- | -| `public/` | Web root. Only this directory should be served. | -| `src/` | Shared code (not served). | -| `config.example.php` | Template. Copy to `config.php`. | +| `public/` | The web root. Only this directory should be served. | +| `src/` | Shared code. Not served. | +| `config.example.php` | Template. Copy it to `config.php` and edit. | | `sudoers/tinyauth-web.sudoers` | Sudo rule for the web user. | -| `data/` | Created at runtime: settings and backups. | +| `examples/nginx/` | nginx examples for a subdomain or a subpath. | +| `data/` | Created at runtime: settings and backups. Not served. | -## Install +## Requirements -1. **Register an OIDC client in tinyauth.** In the tinyauth env file, add a client, for example: +- PHP 8.1 or newer, with PHP-FPM +- A web server (nginx examples are included) +- tinyauth v5.2.0 or later, running under systemd, with an HTTPS public URL +- Sudo, for the service controls + +## Installation + +1. **Register an OIDC client in tinyauth.** Add a client to the tinyauth env file. The client ID and secret must match `config.php` in step 2: ``` TINYAUTH_OIDC_CLIENTS_TINYAUTHWEB_CLIENTID=tinyauth-web - TINYAUTH_OIDC_CLIENTS_TINYAUTHWEB_CLIENTSECRET= + TINYAUTH_OIDC_CLIENTS_TINYAUTHWEB_CLIENTSECRET= TINYAUTH_OIDC_CLIENTS_TINYAUTHWEB_NAME=tinyauth-web TINYAUTH_OIDC_CLIENTS_TINYAUTHWEB_TRUSTEDREDIRECTURIS=https://tinyauth-web.example.com/callback.php ``` - Then restart tinyauth. Use the same client secret in `config.php`. + Restart tinyauth afterwards. You can also add the client from the tool's **New OIDC client** form once it's running. -2. **Copy the app** to the server, then: +2. **Create `config.php`:** ``` cp config.example.php config.php ``` - Edit `config.php`: `tinyauth_url`, `client_id`, `client_secret`, `redirect_uri`, `env_file`, and `service`. + Edit `tinyauth_url`, `client_id`, `client_secret`, `redirect_uri`, `env_file`, and `service`. The `redirect_uri` must match the trusted redirect URI from step 1 exactly, including `https://`. -3. **Point the web server at `public/`.** Use HTTPS. The app sets secure cookies only over HTTPS. +3. **Point the web server at `public/`.** Use HTTPS. See `examples/nginx/` for complete server blocks. -4. **Sudo rule** (as root): +4. **Install the sudo rule** (as root): ``` install -m 0440 sudoers/tinyauth-web.sudoers /etc/sudoers.d/tinyauth-web visudo -cf /etc/sudoers.d/tinyauth-web ``` - Check that the systemctl path matches `command -v systemctl`. + Check that the systemctl path in the file matches `command -v systemctl`. -5. **Let the web user edit the env file** (keep the file owned by root, and only group-writable by the web user): +5. **Let the web user edit the env file.** Keep the file owned by root, and make it writable by the web group only: ``` chgrp www-data /etc/tinyauth/tinyauth.env chmod 660 /etc/tinyauth/tinyauth.env ``` - Make sure the `data/` directory is writable by `www-data`, and that it is not inside the web root. - -6. **Set file permissions** (as root). PHP runs as `www-data`, so it needs to read the code and config and write `data/`. Pre-create `data/`, because the checkout is usually owned by your own user: +6. **Set the directory and file permissions** (as root). PHP runs as `www-data`, so it must be able to read the code and config and write `data/`. Create `data/` yourself, because the checkout is usually owned by your own user: ``` install -d -o www-data -g www-data -m 0750 /path/to/tinyauth-web/data @@ -70,26 +90,50 @@ A small PHP web UI to edit the tinyauth environment file, and to start, stop, re chmod 640 /path/to/tinyauth-web/config.php ``` - `config.php` holds the client secret, so it must not be world-readable. + `config.php` holds the client secret, so it must not be readable by everyone. -7. Open the page, log in, and pick the access group. Check the **Permission checks** section. +7. **Open the page, log in, and choose the access group.** Check the **Permission checks** panel. Every row should show ✔. -## Managing entries +## Using the tool -- **Config table:** Every variable in the env file. Each one shows a short description where it's known. Secrets are masked. Add new variables in the bottom row. The **Key reference** at the bottom lists every key tinyauth accepts, with defaults. It's filterable. -- **New OIDC client:** Fills in `TINYAUTH_OIDC_CLIENTS__*` for you. Leave the secret blank to generate one. The generated secret is shown once, so copy it then. -- **New app ACL:** Fills in `TINYAUTH_APPS__*` for forward-auth apps. Set the domain and whichever users or groups should have access. -- **Local users:** Tinyauth hashes passwords, so create users on the server with `tinyauth user create --interactive`. Add the printed `username:hash` line to `TINYAUTH_AUTH_USERS` (comma-separated), then restart. Hashes are masked here. -- **Blank values:** Saving or leaving a blank required value is allowed, but the page warns about every blank variable. Blank values can break tinyauth, so fill them in or delete them. -- **Paste multiple variables:** Paste `KEY=VALUE` lines in one box, then click **Review**. A popup lists what's new and what already exists. For existing keys, choose **Keep** or **Update**. Any malformed or duplicated line, or an unfilled ``, fails the whole paste and the popup says why. Nothing is written until you click **Apply**. -- **Help icons (?):** Hover or focus a **?** to see a plain-language explanation, an expert explanation, and an example. The most common keys and the tool's forms have them. -- **Collapsible sections:** Paste, the client and app forms, local users, and the key reference start closed. Click the heading to open. +- **Config.** Core settings are closed by default. Other settings are listed below them, and the add row at the bottom creates new variables. The key reference lists every setting tinyauth accepts. +- **New OIDC client.** Enter a name and the tool writes the `TINYAUTH_OIDC_CLIENTS__*` variables. Leave the secret blank to generate one. A generated secret is shown once, so copy it then. +- **New app ACL.** For apps behind forward auth, enter the app's name and domain, plus any users or groups allowed in. +- **Paste multiple variables.** Paste `KEY=VALUE` lines (blank lines and `#` comments are ignored), click **Review**, choose Keep or Update for anything that already exists, then **Apply**. Nothing is written before you apply. +- **Local users.** The tool doesn't create passwords, because tinyauth hashes them. On the server, run `tinyauth user create --interactive`, copy the printed `username:hash` line, and add it to `TINYAUTH_AUTH_USERS` (comma-separated). Then restart tinyauth. +- **Blank values.** Blank variables are allowed, but the page warns about them, since they can break tinyauth. -Every change writes a backup to `data/backups/` first. +Restart the tinyauth service after any change. The page reminds you of this. -## Notes +## Configuration notes -- Saved changes take effect only after tinyauth is restarted. The page reminds you of this. -- The group is read from the `groups` claim of the OIDC userinfo response. If your tinyauth uses a different claim, set `groups_claim`. -- To clear the access group, use **Change access group** on the page (only available to members of the current group). -- To clear a secret value, edit the file in a terminal. The web form doesn't clear secrets. +- **Groups.** Access is decided by the `groups` claim in the OIDC userinfo response. If your tinyauth sends groups under another name, change `groups_claim` in `config.php`. +- **Core keys.** To change which settings appear in the Core section, edit `core_keys` in `config.php`. Patterns support `*`. Leaving the setting out uses the built-in list. +- **Clearing a secret.** The web form won't clear a secret, to avoid accidental wipes. Edit the env file directly to clear one. +- **Changing the access group.** Use **Change access group** on the page. Only current group members can do this. + +## Security notes + +- Serve only `public/`. `config.php`, `src/`, and `data/` must not be reachable over HTTP. The nginx examples do this. +- Use HTTPS. Secure cookies are only sent over HTTPS. +- Keep `config.php` and the env file readable only by the owner and `www-data`. +- The sudo rule allows only `status`, `start`, `stop`, and `restart` for one unit. Don't widen it. +- Form posts are protected with a per-session token (CSRF). +- Secrets are masked in the page, but they are still written to the env file and to backups in `data/backups/`. Protect that directory. + +## Testing + +The project has no automated tests yet. The checks run during development: + +- PHP syntax checks on every file (`php -l`) +- login, config editing, paste review, and service actions run against tinyauth v5.2.0, locally and under `www-data` + +Contributions with tests are welcome. + +## Contributing + +Issues and pull requests are welcome. Keep changes small and in the existing style, and describe what you tested. + +## Licence + +No licence has been chosen yet. Until one is added, all rights are reserved by the author. diff --git a/src/help.php b/src/help.php index 00bf0e8..0a6d48d 100644 --- a/src/help.php +++ b/src/help.php @@ -131,7 +131,7 @@ function key_help(): array ['key' => 'TINYAUTH_UI_TITLE', 'layman' => 'The title shown on the tinyauth login page.', 'expert' => 'Page title and header text for the tinyauth UI. Default "Tinyauth".', - 'example' => 'Clayton\'s Login'], + 'example' => 'My Login'], ]; }