# Portal Auth Admin Dashboard Web dashboard to view and edit the `portal_auth` database. **Only users with role `admin`** in the `users` table can log in. ## Setup 1. Copy `.env.example` to `.env` and set: - `DB_AUTH_HOST`, `DB_AUTH_PORT`, `DB_AUTH_NAME`, `DB_AUTH_USER`, `DB_AUTH_PASSWORD` (same as your portal auth DB) - `SECRET_KEY` (random string for session signing) 2. Install dependencies: ```bash pip install -r requirements.txt ``` 3. Run the app: ```bash python app.py ``` By default it listens on `http://0.0.0.0:5000`. ## Features - **Login**: Admin only (role = `admin`, `is_active` = true). Passwords verified with bcrypt (or legacy salt:hash). - **Dashboard**: Links to each table. - **Users**: View all; create new user; edit role (admin/support) and active flag; change password. - **Sessions**: View active sessions; revoke (delete) a session. - **Auth logs**: View only (append-only log). - **API tokens**: View; activate/deactivate; delete. ## Deployment to Auth LXC (10.110.60.210) From your machine (with SSH access to the server): ```bash ./deploy/deploy.sh ``` This will: - Rsync app files to `/opt/portal-auth-dashboard` on `root@10.110.60.210` - Create a Python venv and install dependencies (including gunicorn) - Create `.env` from `deploy/.env.server` if missing (you must edit it on the server to set `DB_AUTH_PASSWORD` and `SECRET_KEY`) - Install and start the systemd unit `portal-auth-dashboard` (listens on port 5000) **After first deploy**, on the server set the real credentials: ```bash ssh root@10.110.60.210 nano /opt/portal-auth-dashboard/.env # set DB_AUTH_PASSWORD and SECRET_KEY systemctl restart portal-auth-dashboard ``` Dashboard URL: **http://10.110.60.210:5000** ### Manual deploy (if the script is not used) On the server (Debian): ```bash apt-get update && apt-get install -y python3-venv python3-pip rsync mkdir -p /opt/portal-auth-dashboard ``` From your machine, sync the project (excluding `.env`, `venv`, `.git`), then on the server: ```bash cd /opt/portal-auth-dashboard python3 -m venv venv && ./venv/bin/pip install -r requirements.txt cp deploy/.env.server .env # then edit .env cp deploy/portal-auth-dashboard.service /etc/systemd/system/ systemctl daemon-reload && systemctl enable --now portal-auth-dashboard ``` ## Production notes Run behind a reverse proxy (e.g. nginx) with HTTPS. Set `SECRET_KEY` and ensure the app can reach the Auth DB (on the same host use `DB_AUTH_HOST=127.0.0.1`).