|
2 | 2 |
|
3 | 3 | Authentication proxy for Acrobits application. |
4 | 4 |
|
5 | | -The application needs a `TOKEN` environment application on startup. |
| 5 | +This application acts as a middleware to authenticate users. It validates |
| 6 | +incoming POST requests containing a username, password, and a shared secret |
| 7 | +token. If the token matches the configured secret, it attempts to authenticate |
| 8 | +the user against a remote service. |
6 | 9 |
|
7 | | -Each request must be a POST request containing a JSON object. |
8 | | -The object must have the following fields: |
| 10 | +## API Usage |
| 11 | + |
| 12 | +**Authentication Endpoint**: POST to root path `/` |
| 13 | + |
| 14 | +Each request must be a POST request containing a JSON object with the following |
| 15 | +fields: |
9 | 16 | - `username` |
10 | 17 | - `password` |
11 | | -- `token`: it's a SHA256 hash, it must be the same passed to the application at startup |
| 18 | +- `token`: it's a SHA256 hash, it must be the same passed to the application at |
| 19 | + startup |
| 20 | + |
| 21 | +**Examples:** |
| 22 | +```bash |
| 23 | +# HTTP (redirects to HTTPS) |
| 24 | +curl -d '{"username": "[email protected]", "password": "mypass", "token": "11223344"}' \ |
| 25 | + http://localhost:8080 |
| 26 | + |
| 27 | +# HTTPS with self-signed certificate |
| 28 | +curl -k -d '{"username": "[email protected]", "password": "mypass", "token": "11223344"}' \ |
| 29 | + https://localhost:8443 |
12 | 30 |
|
13 | | -Example with curl: |
| 31 | +# HTTPS production example |
| 32 | +curl -d '{"username": "[email protected]", "password": "mypass", "token": "11223344"}' \ |
| 33 | + https://ctiapp-authproxy.example.com |
14 | 34 | ``` |
15 | | -curl -d '{"username": "[email protected]", "password": "mypass", "token": "11223344"}' https://ctiapp-authproxy.example.com |
| 35 | + |
| 36 | +**Health Check**: GET `/index.php/healthcheck` |
| 37 | + |
| 38 | +```bash |
| 39 | +curl http://localhost:8080/index.php/healthcheck |
| 40 | +curl -k https://localhost:8443/index.php/healthcheck |
| 41 | +curl https://ctiapp-authproxy.example.com/index.php/healthcheck |
16 | 42 | ``` |
| 43 | + |
| 44 | +## Settings |
| 45 | + |
| 46 | +The application is configured using environment variables. You can create a |
| 47 | +`.env` file based on `.env.example`. |
| 48 | + |
| 49 | +| Variable | Description | Default / Example | |
| 50 | +|----------|-------------|-------------------| |
| 51 | +| `APP_HOSTNAME` | The hostname where the application is reachable. | `app.example.com` | |
| 52 | +| `TOKEN` | A shared secret token (SHA256 hash) used to validate requests. | `your_token_here` | |
| 53 | +| `DEBUG` | Enable debug logging. | `false` | |
| 54 | +| `VALIDATE_LK_URL` | URL used to validate the license key/token. | `https://example.com/validate` | |
| 55 | + |
| 56 | +## Development |
| 57 | + |
| 58 | +This project uses `just` as a command runner to simplify development tasks. |
| 59 | + |
| 60 | +### Prerequisites |
| 61 | + |
| 62 | +- `just` installed (see [just installation guide](https://github.com/casey/just?tab=readme-ov-file#installation)) |
| 63 | +- `podman` |
| 64 | +- `podman-compose` |
| 65 | +- `podlet` installed (see [podlet installation guide](https://github.com/containers/podlet?tab=readme-ov-file#install)) |
| 66 | +- `git` |
| 67 | + |
| 68 | +### Common Commands |
| 69 | + |
| 70 | +- **Start Development Environment**: |
| 71 | + ```bash |
| 72 | + just dev-start |
| 73 | + ``` |
| 74 | + Starts the application and Traefik reverse proxy in the background. |
| 75 | + |
| 76 | +- **Stop Development Environment**: |
| 77 | + ```bash |
| 78 | + just dev-stop |
| 79 | + ``` |
| 80 | + Stops and removes the running containers. |
| 81 | + |
| 82 | +- **View Logs**: |
| 83 | + ```bash |
| 84 | + just dev-logs |
| 85 | + ``` |
| 86 | + Follows the logs of the application and Traefik. |
| 87 | + |
| 88 | +- **Rebuild and Restart**: |
| 89 | + ```bash |
| 90 | + just dev-rebuild |
| 91 | + ``` |
| 92 | + Rebuilds the container images without cache and restarts the environment. |
| 93 | + |
| 94 | +- **Run Checks**: |
| 95 | + ```bash |
| 96 | + just check |
| 97 | + ``` |
| 98 | + Runs configuration and dependency checks. |
| 99 | + |
| 100 | +## Deployment |
| 101 | + |
| 102 | +Deployment is automated using Ansible and Podman Quadlet, targeting Rocky Linux systems. |
| 103 | + |
| 104 | +### Prerequisites |
| 105 | + |
| 106 | +- `ansible` installed on the deployment machine. |
| 107 | +- `ansible-lint` (optional) |
| 108 | +- SSH access to the target Rocky Linux server. |
| 109 | + |
| 110 | +### Deployment Steps |
| 111 | + |
| 112 | +1. **Configure settings** Ensure the `.env` file is properly set up with your desired configuration. |
| 113 | +1. **Run Deployment**: |
| 114 | + ```bash |
| 115 | + just deploy |
| 116 | + ``` |
| 117 | + This command executes the `deploy/deploy.yml` playbook which: |
| 118 | + - **Host Setup**: Prepares the Rocky Linux host (updates packages, installs Podman). |
| 119 | + - **App Deploy**: Deploys the application using Podman Quadlet files located in the `quadlet/` directory. |
| 120 | +1. **Verify Deployment**: |
| 121 | + After deployment, the service runs as a systemd user service. |
| 122 | + - Check status: `systemctl --user status app.service` |
| 123 | + - View logs: `journalctl --user -u app.service -f` |
| 124 | + |
| 125 | +### Auto-Update Mechanism |
| 126 | + |
| 127 | +The deployment includes an automatic update mechanism for the application |
| 128 | +containers using Podman's auto-update feature. |
| 129 | +
|
| 130 | +- **Configuration**: The `app.container` is configured with |
| 131 | + `AutoUpdate=registry`, which means Podman will check the container registry |
| 132 | + for newer images. |
| 133 | +- **Timer**: A systemd timer (`podman-auto-update.timer`) is enabled for the |
| 134 | + application user. It triggers the update check daily (or as configured). |
| 135 | +- **Process**: When the timer fires, Podman checks if a new image is |
| 136 | + available in the registry. If an update is found, Podman pulls the new |
| 137 | + image and restarts the container automatically. |
| 138 | +- **Manual Trigger**: You can manually trigger an update check by running as |
| 139 | + the application user: |
| 140 | + ```bash |
| 141 | + podman auto-update |
| 142 | + ``` |
0 commit comments