Abderrahman Khalladi
← All articles

DevOps · · 3 min read

Two apps, two VPS, one sign-in: pipelines and SSO between Orbit and VM Manager

How an Orbit user opens VM Manager without going through a sign-in screen again, and how both applications ship to production.

EO Orbit and EO VM Manager are two separate applications. Orbit is the operations portal, written in NestJS. VM Manager drives the hypervisors, written in FastAPI. They run on two different VPS hosts, each with its own database and release cycle.

Users weren’t supposed to notice. Someone signed in to Orbit should be able to open VM Manager with the same permissions, without typing a password again. And both applications had to ship to production without stepping on each other.

The same pipeline for both projects

Both repositories follow the same GitLab CI layout:

  1. test: lint and unit tests on every push.
  2. build: a Docker image tagged with the commit SHA, pushed to the GitLab registry.
  3. deploy-preprod: automatic on the main branch.
  4. deploy-prod: a manual job, triggered after checking pre-production.

The deployment itself is deliberately simple. The job connects over SSH to the VPS as a dedicated user that only has Docker rights, updates the image tag, then runs docker compose pull and docker compose up -d. It then waits for the application’s health endpoint to answer. If it doesn’t, the job fails and the previous tag is put back.

The VPS hosts are with providers such as OVHcloud. Each one gets the same preparation: SSH with keys only, a firewall that only opens SSH, HTTP and HTTPS, Docker, and Nginx as a reverse proxy with Let’s Encrypt certificates renewed automatically. Secrets (keys, database passwords, API tokens) are protected GitLab variables injected at deploy time and never written to the repository.

Having one pipeline for two different stacks has a simple benefit: when something breaks, you know where to look.

Single sign-on

Orbit already authenticates its users, with a JWT and two-factor authentication. Rather than install a full identity provider for two applications, we built a signed hand-off.

How it works:

  1. In Orbit, the user clicks “Infrastructure”.
  2. Orbit’s back end creates a very short hand-off token (one minute) signed with its private key. It holds the user id, their tenant, their roles, an aud of vm-manager and a unique jti.
  3. The browser is redirected to VM Manager’s SSO endpoint with that token.
  4. VM Manager checks the signature with Orbit’s public key, then the issuer, audience and expiry.
  5. It checks that the jti has never been used by writing it to Redis with the token’s lifetime. An intercepted token can’t be replayed.
  6. It finds the matching local user, or creates it on the first visit, opens its own session and redirects to the dashboard with the token removed from the address.
claims = jwt.decode(token, ORBIT_PUBLIC_KEY, algorithms=["RS256"],
                    audience="vm-manager", issuer="eo-orbit")
if not redis.set(f"sso:jti:{claims['jti']}", 1, nx=True, ex=120):
    raise HTTPException(401, "token already used")
user = users.get_or_create_from_orbit(claims)
return start_session(user)

Each application then keeps its own session. Signing out of one doesn’t sign you out of the other, which is acceptable here since VM Manager sessions are short.

The traps we hit

  • Server clocks. With a one-minute token, two VPS hosts whose clocks drift by a few tens of seconds are enough to break everything. NTP on both machines, and a few seconds of tolerance when verifying.
  • Logs. A token passed in the URL ends up in Nginx access logs. On the SSO route, the log format doesn’t write the query string.
  • Roles. VM Manager doesn’t blindly trust the roles it receives: it maps them to its own permissions, and an unknown role grants nothing.

Where it leaves us

The signed hand-off gave us single sign-on without one more server to run. If a third application joins, that will be the right moment to move to a real OpenID Connect provider. For two applications, this mechanism stays easy to understand, test and explain.

Next article Tartib 2.0: why a modular monolith, and how it is structured →