oscar-admin/README.md
Oscar Admin Contributors 5116b13d0c Harden admin security and encrypt Gotify tokens
Encrypt per-user Gotify tokens at rest with sodium/openssl, add app_secret config, security headers, Apache .htaccess hardening, and restrictive permissions for stored settings.
2026-12-03 18:32:16 -05:00

157 lines
6.1 KiB
Markdown
Executable file

# Oscar Admin
A standalone, web-based admin dashboard for [Open OSCAR Server](https://github.com/oscar-server/oscar-server) (AIM/ICQ OSCAR protocol).
Oscar Admin provides a clean UI for day-to-day server administration: users, sessions, chat rooms, messaging, directory, BART assets, buddy lists (feedbag), audit logs, and a raw Management API console.
> **Status:** Active. The admin panel is intended to be deployed alongside Open OSCAR Server, but this repository is standalone and does not require changes to the server source.
## Features
- **Secure login** - OSCAR screen name + math anti-spam challenge + one-time code sent via OSCAR IM.
- **Anti-enumeration** - Allowed and non-allowed screen names get the same login flow/UI.
- **Optional Gotify delivery** - Per-user Gotify URL/token settings; login codes can be sent through Gotify when configured. 100% optional.
- **Overview** - Version, online sessions, users, and room counts.
- **User management** - List/search, create/delete, details, suspend/unsuspend, bot flag, password reset, buddy icon, active sessions.
- **Session management** - List active sessions, inspect details, kick sessions.
- **Chat rooms** - List public/private rooms, create/delete public rooms.
- **Messaging** - Send IM/popup through the system account (feature availability depends on server version).
- **Directory** - Category/keyword CRUD and AIM directory entries.
- **BART / Buddy Art** - Type catalog, browse assets, upload/hash/preview/delete, feedbag BART item set/remove, and a built-in info guide.
- **Buddy List / Feedbag** - User-friendly group/buddy management and linked accounts.
- **Audit log** - Local log of admin actions.
- **API Console** - Raw Management API requests for advanced/debug use.
## Requirements
- **PHP 8.1+** with `curl` and `session` extensions enabled.
- A web server capable of running PHP (nginx + PHP-FPM, Apache, Caddy+php-fpm, etc.).
- An **Open OSCAR Server** instance with the **Management API** enabled.
- A system OSCAR account on that server (used to send login codes/messages).
## Quick Start
1. **Clone the repo**
```bash
git clone https://github.com/<your-org>/oscar-admin.git
cd oscar-admin
```
2. **Create config**
```bash
cp config.example.php config.php
```
3. **Edit `config.php`**
- Add allowed admin screen names to `admin_users`.
- Set `system_screen_name` and `system_password` (an existing OSCAR account).
- Set `mgmt_api_host` / `mgmt_api_port` to your private Management API endpoint.
- Optionally enable Gotify (`gotify_enabled => true`).
4. **Serve with PHP**
For local testing:
```bash
php -S 127.0.0.1:8081
```
Open `http://127.0.0.1:8081/login.php`.
For production, use nginx/Apache + PHP-FPM behind HTTPS.
## Configuration
See [`config.example.php`](config.example.php) for all options. Key settings:
| Setting | Purpose |
|---|---|
| `admin_users` | OSCAR screen names allowed to sign in |
| `system_screen_name` / `system_password` | OSCAR account used to send login codes/messages |
| `mgmt_api_host` / `mgmt_api_port` | Private Open OSCAR Management API endpoint |
| `gotify_enabled` | Enables optional Gotify addon |
| `gotify_url` / `gotify_token` | Optional global Gotify fallback (per-user settings preferred) |
| `app_secret` | Optional secret for encrypting sensitive stored values (Gotify tokens) |
| `shared_style_path` | Base CSS path (defaults to bundled `assets/style.css`) |
## Gotify (Optional)
Gotify support is a 100% optional addon (`lib_gotify.php`). The panel works without it.
1. Set `gotify_enabled => true` in `config.php`.
2. Sign in to the admin dashboard.
3. Open the top-right user menu and save your Gotify URL/token.
4. Use **Test** to verify delivery.
If a Gotify URL/token is saved for a user, login codes are sent through Gotify for that user. Clear settings to disable Gotify delivery for that account.
Per-user Gotify settings are stored in `gotify-users.php` (gitignored). Tokens are encrypted at rest; the file is written as PHP with restrictive permissions to reduce accidental exposure. Set `app_secret` in `config.php` for an explicit encryption key.
## Deployment / Hardening
### Keep the Management API private
The OSCAR Management API is powerful. Bind it to `127.0.0.1` or a trusted private network and **do not expose it publicly**.
### Protect sensitive files
Do not serve or commit:
- `config.php` - secrets and config
- `audit.log` - admin action log
- `gotify-users.php` - per-user Gotify tokens/URLs
Example nginx rules (adjust paths to your install):
```nginx
location /admin/ {
# ... php handling ...
location ~* /admin/(config\.php|config\.example\.php|lib\.php|lib_gotify\.php|user-menu\.php|gotify-users\.php|gotify-users\.json|audit\.log|README\.md|\.gitignore)$ {
deny all;
return 404;
}
}
```
Also serve the admin panel over HTTPS and consider an IP allowlist/VPN/auth proxy.
## Project Structure
```text
.
├── action.php # Authenticated JSON action endpoint (dashboard -> Management API)
├── admin.css # Admin-specific styles
├── admin.js # Dashboard client behavior
├── assets/
│ └── style.css # Bundled base stylesheet
├── bart-info.php # BART/Buddy Art help page
├── config.example.php # Configuration template
├── index.php # Dashboard UI
├── lib.php # Shared helpers: config/session/auth/API/audit/page shell
├── lib_gotify.php # Optional Gotify addon
├── login.php # Login flow (math challenge + OSCAR/Gotify OTP)
├── logout.php # CSRF-protected logout
└── user-menu.php # User menu / per-user Gotify settings
```
Runtime files (gitignored): `config.php`, `audit.log`, `gotify-users.php`.
## Security
See [SECURITY.md](SECURITY.md) for vulnerability reporting and deployment guidance.
## AI Disclosure
Parts of this project were created and maintained with assistance from AI coding tools. See [AI_DISCLOSURE.md](AI_DISCLOSURE.md).
## Contributing
Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a PR.
## License
[MIT](LICENSE)