-
Notifications
You must be signed in to change notification settings - Fork 236
feat(router): add TLS/mTLS support to gRPC subgraphs #2861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 10 commits
1782dc5
21e77d2
9350004
4456cef
52f76b5
e12803e
e071df4
c20aa5a
87d1647
5ba51b0
eddd247
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ icon: "shield-halved" | |||||
| <Info> | ||||||
| Available since version [0.71.0](https://github.com/wundergraph/cosmo/releases/tag/router%400.71.0) | ||||||
| </Info> | ||||||
| The Cosmo Router supports TLS to secure and authenticate communications for both client and subgraph connections. For subgraph connections, encryption and authentication are automatically enabled when the subgraph URL uses the `https://` protocol. For client connections, you can configure TLS as follow: | ||||||
| The Cosmo Router supports TLS to secure and authenticate communications for both client and subgraph connections. For client connections, you can configure TLS as follow: | ||||||
|
|
||||||
|
|
||||||
| ```yaml config.yaml | ||||||
|
|
@@ -119,6 +119,25 @@ That's it! The router should now be able to receive TLS connections **only** fro | |||||
|
|
||||||
| ## TLS with Subgraphs | ||||||
|
|
||||||
| For subgraph connections, encryption and authentication are automatically enabled when the subgraph URL uses the `https://` protocol. | ||||||
|
|
||||||
| <Note> | ||||||
| These settings do not apply to [Cosmo Connect](/connect/overview) subgraphs. | ||||||
| See [TLS with gRPC Subgraphs](#tls-with-grpc-subgraphs) on how to configure them. | ||||||
| </Note> | ||||||
|
|
||||||
| ### Custom CA Certificates | ||||||
|
|
||||||
| By default, the router uses your operating system's root CA store to verify subgraph server certificates. If your subgraphs use TLS certificates signed by an internal or private CA that is not in the system's root CA store, you can provide a custom CA certificate file using `ca_file`. The router will use this CA to verify the subgraph's server certificate during the TLS handshake. | ||||||
|
|
||||||
| ```yaml config.yaml | ||||||
| tls: | ||||||
| client: | ||||||
| all: | ||||||
| ca_file: /path/to/internal-ca.crt | ||||||
| insecure_skip_ca_verification: false | ||||||
| ``` | ||||||
|
|
||||||
| ### Router mTLS | ||||||
|
|
||||||
| In addition to accepting mTLS connections from clients (inbound), the router can also present client certificates when connecting to subgraphs (outbound). This is useful when your subgraphs require mTLS authentication to accept requests from the router. | ||||||
|
|
@@ -160,18 +179,122 @@ tls: | |||||
| Per-subgraph entries live under `tls.client.subgraphs` and use the same field structure as `tls.client.all` (e.g., `cert_file`, `key_file`). A per-subgraph entry fully overrides the global `all` config for that subgraph. | ||||||
| </Note> | ||||||
|
|
||||||
| <Warning> | ||||||
| `insecure_skip_ca_verification` disables subgraph certificate validation. Only use this for development or testing environments. | ||||||
| </Warning> | ||||||
|
|
||||||
| ## TLS with gRPC Subgraphs | ||||||
|
|
||||||
| gRPC subgraph connections use a separate configuration section from HTTP subgraphs: `tls.client_grpc`. | ||||||
| Unlike HTTP subgraphs, where a `https://` URL automatically enables TLS, gRPC subgraph TLS must be explicitly activated with `enabled: true`. | ||||||
|
|
||||||
| ### Enabling TLS | ||||||
|
|
||||||
| Set `enabled: true` under `tls.client_grpc.all` to enable TLS for all gRPC subgraph connections. By default, the router uses the operating system's root CA store to verify server certificates. | ||||||
|
|
||||||
| ```yaml config.yaml | ||||||
| tls: | ||||||
| client_grpc: | ||||||
| all: | ||||||
| enabled: true | ||||||
| ``` | ||||||
|
|
||||||
| To enable TLS for a specific subgraph only, omit the global `all` config and configure it under `subgraphs`: | ||||||
|
|
||||||
| ```yaml config.yaml | ||||||
| tls: | ||||||
| client_grpc: | ||||||
| subgraphs: | ||||||
| products: | ||||||
| enabled: true | ||||||
| ``` | ||||||
|
|
||||||
| To disable TLS for a specific subgraph while keeping it enabled globally, set `enabled: false` in the per-subgraph entry. Per-subgraph config fully replaces the global `all` config for that subgraph. | ||||||
|
|
||||||
| ```yaml config.yaml | ||||||
| tls: | ||||||
| client_grpc: | ||||||
| all: | ||||||
| enabled: true | ||||||
| subgraphs: | ||||||
| products: | ||||||
| enabled: false | ||||||
| ``` | ||||||
|
|
||||||
| ### Custom CA Certificates | ||||||
|
|
||||||
| By default, the router uses your operating system's root CA store to verify subgraph server certificates. If your subgraphs use TLS certificates signed by an internal or private CA that is not in the system's root CA store, you can provide a custom CA certificate file using `ca_file`. The router will use this CA to verify the subgraph's server certificate during the TLS handshake. | ||||||
| If your gRPC subgraphs use certificates signed by an internal or private CA, provide the CA certificate via `ca_file`: | ||||||
|
|
||||||
| ```yaml config.yaml | ||||||
| tls: | ||||||
| client: | ||||||
| client_grpc: | ||||||
| all: | ||||||
| enabled: true | ||||||
| ca_file: /path/to/internal-ca.crt | ||||||
| insecure_skip_ca_verification: false | ||||||
| ``` | ||||||
|
|
||||||
| `ca_file` can also be set per-subgraph to use a different CA for a specific subgraph: | ||||||
|
|
||||||
| ```yaml config.yaml | ||||||
| tls: | ||||||
| client_grpc: | ||||||
| all: | ||||||
| enabled: true | ||||||
| ca_file: /path/to/internal-ca.crt | ||||||
| subgraphs: | ||||||
| products: | ||||||
| enabled: true | ||||||
| ca_file: /path/to/products-ca.crt | ||||||
| ``` | ||||||
|
|
||||||
| ### mTLS | ||||||
|
|
||||||
| To present a client certificate to gRPC subgraphs (mutual TLS), provide both `cert_file` and `key_file`. Both fields are required together. | ||||||
|
|
||||||
| #### Global Configuration | ||||||
|
|
||||||
| Apply a client certificate to all gRPC subgraph connections: | ||||||
|
|
||||||
| ```yaml config.yaml | ||||||
| tls: | ||||||
| client_grpc: | ||||||
| all: | ||||||
| enabled: true | ||||||
| cert_file: /path/to/client.crt | ||||||
| key_file: /path/to/client.key | ||||||
| ca_file: /path/to/ca.crt | ||||||
| ``` | ||||||
|
|
||||||
| #### Per-Subgraph Configuration | ||||||
|
|
||||||
| Override the global config for specific gRPC subgraphs. A per-subgraph entry fully replaces the global `all` config for that subgraph — it does not merge with it. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace em dash in per-subgraph override note. Use a period or split the sentence. Em dashes are disallowed in docs. Suggested doc fix-Override the global config for specific gRPC subgraphs. A per-subgraph entry fully replaces the global `all` config for that subgraph — it does not merge with it.
+Override the global config for specific gRPC subgraphs. A per-subgraph entry fully replaces the global `all` config for that subgraph. It does not merge with it.As per coding guidelines: "Avoid em dashes. Use periods or restructure the sentence instead." 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| ```yaml config.yaml | ||||||
| tls: | ||||||
| client_grpc: | ||||||
| all: | ||||||
| enabled: true | ||||||
| cert_file: /path/to/default-client.crt | ||||||
| key_file: /path/to/default-client.key | ||||||
| subgraphs: | ||||||
| products: | ||||||
| enabled: true | ||||||
| cert_file: /path/to/products-client.crt | ||||||
| key_file: /path/to/products-client.key | ||||||
| inventory: | ||||||
| enabled: true | ||||||
| cert_file: /path/to/inventory-client.crt | ||||||
| key_file: /path/to/inventory-client.key | ||||||
| ``` | ||||||
|
|
||||||
| <Warning> | ||||||
| `insecure_skip_ca_verification` disables subgraph certificate validation. Only use this for development or testing environments. | ||||||
| `insecure_skip_ca_verification` disables gRPC subgraph certificate validation. Only use this for development or testing environments. | ||||||
| </Warning> | ||||||
|
|
||||||
| ```yaml config.yaml | ||||||
| tls: | ||||||
| client_grpc: | ||||||
| all: | ||||||
| enabled: true | ||||||
| insecure_skip_ca_verification: true | ||||||
| ``` | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix required marker for
tls.client_grpc.all.enabled.This field is shown as required, but the table also states a default of
false. Mark it as optional (square) to avoid implying users must set it explicitly.Suggested doc fix
📝 Committable suggestion
🤖 Prompt for AI Agents