Repository navigation
Security
By default, Cloud Streams does not authenticate requests and relies on the infrastructure (e.g. an ingress) to do so. The dashboard and the event ingestion endpoint (POST /api/events/pub) can each be secured independently at the application level. For example, publishers can stay anonymous while users must sign in to the dashboard:
Authentication:
Oidc:
Authority: https://keycloak.example.com/realms/cloud-streams
MetadataAddress: ... # optional: where to fetch the discovery document, when the application reaches the authority at another address than users
ClientId: cloud-streams-dashboard
ClientSecret: ... # optional, for confidential clients; PKCE is always used
Audience: cloud-streams # strongly recommended: the audience bearer tokens must have been issued for
RequireAudience: true # refuse to start without an audience; otherwise, a warning is logged
Scopes: [ openid, profile ]
NameClaimType: preferred_username
RoleClaimType: roles
Dashboard:
Enabled: true # users sign in with OIDC; the management API, hubs and MCP endpoint also accept bearer tokens
Roles: # optional: without any role, every signed-in user is an administrator
Readers: [ cloud-streams-reader ]
Operators: [ cloud-streams-operator ]
Admins: [ cloud-streams-admin ]
Ingestion:
Enabled: false # when true, publishers must present a bearer token or an API key
ApiKeys: [ ] # keys that may publish events of any source
Publishers: # keys bound to the sources they may publish events of
- Name: orders
ApiKey: ...
Sources: [ 'https://orders.example.com/*' ]
SourceClaimType: ~ # optionally, the claim that lists the sources a bearer token may publish events of
ApiKeyHeader: X-Api-KeyAs with any ASP.NET Core setting, these can be supplied as environment variables, e.g. Authentication__Dashboard__Enabled=true. When the dashboard is secured, its session cookie is encrypted with keys stored in Redis, so that every gateway replica can read it. The OIDC client must allow {gateway}/signin-oidc as a redirect URI and {gateway}/signout-callback-oidc as a post-logout redirect URI. Signing out requires a POST to auth/logout.
Roles are read from the claim named by Oidc:RoleClaimType, and each one includes the ones above it:
| Role | May |
|---|---|
| Reader | get, list and watch resources, read the stream and partitions, export subscriptions and use the read-only MCP tools |
| Operator | also suspend, resume and replay subscriptions, skip the event that faulted them, and redeliver their dead letters, with POST /api/resources/v1/namespaces/{namespace}/subscriptions/{name}/suspend, .../resume, .../replay, .../skip and .../dead-letters/{offset}/redeliver
|
| Admin | also create, replace, patch and delete resources, and patch their status |
A user who has none of the configured roles is denied access (403). When no role is configured, every signed-in user is an administrator, as before. The dashboard hides the actions the user may not perform. Acknowledgement endpoints remain anonymous, as the token is their authorization.
By default, any authenticated publisher may publish events of any source. A publisher can instead be bound to the sources it may publish events of:
-
API keys: a key listed under
Publishersmay only publish events whose source matches one of itsSources. Keys listed underApiKeysstay unrestricted, for example for a subscription that bridges another Cloud Streams instance. -
Bearer tokens: when
SourceClaimTypeis set, a token may only publish events whose source matches one of the patterns the claim lists, as an array or a space-separated string. A token without the claim may publish none.
A pattern must match the whole source, case-sensitively. * matches any sequence of characters: https://orders.example.com/* matches https://orders.example.com/eu, but not https://orders.example.com.evil.net. An event whose source is not allowed is rejected with 403 Forbidden, problem type https://cloud-streams.io/problems/source-not-allowed, and counted as rejected for authorization.
Behind a reverse proxy that terminates TLS, the X-Forwarded-For and X-Forwarded-Proto headers must be honoured, so that cookies are marked Secure and redirect URIs use https. They are only trusted when sent by a known proxy: loopback by default, otherwise the addresses and CIDR ranges configured below:
ForwardedHeaders:
KnownProxies: [ 10.0.0.12 ]
KnownNetworks: [ 10.244.0.0/16 ]
TrustAllProxies: false # only when the application cannot be reached without going through a proxyGateways serve two endpoints:
- Public: event ingestion, acknowledgements and health checks.
- Management: the management API, i.e. resources, hubs, MCP and the dashboard.
On Kubernetes, the gateways the operator deploys and those the chart deploys serve the management endpoint on a port of its own, never on the public one. Exposing the public endpoint thus never exposes the management one. Each endpoint is exposed by a Gateway API HTTPRoute, by an ingress, by both, or only through the gateway's service. A gateway resource's spec.workload.endpoints:
spec:
workload:
endpoints:
public:
httpRoute:
parentRefs: [ { name: public, namespace: infra } ] # a Kubernetes Gateway of the cluster
hostnames: [ events.example.com ]
management:
enabled: true # false by default
port: 8081 # the operator's 'operator.workloads.gateway.managementPort' by default
ingress:
className: internal
hosts: [ streams.internal.example.com ]
tlsSecretName: streams-internal-tls-
HTTPRoutes: the operator creates the route,
gateway.networking.k8s.io/v1, and never the Kubernetes Gateway it attaches to, which belongs to the cluster's gateway controller. On a cluster without the Gateway API, a gateway that asks for a route isDegraded, with the reason. -
Ingresses: their annotations are set by the operator's configuration only,
operator.workloads.gateway.ingressAnnotations, since some ingress controllers read configuration snippets from them. -
Names: the objects of the public endpoint are named after the workload, e.g.
orders-gateway, and those of the management endpointorders-gateway-management. -
The chart:
gateway.endpointstakes the same shape for the gateways it deploys, in Redis mode, and for the API, in Kubernetes mode. Its ingresses are described by hosts and paths, and its routes and ingresses may carry annotations.
Outside Kubernetes, the management API is kept off the public network in the same way, by serving it on a dedicated port that is not exposed, or by disabling it on ingestion-only replicas:
ManagementApi:
Enabled: true # false on ingestion-only replicas
Port: 8081 # serve the management API on this port only; listen on it too, e.g. ASPNETCORE_HTTP_PORTS=8080;8081At startup, a SECURITY warning is logged whenever the management API is served without authentication, bearer tokens are accepted without audience validation, or forwarded headers are trusted from any client.
The requests Cloud Streams sends on behalf of resources (deliveries to subscribers, mutation webhooks and health checks) are subject to an outbound policy. By default, it only denies link-local addresses, which include cloud providers' metadata services:
OutboundRequests:
AllowedHosts: [ '*.svc.cluster.local', subscriber.example.com ] # any host if empty
DeniedNetworks: [ 10.10.0.0/16 ]
DenyLinkLocal: true
DenyPrivateNetworks: false