Replace an authentication proxy

An internal application with no login of its own is usually protected by an authentication proxy in front of it: oauth2-proxy, Pomerium, or a forward-auth rule in nginx (auth_request) or Traefik (ForwardAuth) calling one. The proxy signs the person in against an identity provider and passes their name to the application in a header.

Meerkat does the same job, and keeps the parts that usually sit around the proxy in the same place: the accounts and their roles, the access rule of each application, the routing, the rate limits and the audit trail.

What maps to what

In front of the application today In Meerkat
One proxy, or one forward-auth rule, per application One route per application, all on one gateway
The identity provider the proxy delegates to The same provider, through OpenID Connect; or local accounts, GitHub, and in Enterprise LDAP and SAML
Allowed e-mail domains, allowed groups The route's access rule: signed in, a role, a list of people
The header that carries the user name Identity on the route: each fact under the header name the application already reads
A token the application verifies A signed JWT, checked against the gateway's published keys
Rules per path Per-endpoint rules, read from the application's OpenAPI description

The headers Meerkat sets are removed from the incoming request first: a caller cannot forge them through the gateway.

Before and after

A typical oauth2-proxy in front of a billing application: people sign in at the company's OpenID provider, only addresses of the company's domain and members of the ops group pass, and the application reads the user from two headers.

oauth2-proxy \
  --provider=oidc \
  --oidc-issuer-url=https://login.acme.example \
  --email-domain=acme.example \
  --allowed-group=ops \
  --upstream=http://billing:8080 \
  --pass-user-headers=true

The upstream reads X-Forwarded-User and X-Forwarded-Email. The same in Meerkat, on one route named billing:

oauth2-proxy Meerkat
--provider=oidc, --oidc-issuer-url The same provider, declared once under Infra, Authentication for every application
--email-domain=acme.example Only the people your provider signs in have an account at all
--allowed-group=ops Security, Who may call it: the role ops (granted in Meerkat, or in Enterprise by a group rule from the provider's groups)
--upstream=http://billing:8080 Target http://billing:8080, and a path predicate /billing/**
X-Forwarded-User, X-Forwarded-Email Identity: username as X-Forwarded-User, email as X-Forwarded-Email; Auth forward: mechanism Headers

The application does not change: it reads the same two headers.

The steps

1. Run Meerkat beside the current proxy

The quick start has it running in a few minutes, with Docker, Compose, Swarm or Helm.

2. Connect the accounts

Declare the identity provider the proxy uses today under Infra, Authentication, or create local accounts. People sign in on Meerkat's own pages, in your colours. See OpenID Connect.

3. Add a route for the application

Infra, Routes, New route: a path or host predicate, and the application's internal address as the target. See your first route.

4. Say who may pass

In the route's Security section, Who may call it: signed in, or a role.

The route editor on the Security section: who may call the route, the roles that grant access, and the users always allowed

5. Hand over the identity

In Identity, give each fact the header name the application reads now, and choose the Headers mechanism under Auth forward; or send a signed JWT. Connecting an application has recipes for Grafana, GeoServer and others.

A route's Identity section: each fact ticked is sent under the header name the application already reads, X-WEBAUTH-USER, X-WEBAUTH-NAME, X-WEBAUTH-EMAIL and X-WEBAUTH-ROLE, with the value a sample caller gets

6. Check it before moving anything

Call the route through Meerkat's data plane, without signing in:

curl -i http://localhost:8080/billing/

It is refused, which proves the route takes the request and its rule holds:

HTTP/1.1 401 Unauthorized
Www-Authenticate: Session

authentication required

Open the same address in a browser: Meerkat's sign-in page comes first, then the application, which names the person signed in. Routing test, on Infra, Routes, shows which route takes a request and why. To see the exact headers the application receives, point a temporary route at an echo service such as go-httpbin, whose /headers answers what it was sent.

7. Move the traffic

Point the application's public address at Meerkat's data plane, and leave the application reachable only through the gateway.

8. Remove the old proxy

Once the traffic has moved and the application answers through Meerkat only.

A header is trusted because nobody else can set it. Keep the application off any other path - no published port, no ingress of its own - or anyone who reaches it directly can send the header themselves.

What changes for the application

Nothing, when it reads the same headers as before. What changes is around it: its access rule, its roles and its traffic are on the console with every other application's, and every change to them is in the audit trail.

See the editions for what the free image includes.