Atlax replaces WHMCS for a Tunisian hosting company: domains, cPanel hosting, SSL, Microsoft 365, billing and support. Unlike Tartib, this project is built as microservices, for a good reason: it depends on slow external providers that aren’t always up (the ATI registry, ResellerClub, cPanel/WHM, payment providers). A registrar outage must not stop someone paying an invoice.
More services means more surface to protect. These are the choices we made, and why.
The platform: config server, Eureka and gateway
Three technical services carry the others:
- config-server centralises each service’s configuration. Secrets aren’t written in it in clear text: they come from the environment, and in production from Docker secrets.
- discovery-server (Eureka) keeps the list of instances. The gateway routes to
lb://billing-servicewithout knowing any IP address. - gateway is the only public entry point. No business service is exposed directly.
Business services are split by responsibility, not by screen: auth, commerce, billing, domain, hosting, notification, reporting. ATI and ResellerClub are two adapters inside the same domain service, since they do the same job.
Tokens stay on the server
The client area and the back office are two React applications. They could have run the OAuth2 flow themselves and kept tokens in the browser. We didn’t: a script injected through an XSS hole could read them.
So the gateway acts as a backend-for-frontend. It’s a confidential OAuth2 client of the authentication service, with one registration per application (atlax-web for customers, atlax-back-office for staff). It runs the authorization code flow with PKCE, keeps the tokens in a session stored in Redis, and only gives the browser an HttpOnly, SameSite=Lax session cookie. Each application has its own cookie, so signing in to the back office gives nothing on the client side, and the other way round.
When the browser calls the API, the gateway’s TokenRelay filter adds the access token to the request sent to the service and refreshes it when needed. The services validate JWTs as resource servers and enforce their own permissions.
An authentication service we understand
We ruled out Keycloak and built auth-service on Spring Authorization Server. The team wanted to understand and own this part, and to keep its own sign-in pages. A few details that matter:
- The sign-in form lives in React. The authentication service renders no HTML: it redirects to the sign-in page of the application that asked. The page fetches a CSRF token, then posts a plain form to the service.
- A wrong password says nothing about the account. An account’s state (unverified e-mail, locked, disabled) is only reported after a correct password.
- The signing key is a PEM file, read at startup from a Docker secret. The service refuses to start if the key is missing or shorter than 2048 bits. Its
kidis its RFC 7638 thumbprint. During a rotation the old key stays published in/oauth2/jwkswithout signing anything, so tokens already issued stay valid until they expire. - OAuth2 client secrets are stored hashed, and refresh tokens rotate on every use.
The other layers
- reCAPTCHA v3 on public forms (contact, quote request). Verification requires the expected action, a minimum score and an allowed host name. If Google doesn’t answer, the form is refused: we fail closed.
- One PostgreSQL database and user per service. A compromised service can’t read the others’ tables.
- Errors as codes. Front ends translate the codes; the technical detail in English is never shown, which avoids saying too much about the system’s internals.
- Kafka with outbox and inbox. Not security in the strict sense, but an order isn’t lost when a service goes down, and a message delivered twice is only processed once.
What it costs
None of this is free. We had to write what Keycloak gives you out of the box: sign-up, e-mail verification, password reset, brute-force protection, MFA for staff. Key rotation is manual. And there are more processes to run than with a monolith.
But every decision is written down in an ADR, with what was ruled out and why. When someone joins the project, they don’t have to guess why the tokens aren’t in localStorage.