Admin Security
Guides, route-group overviews, and live schema entry points for the Plexichat backend.
Admin security
This guide describes security best practices for Plexichat administrators. Apply these settings to protect admin accounts, enforce access controls, and maintain auditability.
Secure authentication
Bootstrap administrator credentials
On the very first start of a fresh installation, Plexichat creates the
built-in admin account with a randomly generated password. That plaintext
password is shown exactly once, printed to the server console (stdout) at
the moment of generation:
============================================================
PLEXICHAT FIRST BOOT: generated admin credentials
Username: admin
Password: <generated password>
Store this password NOW - it is not shown again and
is not written to disk unless you opted in via
PLEXICHAT_SAVE_ADMIN_CREDENTIALS=1.
============================================================
By design the password is never persisted to disk in plaintext: it exists only in the Argon2id hash inside the database and wherever the operator saved it. It is also never written to log files — logs at most reference the credential file path, never credential contents.
Headless installs that cannot capture console output may explicitly set
PLEXICHAT_SAVE_ADMIN_CREDENTIALS=1 in the environment before first boot to
opt in to a ~/.plexichat/admin_credentials.txt file. The file is written
with mode 0600 via an atomic create-and-replace, and a failed write is
fatal (startup refuses to continue) so the password can never be silently
lost or exposed through a permissive fallback. Delete the file after noting
the credentials.
Whichever way you capture it, change the generated password immediately after first login and enable 2FA when prompted.
Enforce password policies
Configure strong password policies:
admin_ui:
security:
password_policy:
min_length: 12
require_uppercase: true
require_lowercase: true
require_numbers: true
require_special_chars: true
prevent_common_passwords: true
change_interval_days: 90
Require admins to rotate passwords when the policy interval expires, and do not reuse shared accounts. There is no users.force_password_change scope — to force a username change use users.force_username_change; to lock an account or force logout, use admin.security.sessions and admin.security.logout_all.
Require two-factor authentication
Require 2FA for every admin account:
- Require OTP setup on first login.
- Use authenticator apps (avoid SMS when possible).
- Generate and store backup codes securely.
- Rotate OTP secrets periodically.
Manage sessions
Configure secure session settings:
admin_ui:
security:
session:
max_concurrent_sessions: 3
timeout_idle_minutes: 30
session_timeout_minutes: 480
Use admin.security.sessions to force logout (POST /api/v1/admin/security/force-logout) or lock a user (POST /api/v1/admin/security/lock-user), and admin.security.logout_all to invalidate every session (POST /api/v1/admin/security/logout-all). These actions require their respective scopes — do not use a non-existent users.force_password_change scope for session management.
Control access
Restrict hosts
Restrict admin-panel access to specific hosts:
admin_ui:
host_restriction:
enabled: true
allowed_hosts:
- "127.0.0.1"
- "localhost"
- "::1"
- "admin.yourdomain.com"
The server checks allowed_hosts on every admin request. Requests from other hosts are rejected before permission checks.
Block IP addresses
Block suspicious IP addresses:
admin_ui:
blocked_ips:
- "192.0.2.1"
- "198.51.100.0/24"
At runtime, use the IP-block API with admin.security.ipblock:
GET /api/v1/admin/security/blocked-ips— list blocked IPsPOST /api/v1/admin/security/block-ip— block an IPDELETE /api/v1/admin/security/unblock-ip/{ip}— unblock an IP
Limit login attempts
Apply rate limiting to prevent brute-force attacks:
admin_ui:
rate_limit:
max_attempts: 5
window_seconds: 300
lockout_seconds: 900
Harden RBAC
Follow the principle of least privilege
- Assign the minimum permissions needed for each role.
- Prefer specific scopes over broad families. For example, grant
reports.actionto allow reviewing reports rather than a non-existentreports.resolve, and grantusers.force_username_changerather than a non-existentusers.force_password_change. - Remove unused roles and permissions.
Valid scopes are defined in src/core/admin/permissions.py (PERMISSION_SCOPES). Common mistakes include:
| Incorrect (does not exist) | Use instead |
|---|---|
users.force_password_change |
users.force_username_change (force username change) or admin.security.sessions / admin.security.logout_all (force logout or lock) |
servers.ban |
admin.moderation.bans (ban or unban users platform-wide) |
reports.resolve |
reports.action (take action on reports) |
The server returns 400 Invalid or non-delegable permission scope for unknown scopes.
Manage roles securely
- Create roles for specific functions; avoid using the super-admin role for daily work.
- Enforce separation of duties for critical operations (for example, separate the roles that can delete servers and purge users).
- Document the purpose of each role and review assignments regularly.
- Remember hierarchy: you can only manage roles and admins at a lower position than your own highest position. See the RBAC guide.
Audit permissions
Review regularly:
- Who has access to what.
- What each role can do.
- Recent permission changes (query
GET /api/v1/admin/audit/logs? action_family=adminoraction_family=rolewithadmin.audit.read). - Unusual assignments.
The audit log endpoints are GET /api/v1/admin/audit/logs, GET /api/v1/admin/audit/logs/stats, and GET /api/v1/admin/audit/logs/export. The path is /audit/logs, not /audit-log. See src/api/routes/admin/audit.py.
Protect data
Encrypt sensitive data
- Enable database encryption for sensitive fields.
- Use TLS for all admin-panel connections.
- Encrypt backup files and store encryption keys securely.
Log admin actions
Enable comprehensive audit logging for both successful and failed actions.
Review audit logs regularly. Retrieve them with:
curl "/api/v1/admin/audit/logs?page=1&per_page=50" \ -H "Authorization: Bearer <token>"Set up alerting for suspicious activities.
Secure backups
- Encrypt admin database backups and store them in a secure location.
- Test backup restoration regularly.
- Enforce retention policies.
Operate securely
Manage admin accounts
- Use individual admin accounts; never share accounts.
- Disable unused admin accounts promptly.
- Enforce password rotation through policy.
- Revoke access immediately when staff leave.
Keep the system updated
- Keep Plexichat and its dependencies up to date.
- Test updates in staging before production.
- Monitor security advisories.
Monitor activity
- Monitor failed login attempts.
- Alert on suspicious admin activities and unusual permission usage.
- Track system performance metrics.
Respond to incidents
Follow this checklist:
- Identify — Determine scope and impact.
- Contain — Limit further damage.
- Eradicate — Remove the threat.
- Recover — Restore normal operations.
- Learn — Document findings and improve controls.
Compromised admin account
- Disable the account immediately.
- Force logout of affected sessions (
admin.security.sessionsoradmin.security.logout_all). - Review audit logs at
GET /api/v1/admin/audit/logsfor suspicious activity. - Rotate secrets and keys.
- Notify affected users if necessary.
Unauthorized access attempt
- Block offending IP addresses (
admin.security.ipblock). - Review audit logs for patterns.
- Apply additional rate limiting.
- Consider enabling CAPTCHA.
- Monitor for continued attempts.
Data breach
- Identify compromised data and assess scope.
- Notify affected parties.
- Apply additional security measures.
- Review and improve security practices.
Meet compliance requirements
GDPR
- Minimize data collection.
- Support the right to be forgotten.
- Maintain audit trails.
- Follow data-breach notification procedures.
SOC 2
- Document security procedures.
- Enforce access controls.
- Enable comprehensive logging.
- Run regular security assessments.
HIPAA
- Enable access logging.
- Encrypt data at rest and in transit.
- Maintain business-associate agreements.
- Provide regular security training.
Follow the security checklist
Daily
- Review failed login attempts.
- Check for unusual admin activity.
- Verify system performance.
Weekly
- Review audit logs (
GET /api/v1/admin/audit/logs). - Check for security updates.
- Verify backup integrity.
- Review role assignments.
Monthly
- Run a security assessment.
- Review access.
- Check password-rotation compliance.
- Verify compliance status.
Quarterly
- Run a full security audit.
- Perform penetration testing.
- Provide security training.
- Review policies.
Related resources
- OWASP Security Guidelines
- NIST Cybersecurity Framework
- CIS Controls
- RBAC guide — permission scopes and hierarchy
- Operations guide — daily and weekly security tasks