Skip to content
Get started
Bastionary › Knowledge base › Operations and self-hosting

Self-hosting your auth: a deployment checklist

By Bastionary · Operations and self-hosting

Self-hosting authentication gives you control over identity data, but it also makes you responsible for uptime, security patches, backups, and audit evidence. This guide walks through the decisions and concrete tasks you need to complete before running Bastionary in production.

Decide whether self-hosting auth fits your team

Before provisioning servers, be honest about the operational cost. Self-hosting is not just a deployment choice; it is a long-term control decision. The work includes patching, certificate renewal, incident response, and explaining the architecture to auditors and enterprise customers.

Use this checklist to decide whether your team is ready:

  • You have an engineer who can own identity, TLS, database, and incident response.
  • Your customers or regulators require identity data to stay inside your network.
  • You can accept responsibility for patches, backups, and key rotation.
  • You have a tested rollback strategy for failed upgrades.
  • You can provide the observability and audit trails that enterprise customers expect.
  • You understand the total cost of ownership, including time spent on maintenance and compliance.

If these are not true yet, delay self-hosting until the team is ready. A partially maintained auth system is more dangerous than no auth system at all.

Prepare the base infrastructure

Bastionary needs a stateful backend and a trusted network path to users. Start with these minimums:

  • A Linux host or container runtime with at least 2 vCPU, 4 GiB RAM, and 20 GiB disk.
  • A PostgreSQL database with automated daily backups and point-in-time recovery enabled.
  • Redis or another supported cache and state store for sessions and rate limiting.
  • A public hostname and valid TLS certificate from a trusted certificate authority.
  • A private network segment that isolates the database from the public internet.

Place the application servers in a separate subnet from the database and restrict access with security groups or firewall rules. Automate certificate renewal so a lapsed certificate does not lock users out.

Generate a strong signing secret and store it in a secret manager or environment file:

openssl rand -hex 32

Never commit secrets to Git. Load them at runtime from a vault, Docker secrets, or systemd credentials. A basic Docker Compose stack might look like this:

services:
  app:
    image: bastionary/bastionary:latest
    environment:
      DATABASE_URL: postgres://app:${DB_PASSWORD}@db:5432/bastionary
      REDIS_URL: redis://redis:6379
      BASTIONARY_SIGNING_KEY: <hex-from-openssl>
      BASTIONARY_PUBLIC_URL: https://auth.example.com
    ports:
      - "3000:3000"
  db:
    image: postgres:16
    volumes:
      - pgdata:/var/lib/postgresql/data
  redis:
    image: redis:7

Run this stack in staging first and verify that migrations complete before exposing it to users.

Harden the deployment

Authentication is a high-value target. Treat the control plane like any other sensitive infrastructure:

  • Run the service behind a reverse proxy that terminates TLS and enforces modern cipher suites.
  • Block public access to the database and admin ports with firewall rules.
  • Enable request logging, structured audit logging, and centralized log forwarding.
  • Use separate credential sets for application, database, and backup operations.
  • Pin container images by digest and scan them for known vulnerabilities.
  • Rate-limit login, registration, and password reset endpoints to slow down credential stuffing.

Secrets and key management

Store signing keys and database passwords in a secrets manager with access controls. Set file permissions on environment files to 0600 and load them through a process manager that does not leak values to child shells. Rotate the signing key at least once per year and test the rotation in staging first.

Set environment variables such as these before starting the service:

DATABASE_URL=postgres://app:${DB_PASSWORD}@db:5432/bastionary
REDIS_URL=redis://redis:6379
BASTIONARY_SIGNING_KEY=<hex-from-openssl>
BASTIONARY_PUBLIC_URL=https://auth.example.com

Restart the service only after verifying every variable is loaded and the database is reachable.

Operate and maintain the deployment

Owning auth means owning evidence. Build operational runbooks before launch:

  • Backup frequency, retention window, and restore drill schedule.
  • Patch cadence and a maintenance window communicated to users.
  • Key rotation procedure for signing secrets and database credentials.
  • Incident response steps for credential leaks or suspicious login patterns.
  • Audit export format that satisfies your customers and auditors.
  • Escalation path for an authentication outage, including a way to disable features without losing data.

Document the shared responsibility boundary. You control the host, network, database, and application configuration. Bastionary provides the protocol logic and session model, but you are responsible for the environment it runs in.

Encrypt backups at rest and keep a copy in a separate location from the production database. Test decryption during restore drills so you do not discover a missing key during an outage.

Monitor the metrics that matter: login success and failure rates, session revocation latency, certificate expiration, backup age, and patch lag. Alert on anything that could prevent users from signing in or could hide a security event. After every incident, update the runbook so the same failure is easier to detect next time.

Next steps

  • Run Bastionary in a staging environment with a replica of your production identity provider and database.
  • Perform a restore drill from your backup before going live.
  • Review the security and audit logging configuration with your team.
  • Deploy to production behind a TLS-enabled reverse proxy.

Run it yourself

Bastionary is free, open-source software. Follow the quick start to have it running on your own server, or browse the releases on Git.

Get started