Sovrain
  1. Documentation
  2. Self-hosting

How-to guide

Install Sovrain from a package

Install the .deb or .rpm package, configure /etc/sovrain/sovrain.env, run Sovrain as a systemd service behind your own reverse proxy and create your organization.

This guide installs Sovrain from the .deb or .rpm package of a release and runs it as a systemd service. Your own reverse proxy, such as Caddy, nginx or Traefik, answers HTTPS and passes the requests on to Sovrain. At the end, Sovrain answers at https://auth.example.com and you have created your organization. For a server with Docker, the quickest way is Run Sovrain on your server.

Before you start

You need:

  • Linux on x86_64 or aarch64 with systemd: Debian, Ubuntu, RHEL, Rocky, AlmaLinux, Fedora or openSUSE;
  • a reverse proxy on the same server that serves HTTPS with certificates for the two names below;
  • a domain where you can add DNS records;
  • a mail account that sends over SMTP on port 465 with TLS; see Configure outgoing mail.

Install Sovrain

  1. Download the package and the checksums, check the package and install it. On Debian or Ubuntu on x86_64:

    curl -fsSLO https://releases.sovrain.app/download/1.0.0-rc.1/sovrain_amd64.deb
    curl -fsSLO https://releases.sovrain.app/download/1.0.0-rc.1/SHA256SUMS
    sha256sum --ignore-missing -c SHA256SUMS
    sudo apt install ./sovrain_amd64.deb
    

    On ARM, use sovrain_arm64.deb. On RHEL, Rocky, AlmaLinux or Fedora, download sovrain.x86_64.rpm (sovrain.aarch64.rpm on ARM) and run sudo dnf install ./sovrain.x86_64.rpm; on openSUSE, run sudo zypper install ./sovrain.x86_64.rpm.

sha256sum prints OK after the package name. The package installs /usr/bin/sovrain and the service sovrain, adds the system user sovrain and the data directory /var/lib/sovrain, and creates /etc/sovrain/sovrain.env with a new master key. It does not start Sovrain yet.

Point DNS at the server

Sovrain needs two names: the sign-up address and the address of your organization, one level below it. Choose the organization’s short name now, here acme, and add two A records that point at the server:

auth.example.com        A   203.0.113.10
acme.auth.example.com   A   203.0.113.10

Configure Sovrain

Open the configuration file:

sudoedit /etc/sovrain/sovrain.env

Set IDP_BASE_URL to your sign-up address and the IDP_SMTP_ values to your mail account:

SPRING_PROFILES_ACTIVE=selfhost
IDP_DATABASE_DIRECTORY=/var/lib/sovrain
IDP_BASE_URL=https://auth.example.com
IDP_MEK=<generated by the package>
IDP_CSRF_SECRET=<generated by the package>
IDP_SMTP_HOST=smtp.example.com
IDP_SMTP_USERNAME=sovrain@example.com
IDP_SMTP_PASSWORD=<your mail password>

Leave IDP_MEK and IDP_CSRF_SECRET as the package generated them. IDP_MEK is the master key: Sovrain encrypts every key and secret it stores under it, and the data cannot be read without it.

Start the service

sudo systemctl enable --now sovrain
journalctl -u sovrain -f

Within a few seconds the log contains idp listening on 127.0.0.1:8080, data in /var/lib/sovrain. Sovrain listens only on 127.0.0.1, so it is reachable only from the server itself.

Put your reverse proxy in front

Configure your proxy to serve HTTPS on both names and pass every request to http://127.0.0.1:8080. It must pass the original Host header and set X-Forwarded-For to the client’s address. With Caddy, this is all:

auth.example.com, acme.auth.example.com {
	reverse_proxy 127.0.0.1:8080
}

For nginx and the details: Run the image behind your own proxy.

Create your organization

Open https://auth.example.com/register and create the first organization with the short name from the DNS step, as in Run Sovrain on your server. After that, sign-up closes and more people join by invitation.

Until the first organization exists, anyone who reaches https://auth.example.com/register can create it. Create yours as soon as the proxy works.

Keep a copy of the master key

Copy /etc/sovrain/sovrain.env into your password manager, somewhere other than the server and its backups. Without IDP_MEK, nobody can read the data again, not even from a backup.

The 30-day trial has started. Before it ends, activate a license.

Other situations

If you remove the package

sudo apt remove sovrain (or dnf remove, zypper remove) stops and disables the service and removes the program. It keeps /etc/sovrain/sovrain.env and /var/lib/sovrain, so installing the package again brings your organization back with the same master key. To delete the data for good, remove both yourself.

If you install the package again over an existing configuration

The package creates /etc/sovrain/sovrain.env only when the file is missing. An existing file, with its master key, stays as it is.