Public-ready README with AI disclosure; generic example text
This commit is contained in:
parent
e74746bea9
commit
14de7bd573
2 changed files with 86 additions and 42 deletions
126
README.md
126
README.md
|
|
@ -1,68 +1,88 @@
|
||||||
# tinyauth-web
|
# 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
|
## Features
|
||||||
|
|
||||||
- Login with tinyauth (OIDC). Only members of one chosen group may use the tool.
|
- **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.
|
||||||
- First run: the first person to log in picks the allowed group from their own groups.
|
- **Safe env editing.** Each save makes a timestamped backup first. Secret values are masked and never shown; leave a secret blank to keep it.
|
||||||
- Edit, add and delete variables in the env file. Secret values are never shown; leave blank to keep.
|
- **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`.
|
||||||
- Every save writes a backup to `data/backups/` first.
|
- **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.
|
||||||
- Start, stop, restart and status, through a narrow sudoers rule.
|
- **Guided forms.** Create an OIDC client (with a generated secret if you want one) or an app ACL in a few fields.
|
||||||
- Permission checks page shows what is missing.
|
- **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
|
## Layout
|
||||||
|
|
||||||
| Path | Purpose |
|
| Path | Purpose |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `public/` | Web root. Only this directory should be served. |
|
| `public/` | The web root. Only this directory should be served. |
|
||||||
| `src/` | Shared code (not served). |
|
| `src/` | Shared code. Not served. |
|
||||||
| `config.example.php` | Template. Copy to `config.php`. |
|
| `config.example.php` | Template. Copy it to `config.php` and edit. |
|
||||||
| `sudoers/tinyauth-web.sudoers` | Sudo rule for the web user. |
|
| `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_CLIENTID=tinyauth-web
|
||||||
TINYAUTH_OIDC_CLIENTS_TINYAUTHWEB_CLIENTSECRET=<generate a long random secret>
|
TINYAUTH_OIDC_CLIENTS_TINYAUTHWEB_CLIENTSECRET=<a long random secret>
|
||||||
TINYAUTH_OIDC_CLIENTS_TINYAUTHWEB_NAME=tinyauth-web
|
TINYAUTH_OIDC_CLIENTS_TINYAUTHWEB_NAME=tinyauth-web
|
||||||
TINYAUTH_OIDC_CLIENTS_TINYAUTHWEB_TRUSTEDREDIRECTURIS=https://tinyauth-web.example.com/callback.php
|
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
|
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
|
install -m 0440 sudoers/tinyauth-web.sudoers /etc/sudoers.d/tinyauth-web
|
||||||
visudo -cf /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
|
chgrp www-data /etc/tinyauth/tinyauth.env
|
||||||
chmod 660 /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 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:
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
install -d -o www-data -g www-data -m 0750 /path/to/tinyauth-web/data
|
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
|
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.
|
- **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:** Fills in `TINYAUTH_OIDC_CLIENTS_<NAME>_*` for you. Leave the secret blank to generate one. The generated secret is shown once, so copy it then.
|
- **New OIDC client.** Enter a name and the tool writes the `TINYAUTH_OIDC_CLIENTS_<NAME>_*` variables. Leave the secret blank to generate one. A generated secret is shown once, so copy it then.
|
||||||
- **New app ACL:** Fills in `TINYAUTH_APPS_<NAME>_*` for forward-auth apps. Set the domain and whichever users or groups should have access.
|
- **New app ACL.** For apps behind forward auth, enter the app's name and domain, plus any users or groups allowed in.
|
||||||
- **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.
|
- **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.
|
||||||
- **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.
|
- **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.
|
||||||
- **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 `<placeholder>`, fails the whole paste and the popup says why. Nothing is written until you click **Apply**.
|
- **Blank values.** Blank variables are allowed, but the page warns about them, since they can break tinyauth.
|
||||||
- **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.
|
|
||||||
|
|
||||||
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.
|
- **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`.
|
||||||
- The group is read from the `groups` claim of the OIDC userinfo response. If your tinyauth uses a different claim, set `groups_claim`.
|
- **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.
|
||||||
- To clear the access group, use **Change access group** on the page (only available to members of the current group).
|
- **Clearing a secret.** The web form won't clear a secret, to avoid accidental wipes. Edit the env file directly to clear one.
|
||||||
- To clear a secret value, edit the file in a terminal. The web form doesn't clear secrets.
|
- **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.
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ function key_help(): array
|
||||||
['key' => 'TINYAUTH_UI_TITLE',
|
['key' => 'TINYAUTH_UI_TITLE',
|
||||||
'layman' => 'The title shown on the tinyauth login page.',
|
'layman' => 'The title shown on the tinyauth login page.',
|
||||||
'expert' => 'Page title and header text for the tinyauth UI. Default "Tinyauth".',
|
'expert' => 'Page title and header text for the tinyauth UI. Default "Tinyauth".',
|
||||||
'example' => 'Clayton\'s Login'],
|
'example' => 'My Login'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue