# tinyauth-web 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 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/` | 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. | | `examples/nginx/` | nginx examples for a subdomain or a subpath. | | `data/` | Created at runtime: settings and backups. Not served. | ## Requirements - 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_NAME=tinyauth-web TINYAUTH_OIDC_CLIENTS_TINYAUTHWEB_TRUSTEDREDIRECTURIS=https://tinyauth-web.example.com/callback.php ``` Restart tinyauth afterwards. You can also add the client from the tool's **New OIDC client** form once it's running. 2. **Create `config.php`:** ``` cp config.example.php config.php ``` 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. See `examples/nginx/` for complete server blocks. 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 in the file matches `command -v systemctl`. 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 ``` 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 chown root:www-data /path/to/tinyauth-web/config.php chmod 640 /path/to/tinyauth-web/config.php ``` `config.php` holds the client secret, so it must not be readable by everyone. 7. **Open the page, log in, and choose the access group.** Check the **Permission checks** panel. Every row should show ✔. ## Using the tool - **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. Restart the tinyauth service after any change. The page reminds you of this. ## Configuration notes - **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.