Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.custom.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3018,7 +3018,7 @@ JWKS_INCLUSTER := $(JWKS_BASE) --set global.identity.issuerUrl=https://dex.ci.ex
# Nothing external at all: the platform's issuer in-cluster too (giantswarm/agent-platform#505
# admits global.identity.issuerUrl's host from the controller policy, so a public issuer is an
# external target whatever the routes name). This is the shape held against GOLDEN_REF.
JWKS_ISSUER_INCLUSTER := $(JWKS_BASE) --set global.identity.issuerUrl=https://dex.giantswarm.svc.cluster.local:5556 --set gateway.jwksEgress.enabled=true
JWKS_ISSUER_INCLUSTER := $(JWKS_BASE) --set global.identity.issuerUrl=https://dex.giantswarm.svc.cluster.local:5556 --set gateway.jwksEgress.enabled=true --set 'networkPolicy.identityProvider.inClusterPeers[0].namespace=giantswarm' --set 'networkPolicy.identityProvider.inClusterPeers[0].matchLabels.app=dex' --set 'networkPolicy.identityProvider.inClusterPeers[0].ports[0]=5556'
# The platform's release beside a serving slice: the controller on, no route with a JWT policy
# of its own (kagent off), a public issuer. The slice's models policy in another namespace
# takes that issuer on 443, and only this release's policy governs the controller.
Expand Down
41 changes: 40 additions & 1 deletion docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,48 @@ POST https://models.<domain>/<namespace>/<model>/v1/chat/completions
Authorization: Bearer <id_token>
```

## Shared encryption key

The platform enables `muster.muster.oauth.server.encryptionKey` by default.
Muster uses the existing `oauth-encryption-key` entry in its OAuth Secret for
token encryption and derives its request-state sealing key with HKDF. The lab
provisioner generates this root key once and preserves it. Other installations
provide it alongside the platform's OAuth credentials. There is one stored key
and no separate request-state key setting.

Keep the same Secret and key across replicas and upgrades. Existing encrypted
stores retain their format. Explicit `encryptionKey: false` remains supported
with one replica; multiple replicas require the shared key. The no-OAuth kind
example uses that single-replica configuration. An existing plaintext store
requires a storage migration before enabling encryption. Disabling encryption
does not decrypt existing records; changing storage mode requires a migration.

## OAuth issuer connectivity

The agent-manager, vm-manager, cluster-manager, skill-manager and workspace-manager defaults set `oauth.dex.allowPrivateURLs: false`. The model-manager block does not set `oauth.dex.allowPrivateURLs`, and the mcp-kubernetes block does not set `mcpKubernetes.oauth.allowPrivateURLs`: neither value has an effect. Their Dex discovery client can reach an operator-configured issuer that resolves to a private address without this opt-in and follows `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY`. An issuer discovery failure calls for checking DNS, egress, proxy settings and certificate trust, rather than asking the person to sign in again. Keep HTTPS, certificate verification and the exact configured issuer identity intact; configure the installation's internal CA through `global.identity.ca.secretName` when needed.
Manager trusted-issuer discovery and JWKS egress uses the endpoint's URL port.
An in-cluster Service selects only that Service's backends through Cilium
`toServices`, rather than every Pod in its namespace. Cilium checks ports after
Service translation. When a Service port maps to a different backend port, set
the backend ports and Pod selector in
`networkPolicy.identityProvider.inClusterPeers`; these settings also apply to
additional trusted issuer Services. An explicit empty list disables the
in-cluster legs.

The Kubernetes NetworkPolicy flavor opens the additional public URL ports, with
the configured public-address exclusions. It cannot select a Service by name:
for an in-cluster issuer, provide its namespace and target ports in
`networkPolicy.identityProvider.inClusterPeers`. Set `matchLabels` to restrict
the peer to its backend Pods; omitting it permits every Pod in that namespace
on those ports. Missing peer information fails rendering.

With a manager's authorization server disabled, configure
`oauth.resourceServer.trustedIssuers` and `authorizationServers`. That mode
does not require an upstream OAuth client ID or client secret.
`oauth.authorizationServer.issuer` still supplies mcp-oauth's public base URL
for resource metadata in this mode. The advertised authorization servers come
from `resourceServer.authorizationServers`.

The agent-manager, vm-manager, skill-manager and workspace-manager defaults set `oauth.dex.allowPrivateURLs: false`. The model-manager and cluster-manager blocks do not set `oauth.dex.allowPrivateURLs`, and the mcp-kubernetes block does not set `mcpKubernetes.oauth.allowPrivateURLs`: neither value has an effect. Their Dex discovery client can reach an operator-configured issuer that resolves to a private address without this opt-in and follows `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY`. An issuer discovery failure calls for checking DNS, egress, proxy settings and certificate trust, rather than asking the person to sign in again. Keep HTTPS, certificate verification and the exact configured issuer identity intact; configure the installation's internal CA through `global.identity.ca.secretName` when needed.

When a manager refuses `--allow-private-oauth-urls=true` or its chart value `oauth.dex.allowPrivateURLs: true`, remove the old opt-in or set the chart value to `false`. The platform defaults already use `false`. workspace-manager needs 0.15.9 or later and mcp-kubernetes 1.14.26 or later for that: their earlier releases still need the opt-in to reach a private issuer. The component ranges require builds on mcp-oauth v1.15.0 or later. The managers and mcp-kubernetes also fetch their own Dex's key set from a private address without a setting, to validate forwarded ID tokens, so the platform no longer sets `oauth.sso.allowPrivateIPs`. That setting is deprecated: it lifts the check for every key set host and logs a warning. Do not set it to repair discovery or a certificate error.

Expand Down
5 changes: 1 addition & 4 deletions helm/agent-platform-connectivity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ The kagent block is open in the schema, so the template refuses a key under `kag
| networkPolicy.additionalEgressCIDRs | list | `[]` | |
| networkPolicy.additionalEgressFQDNs | list | `[]` | |
| networkPolicy.envoyGateway.proxyNamespace | string | `"envoy-gateway-system"` | Where Envoy Gateway runs the Gateways' proxy pods. The default is the controller's namespace of Envoy Gateway's default deploy mode (ControllerNamespace); change it when Envoy Gateway runs in another namespace, and set it empty when it runs in the GatewayNamespace mode, which puts each proxy in its Gateway's own namespace. |
| networkPolicy.identityProvider.inClusterPeers | string | `nil` | The in-cluster peers of the identity provider egress, each a namespace, optional pod labels (matchLabels) and its ports. Unset (null), the chart derives them: the proxy pods of the public Gateway muster's route attaches to (ingress.parentRefs, else the chart-owned edge, else global.gatewayApi.parentRefs) on 443 and 10443, and, for an issuer host <service>.<namespace>.svc[.cluster.local], that namespace on the URL's port. A list replaces the derived peers; [] renders no in-cluster leg. |
| networkPolicy.identityProvider.inClusterPeers | string | `nil` | The in-cluster peers of the identity provider egress, each a namespace, optional pod labels (matchLabels) and its ports. Unset (null), the chart derives them: the proxy pods of the public Gateway muster's route attaches to (ingress.parentRefs, else the chart-owned edge, else global.gatewayApi.parentRefs) on 443 and 10443, and, for an issuer host <service>.<namespace>.svc[.cluster.local], only that Service's backends on the URL's port. This also supplies backend ports for additional trusted issuer Services: set the target ports when a Service translates them. A list replaces derived peers; [] renders no in-cluster leg. |
| networkPolicy.substrate.credentialProvider.egressFQDNs | list | `[]` | |
| networkPolicy.substrate.egressGateway.privateCIDRs | list | `[]` | |
| networkPolicy.musterInClusterMcpPorts[0] | int | `8080` | |
Expand Down Expand Up @@ -1711,7 +1711,6 @@ The kagent block is open in the schema, so the template refuses a key under `kag
| model-manager.kagent.disableWiring | bool | `false` | |
| model-manager.mcp.enabled | bool | `true` | |
| model-manager.oauth.enabled | bool | `true` | |
| model-manager.oauth.provider | string | `"dex"` | |
| model-manager.oauth.downstream.enabled | bool | `true` | |
| model-manager.muster.mcpServer.enabled | bool | `true` | |
| model-manager.muster.mcpServer.auth.forwardToken | bool | `true` | |
Expand Down Expand Up @@ -1797,8 +1796,6 @@ The kagent block is open in the schema, so the template refuses a key under `kag
| cluster-manager.installation.name | string | `""` | |
| cluster-manager.mcp.enabled | bool | `true` | |
| cluster-manager.oauth.enabled | bool | `true` | |
| cluster-manager.oauth.provider | string | `"dex"` | |
| cluster-manager.oauth.dex.allowPrivateURLs | bool | `false` | |
| cluster-manager.oauth.downstream.enabled | bool | `true` | |
| cluster-manager.muster.mcpServer.enabled | bool | `true` | |
| cluster-manager.muster.mcpServer.auth.forwardToken | bool | `true` | |
Expand Down
27 changes: 19 additions & 8 deletions helm/agent-platform-connectivity/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ Usage: include "agent-platform.backstage.edgeGateways" . | fromJsonArray

{{/*
The in-cluster pods a platform service reaches the login identity provider at,
as a JSON list of {namespace, matchLabels, ports}
as a JSON list of {namespace, matchLabels or serviceName, ports}
(giantswarm/agent-platform#1383). An issuer served through an in-cluster
Gateway whose LoadBalancer address Cilium translates (a private installation)
is, at policy time, that Gateway's proxy pods on their own port (the Envoy edge
Expand All @@ -1412,7 +1412,7 @@ pods. networkPolicy.identityProvider.inClusterPeers, when set, is the list
actors' egress reaches (agent-platform.substrate.egressEdge);
- for an issuer host that names an in-cluster Service
(<service>.<namespace>.svc[.cluster.local], agent-platform.jwks.inCluster),
every pod of that namespace on the URL's port (443 for https, 80 for http).
that Service's backends on the URL's port (443 for https, 80 for http).
Usage: include "agent-platform.idpEgress.inClusterPeers" (dict "ctx" $ "issuerUrl" $url) | fromJsonArray
*/}}
{{- define "agent-platform.idpEgress.inClusterPeers" -}}
Expand All @@ -1431,7 +1431,7 @@ Usage: include "agent-platform.idpEgress.inClusterPeers" (dict "ctx" $ "issuerUr
{{- $host := include "agent-platform.jwks.normalizeHost" ($url.hostname | default "") -}}
{{- if include "agent-platform.jwks.inCluster" $host -}}
{{- $port := regexFind ":[0-9]+$" ($url.host | default "") | trimPrefix ":" | default (ternary "80" "443" (eq $url.scheme "http")) | int -}}
{{- $peers = append $peers (dict "namespace" (index (splitList "." $host) 1) "matchLabels" dict "ports" (list $port)) -}}
{{- $peers = append $peers (dict "namespace" (index (splitList "." $host) 1) "serviceName" (first (splitList "." $host)) "ports" (list $port)) -}}
{{- end -}}
{{- end -}}
{{- $peers | toJson -}}
Expand All @@ -1440,31 +1440,42 @@ Usage: include "agent-platform.idpEgress.inClusterPeers" (dict "ctx" $ "issuerUr
{{/*
Cilium egress rules from a platform service to the login identity provider:
the hosts of agent-platform.idpHosts (discovery, JWKS, userinfo, token) by
name on 443 (through the DNS proxy rule the caller renders), plus the
in-cluster peers of agent-platform.idpEgress.inClusterPeers, each by its
namespace and pod labels on its ports — never the cluster entity, which would
open every in-cluster endpoint on those ports (giantswarm/agent-platform#1383).
name on the issuer URL's port (Google endpoints use 443), plus the in-cluster
peers of agent-platform.idpEgress.inClusterPeers, selected by Service or
namespace and optional pod labels on their backend ports.
Rendered as YAML list items; the caller provides `egress:` and the indentation.
Usage: include "agent-platform.idpEgress.cilium" (dict "ctx" $ "provider" "dex" "issuerUrl" $url)
*/}}
{{- define "agent-platform.idpEgress.cilium" -}}
{{- $port := "443" -}}
{{- if and (eq .provider "dex") (not (include "agent-platform.idp.googleIssuer" .issuerUrl)) -}}
{{- $url := urlParse (toString (.issuerUrl | default "")) -}}
{{- $port = regexFind ":[0-9]+$" ($url.host | default "") | trimPrefix ":" | default "443" -}}
{{- end -}}
{{- with (include "agent-platform.idpHosts" . | fromJsonArray) }}
- toFQDNs:
{{- range . }}
- matchName: {{ . }}
{{- end }}
toPorts:
- ports:
- port: "443"
- port: {{ $port | quote }}
protocol: TCP
{{- end }}
{{- range (include "agent-platform.idpEgress.inClusterPeers" . | fromJsonArray) }}
{{- if .serviceName }}
- toServices:
- k8sService:
serviceName: {{ .serviceName }}
namespace: {{ .namespace }}
{{- else }}
- toEndpoints:
- matchLabels:
{{- with .matchLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
io.kubernetes.pod.namespace: {{ .namespace }}
{{- end }}
toPorts:
- ports:
{{- range .ports }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- define "agent-platform.idpEgress.kubernetes" -}}
{{- range dig "identityProvider" "inClusterPeers" list .Values.networkPolicy }}
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: {{ .namespace }}
{{- with .matchLabels }}
podSelector:
matchLabels:
{{- toYaml . | nindent 10 }}
{{- end }}
ports:
{{- range .ports }}
- port: {{ . | int }}
protocol: TCP
{{- end }}
{{- end -}}
{{- end -}}
69 changes: 69 additions & 0 deletions helm/agent-platform-connectivity/templates/_oauth-egress.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{/*
Trusted issuer discovery and JWKS destinations, with their URL ports.
Service destinations select only that Service's backends. Explicit identity
provider peers supply backend ports when Service port translation needs them.
*/}}
{{- define "agent-platform.oauth.trustedIssuerEgress" -}}
{{- $ctx := .ctx -}}
{{- $component := .component -}}
{{- $flavor := .flavor -}}
{{- $chart := index $ctx.Values $component | default dict -}}
{{- $main := include "agent-platform.idpHosts" (dict "provider" .provider "issuerUrl" .issuerUrl) | fromJsonArray -}}
{{- $mainPort := 443 -}}
{{- if and (eq .provider "dex") (not (include "agent-platform.idp.googleIssuer" .issuerUrl)) -}}
{{- $mainURL := urlParse (toString (.issuerUrl | default "")) -}}
{{- $mainPort = regexFind ":[0-9]+$" ($mainURL.host | default "") | trimPrefix ":" | default "443" | int -}}
{{- end -}}
{{- $configured := dig "identityProvider" "inClusterPeers" nil $ctx.Values.networkPolicy -}}
{{- $rules := dict -}}
{{- $issuers := dig "oauth" "resourceServer" "trustedIssuers" list $chart -}}
{{- if and (eq $flavor "kubernetes") .issuerUrl }}{{ $issuers = append $issuers (dict "issuer" .issuerUrl) }}{{ end -}}
{{- range $index, $entry := $issuers -}}
{{- range $field := list "issuer" "jwksURI" -}}
{{- $url := urlParse (toString (dig $field "" $entry)) -}}
{{- $host := include "agent-platform.jwks.normalizeHost" ($url.hostname | default "") -}}
{{- if $host -}}
{{- if include "agent-platform.jwks.addrLiteral" $host -}}
{{- fail (printf "%s.oauth.resourceServer.trustedIssuers[%d].%s names an address (%s): the network policy reaches a trusted issuer by name; use its DNS name" $component $index $field $host) -}}
{{- end -}}
{{- $port := regexFind ":[0-9]+$" ($url.host | default "") | trimPrefix ":" | default (ternary "80" "443" (eq $url.scheme "http")) | int -}}
{{- if or (lt $port 1) (gt $port 65535) -}}
{{- fail (printf "%s.oauth.resourceServer.trustedIssuers[%d].%s has an invalid port" $component $index $field) -}}
{{- end -}}
{{- $rule := dict -}}
{{- $ports := list $port -}}
{{- if include "agent-platform.jwks.inCluster" $host -}}
{{- $labels := splitList "." $host -}}
{{- $namespace := index $labels 1 -}}
{{- if and (eq $flavor "kubernetes") (kindIs "invalid" $configured) -}}
{{- fail (printf "%s issuer Service %s requires networkPolicy.identityProvider.inClusterPeers with namespaces and backend ports: Kubernetes NetworkPolicy cannot select a Service" $component $host) -}}
{{- end -}}
{{- if not (kindIs "invalid" $configured) -}}
{{- $ports = list -}}
{{- end -}}
{{- $_ := set $rule "toServices" (list (dict "k8sService" (dict "serviceName" (first $labels) "namespace" $namespace))) -}}
{{- else if and (eq $flavor "kubernetes") (ne $port 443) -}}
{{- $_ := set $rule "to" (list (dict "ipBlock" (dict "cidr" "0.0.0.0/0" "except" $ctx.Values.networkPolicy.kubernetes.worldExcludedCIDRs))) -}}
{{- else if and (eq $flavor "cilium") (not (and (eq $port $mainPort) (has $host $main))) -}}
{{- $_ := set $rule "toFQDNs" (list (dict "matchName" $host)) -}}
{{- end -}}
{{- if and $rule $ports -}}
{{- $portRules := list -}}
{{- range ($ports | uniq | sortAlpha) -}}
{{- $portRules = append $portRules (dict "port" (ternary (toString .) (int .) (eq $flavor "cilium")) "protocol" "TCP") -}}
{{- end -}}
{{- if eq $flavor "cilium" -}}
{{- $_ := set $rule "toPorts" (list (dict "ports" $portRules)) -}}
{{- else -}}
{{- $_ := set $rule "ports" $portRules -}}
{{- end -}}
{{- $_ := set $rules (toJson $rule) $rule -}}
{{- end -}}

{{- end -}}
{{- end -}}
{{- end -}}
{{- range (keys $rules | sortAlpha) }}
- {{ get $rules . | toYaml | nindent 2 | trim }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,27 @@ identity provider.
{{- end -}}

{{/*
The identity provider the component validates tokens with
(cluster-manager.oauth.provider): dex (the default) or google.
The identity provider the component validates tokens with: dex or google, as
the chart resolves it (cluster-manager.oauth.authorizationServer.upstream.type,
else the deprecated cluster-manager.oauth.provider, else global.identity.type,
else dex).
*/}}
{{- define "agent-platform.clusterManager.oauthProvider" -}}
{{- $chart := include "agent-platform.clusterManager.chartValues" . | fromJson -}}
{{- dig "oauth" "provider" "dex" $chart -}}
{{- dig "oauth" "authorizationServer" "upstream" "type" "" $chart | default (dig "oauth" "provider" "" $chart) | default .Values.global.identity.type | default "dex" -}}
{{- end -}}

{{/*
The issuer URL the component validates tokens against: the dex provider's
cluster-manager.oauth.dex.issuerURL, else global.identity.issuerUrl (the chart's
own fallback). Empty for the google provider and when neither is set.
cluster-manager.oauth.authorizationServer.upstream.issuer, else the deprecated
cluster-manager.oauth.dex.issuerURL, else global.identity.issuerUrl (the
chart's own fallbacks). Empty for the google provider (whose public endpoints
agent-platform.idpHosts names from the provider alone) and when neither is set.
*/}}
{{- define "agent-platform.clusterManager.issuerUrl" -}}
{{- $chart := include "agent-platform.clusterManager.chartValues" . | fromJson -}}
{{- if eq (include "agent-platform.clusterManager.oauthProvider" .) "dex" -}}
{{- dig "oauth" "dex" "issuerURL" "" $chart | default .Values.global.identity.issuerUrl -}}
{{- dig "oauth" "authorizationServer" "upstream" "issuer" "" $chart | default (dig "oauth" "dex" "issuerURL" "" $chart) | default .Values.global.identity.issuerUrl -}}
{{- end -}}
{{- end -}}

Expand Down
Loading
Loading