Twingate Gateway
How the Twingate Gateway authenticates users, secures connections, and where it runs.
The Twingate Gateway is the open-source Layer 7 reverse proxy behind every Privileged Access Management Resource. It sits between protocol clients (kubectl, ssh, a web browser) and the upstream service, authenticates the Twingate user, and signs in to the upstream service on the user’s behalf.
This page covers behavior shared by all protocols. For protocol-specific setup, see Privileged Access for Kubernetes, Privileged Access for SSH, and Privileged Access for Web Apps.
Connection flow
A Privileged Access Management Resource has two addresses:
- Address: The upstream service, as reached by the Gateway. For example, a Kubernetes API server at
10.0.0.1. - Gateway address: The Gateway, as reached by the Connector. For example,
gateway.int. With the Twingate Operator, it is resolved from the Gateway’sService: the load balancer address for aLoadBalancerservice, otherwise its in-cluster DNS name. From Gateway 2.1, settwingateOperator.gateway.addresswhen Connectors reach the Gateway another way.
Each connection follows these steps:
- The protocol client opens a TCP connection to the Resource address. The Twingate Client carries it through the encrypted tunnel to the Connector.
- The Connector sees that the Resource has a Gateway and forwards the connection to the Gateway address instead of the Resource address.
- The Twingate Client opens a TLS connection to the Gateway (the outer TLS layer).
- The Twingate Client sends an HTTP
CONNECTrequest carrying a Gateway Access Token (GAT). The Gateway validates the token. - Depending on the protocol, the protocol client opens an inner secure layer with the Gateway inside the same TCP connection, such as TLS for HTTPS or the SSH protocol for SSH.
- The Gateway forwards each request to the upstream service and returns the response.
Authentication
The Twingate Controller issues the Gateway Access Token after the user satisfies every Security Policy on the Resource, including MFA, device trust, location, and just-in-time access. The token is a signed JWT scoped to the user, device, and Resource.
After the Gateway validates the token, it authenticates to the upstream service for the user:
| Protocol | How the Gateway authenticates upstream |
|---|---|
| Kubernetes | A Kubernetes service account token, with the user’s identity sent as impersonation headers |
| SSH | A short-lived SSH certificate signed by an SSH certificate authority |
| Web App | Identity headers injected into each HTTP request, such as the signed token itself |
The user’s device holds no credential for the upstream service.
Connection security
The Gateway terminates the outer TLS connection from the Twingate Client. The Client validates the Gateway’s certificate against the X.509 certificate authority registered with the Gateway, and against the hostname it dials. The certificate must therefore cover each Resource address and alias the Gateway serves.
When the protocol has an inner secure layer, the protocol client verifies the Gateway with trust material that the Twingate Client syncs to the device:
| Protocol | Synced configuration |
|---|---|
| Kubernetes | ~/.kube/config with a context and CA certificate for each cluster |
| SSH | ~/.ssh/known_hosts with the Gateway’s SSH host CA |
| Web App | None |
The synced configuration contains no tokens, private keys, or passwords.
Deployment
The Gateway runs in your environment, either in a Kubernetes cluster (with the Twingate Kubernetes Operator or the Gateway Helm chart) or on a VM as a Docker container or release binary.
Each Gateway belongs to a Remote Network, and a single Gateway can serve multiple Resources in that Remote Network. Every Connector in the Remote Network must be able to reach the Gateway address, because any of them can carry a connection.
The Gateway’s only outbound connection to Twingate is fetching the public keys it uses to verify Gateway Access Tokens. Audit logs and session recordings stay in your environment.
Operating the Gateway
- Gateway TLS Certificates: Static, cert-manager, and on-demand certificates.
- Session Recordings: Recording format and how to ship recordings to storage.
- Gateway Monitoring: Prometheus metrics, alerting, and a Grafana dashboard.
- Upgrading the Gateway: Breaking changes between major Gateway versions.
Last updated