diff --git a/README.md b/README.md index 4c06821..f573cfd 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ The guides below cover individual topics in depth. The first four apply to ever | [ODBC Configuration](doc/odbc_configuration.md) | Loading data from external databases — PostgreSQL, MariaDB, and IBM i (AS/400) | | [Deployment Reference](doc/deployment_reference.md) | Per-container images, ports, volume paths, and environment variables — for orchestrators not listed above, or for debugging a running container | | [Helm Chart](charts/rocketgraph/README.md) | Deploying on Kubernetes and OpenShift, and every value the chart accepts | +| [Keycloak Setup for xGT](doc/keycloak_setup/README.md) | Illustrated normal-user and automation login setup, token mappers, LDAP federation, HTTPS trust and Mission Control; Helm examples require chart 0.5.0 | +| [OpenShift and LDAP Quickstart](doc/openshift_ldap_quickstart.md) | Deployment checklist for LDAP groups, OAuth clients, xGT labels and service-account tokens; Helm examples require chart 0.5.0 | | [OpenShift Test Server](doc/openshift_test_server/README.md) | Step-by-step LDAP/OAuth setup, group synchronization, FIPS images, automation tokens, and three XGT servers sharing Mission Control | | [OpenShift FIPS Deployment Planning](doc/openshift_fips_deployment.md) | Administrator responsibilities, required inputs, and deployment acceptance checks | diff --git a/charts/rocketgraph/Chart.yaml b/charts/rocketgraph/Chart.yaml index 2e9ad00..7f1ddd0 100644 --- a/charts/rocketgraph/Chart.yaml +++ b/charts/rocketgraph/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: rocketgraph description: Rocketgraph Mission Control with xGT icon: https://rocketgraph.com/wp-content/uploads/2025/02/R-logo-color.png -version: 0.4.0 +version: 0.5.0 appVersion: "2.7.0" diff --git a/charts/rocketgraph/README.md b/charts/rocketgraph/README.md index da996e4..27837ad 100644 --- a/charts/rocketgraph/README.md +++ b/charts/rocketgraph/README.md @@ -59,7 +59,7 @@ oc get route -frontend -o jsonpath='{.spec.host}' ### Full Stack with OpenShift restricted-v2 -In chart 0.4.0, add this to your site values to run XGT, Mission Control and MongoDB without an `anyuid` grant: +In chart 0.4.0 and later, add this to your site values to run XGT, Mission Control and MongoDB without an `anyuid` grant: ```yaml openshift: @@ -266,6 +266,8 @@ xgt: Keep per-release settings in version-controlled values files and pass them again to `helm upgrade`. Review release notes and rendered manifests before upgrading. If you modify chart templates instead, maintain a fork and merge upstream changes yourself; Helm does not merge customer template edits into an upstream chart. +Upgrades with `--reuse-values` retain the legacy frontend, backend and XGT TLS Secret key names when `secretKeys` is absent. Partial key mappings also retain defaults for unspecified entries. Custom key names must follow Kubernetes Secret key rules: 1–253 letters, digits, `.`, `_` or `-`, excluding `.` and names starting with `..`. When the chart generates a TLS Secret from inline certificate values, each supplied certificate, private key and CA must select a distinct key name. + ### With xGT License Manager The License Manager is a standalone service that serves license files to xGT over port 6200, supporting multiple licenses and multiple xGT replicas. When enabled, `license.location` in xgtd.conf is set automatically. @@ -295,6 +297,33 @@ See [`values-license-manager.yaml`](values-license-manager.yaml) for a complete Step-by-step guides for the chart's optional features. Each one shows the values to set and any Secret or ConfigMap you need to create first. For the complete list of every value the chart accepts, see [Values Reference](#values-reference). +### License and OIDC Secret Key Names + +Choose the source keys when reusing Secrets whose keys differ from the chart defaults: + +```yaml +xgt: + license: + existingSecret: company-xgt-license + secretKey: license.lic + oidc: + caCertExistingSecret: company-oidc + secretKeys: + caCert: ca.crt +backend: + oidc: + existingSecret: company-oidc + caCertExistingSecret: company-oidc + secretKeys: + clientSecret: client-secret + caCert: ca.crt + tlsVerify: /etc/ssl/certs/oidc-ca.pem +``` + +Here `company-xgt-license` must contain `license.lic`, and `company-oidc` must contain `client-secret` and `ca.crt`. The chart mounts the license at `/license/xgtd.lic`, mounts the OIDC CA at `/etc/ssl/certs/oidc-ca.pem` in each configured component, and exposes the client secret as `MC_OIDC_CLIENT_SECRET` in the backend. Source key names do not change those application destinations. For xGT alone, keep `xgt.oidc` and omit the backend settings. + +The same keys are used when the chart creates Secrets from `xgt.license.data`, `xgt.oidc.caCert`, `backend.oidc.clientSecret` or `backend.oidc.caCert`. Defaults remain `xgtd.lic`, `MC_OIDC_CLIENT_SECRET` and `oidc-ca.pem`; existing values files need no changes. Keys must be valid Kubernetes Secret keys: up to 253 letters, digits, `.`, `_` or `-`, excluding `.` and names beginning with `..`. Restart xGT after changing the license or CA, and restart the backend after changing its client secret or CA; file mounts use `subPath` and environment variables are read when the pod starts. + ### TLS / SSL #### Frontend HTTPS @@ -393,6 +422,167 @@ helm install rocketgraph ./charts/rocketgraph \ Users must select **PKIAuth** as the auth type when logging in for the backend to present the client certificate to xGT. +#### xGT SSL with OpenShift Service Serving Certificates + +OpenShift can issue and renew the xGT certificate itself. An annotation on the xGT service makes OpenShift create a `kubernetes.io/tls` secret holding the certificate and key under `tls.crt` and `tls.key`, and an annotated ConfigMap receives the CA that signed it under `service-ca.crt`. The chart reads both directly, so no certificates need to be generated or copied. + +1. Create a ConfigMap for OpenShift to fill with the service CA: + +```bash +oc create configmap xgt-service-ca -n +oc annotate configmap xgt-service-ca service.beta.openshift.io/inject-cabundle=true -n +``` + +1. Install with a values file like the following. The annotation asks OpenShift to create the `xgt-serving` secret, `secretKeys` maps its key names to the files xGT expects, and the backend verifies xGT against the injected CA. The certificate is issued for `..svc`, and the xGT service is named `-xgt`, so `XGT_SERVER_CN` must be `-xgt..svc`: + +```yaml +openshift: + enabled: true +xgt: + service: + annotations: + service.beta.openshift.io/serving-cert-secret-name: xgt-serving + ssl: + enabled: true + existingSecret: xgt-serving + secretKeys: + cert: tls.crt + key: tls.key +backend: + tls: + xgtServerCertConfigMap: xgt-service-ca + env: + XGT_SERVER_CN: -xgt..svc +``` + +```bash +helm install ./charts/rocketgraph -n -f serving-certs.yaml +``` + +The xGT pod waits in `ContainerCreating` until OpenShift has created the secret, which normally takes a few seconds after the service exists. + +For an XGT-only deployment under `restricted-v2`, see [examples/xgt_openshift_service_tls.yaml](examples/xgt_openshift_service_tls.yaml). Replace the licensed hostname and create the referenced license Secret before installing. + +xGT reads its certificate only at startup. When OpenShift renews the certificate, restart the xGT pod to pick up the new one: + +```bash +oc rollout restart deployment/-xgt -n +``` + +For mTLS, the backend's client certificate comes from your own CA, since the service CA does not issue client certificates. OpenShift owns the `xgt-serving` secret, so give xGT that CA in a secret of its own, and give the backend its client certificate and key as in the previous section: + +```bash +oc create secret generic xgt-client-ca --from-file=ca-chain.cert.pem=xgt-ca.pem -n +oc create secret generic backend-tls \ + --from-file=proxy-client-cert.pem=proxy-cert.pem \ + --from-file=proxy-client-key.pem=proxy-key.pem \ + -n +``` + +Then add these to the values file. The backend still verifies xGT against the service CA from `xgtServerCertConfigMap`, so `backend-tls` needs no `xgt-server.pem`: + +```yaml +xgt: + ssl: + mtls: true + caCertExistingSecret: xgt-client-ca +backend: + tls: + existingSecret: backend-tls + mtls: true +``` + +`secretKeys.caCert` names the CA's key in `xgt-client-ca`. As with any xGT mTLS setup, users must select **PKIAuth** when logging in. + +##### Connecting from Outside the Cluster + +Python scripts using the `xgt` client can connect to this server from outside the cluster. + +1. Expose xGT. The chart creates its service as `ClusterIP`, which is reachable only inside the cluster. Set `xgt.service.type` to `LoadBalancer` or `NodePort`, and connect to that address. + +1. Give each client machine the service CA, which signed xGT's certificate. Plain SSL needs no private key on the client. When OpenShift replaces its service CA, clients need the new copy: + +```bash +oc get configmap xgt-service-ca -n -o jsonpath='{.data.service-ca\.crt}' > service-ca.crt +``` + +1. Connect with SSL, setting `ssl_server_cn` to the name on the certificate. It defaults to the host connected to, and the certificate covers only the service's in-cluster name, not the external address: + +```python +import xgt + +conn = xgt.Connection( + host = "", port = 4367, + flags = { "ssl": True, + "ssl_server_cert": "service-ca.crt", + "ssl_server_cn": "-xgt..svc" }, + auth = xgt.BasicAuth("", "")) +``` + +With mTLS, each client also needs its own certificate and key, signed by the CA in `xgt-client-ca`. Keep the same `flags` and authenticate with the certificate: + +```python +auth = xgt.PKIAuth(ssl_server_cert = "service-ca.crt", + ssl_client_cert = "client.cert.pem", + ssl_client_key = "client.key.pem") +``` + +The `Connection` and `PKIAuth` documentation describes their other SSL options. + +The backend CA ConfigMap is mounted using `subPath`. When its CA bundle changes, restart the backend to refresh that mounted file: + +```bash +oc rollout restart deployment/-backend -n +``` + +#### Backend TLS Secret Key Names + +The backend can read an mTLS client Secret with `tls.crt` and `tls.key`, or custom key names, without renaming the source keys: + +```yaml +backend: + tls: + existingSecret: backend-client-tls + mtls: true + secretKeys: + cert: tls.crt + key: tls.key + caCert: ca.crt +``` + +For the backend, `cert` and `key` are its **client** certificate and private key used when connecting to XGT. `caCert` is the CA used to verify XGT's server certificate. The Secret must contain that CA key unless `backend.tls.xgtServerCertConfigMap` supplies it separately, as in the OpenShift service-certificate example above. The serving-certificate annotation does not issue these client credentials. + +The chart mounts the selected keys at the backend's existing paths: `/etc/ssl/certs/proxy-client-cert.pem`, `/etc/ssl/private/proxy-client-key.pem`, and `/etc/ssl/certs/xgt-server.pem`. It also uses the selected keys when creating a Secret from inline `proxyClientCert`, `proxyClientKey`, and `xgtServerCert`. Defaults remain unchanged. The ConfigMap CA key continues to use `xgtServerCertConfigMapKey`, independently of `secretKeys.caCert`. + +Restart the backend after updating its TLS Secret because these mounts use `subPath`. + +#### Frontend TLS Secret Key Names + +The frontend accepts standard Kubernetes TLS Secrets with `tls.crt` and `tls.key`. For browser access, the certificate must cover the public hostname, such as `mc.company.com`, and its CA must be trusted by the browser. Create the Secret using your issued certificate chain and private key: + +```bash +oc -n create secret tls frontend-tls \ + --cert=./fullchain.pem --key=./private-key.pem +``` + +Then select those source keys in your values file: + +```yaml +frontend: + tls: + existingSecret: frontend-tls + secretKeys: + cert: tls.crt + key: tls.key + caCert: client-ca.pem # Needed only when frontend.tls.mtls is true. +``` + +Key mapping preserves the certificate's identity and trust requirements. An OpenShift-generated **service** certificate covers internal Service DNS names, so it is useful for the router-to-frontend HTTPS connection of a re-encrypt Route. The browser sees the Route's separate certificate, which must cover the public hostname. An edge Route terminates TLS at the router and does not require frontend TLS Secret settings. + +These settings select source keys in the Secret. Container paths remain `/etc/ssl/certs/td.pem`, `/etc/ssl/private/td.pem`, and, for mTLS, `/etc/ssl/certs/ca-chain.pem`. The chart uses the same key names when creating a Secret from inline frontend certificates. Default keys remain `public.pem`, `private.pem`, and `chain.pem`. `secretKeys.caCert` selects the CA for verifying browser client certificates; server intermediate certificates belong in `tls.crt` with the server certificate. + +Restart the frontend after certificate updates because its certificate mounts use `subPath`. + ### With MongoDB Authentication The three MongoDB hardening features below — authentication, TLS, and encryption at rest — are explained in depth in the [MongoDB security guide](../../doc/mongodb_security.md), including how auth enforcement is decided, the upgrade path for a data volume that was initialised without auth, and troubleshooting. The sections here cover the chart values and Secrets; consult that guide for the reasoning and failure modes. @@ -758,6 +948,8 @@ See the [OIDC configuration guide](../../doc/oidc_configuration.md) for how the #### Keycloak +For screenshots, token mappers, Python login scripts and optional LDAP/CA setup, follow [Keycloak Setup for xGT](../../doc/keycloak_setup/README.md). Its Helm examples require chart **0.5.0**; the [Mission Control page](../../doc/keycloak_setup/mission_control.md) includes the client registration, Secret, values and Route manifests. + Register a confidential client named `mission-control` with Standard flow enabled and callback `https://mc.example.com/api/login/oidc/callback`. Store its secret in `mission-control-oidc` under key `MC_OIDC_CLIENT_SECRET`. Keep the Python browser client `xgtd-client` public with PKCE `S256` and callback `http://127.0.0.1:8765/callback`. Mission Control 2.7.0 does not send PKCE, so do not require it on the confidential client. ```yaml @@ -825,22 +1017,25 @@ Issuer, client ID, and `user:info` are discovered from xGT. The callback is deri #### CA Certificates -If the identity provider uses a private or self-signed CA, create a secret and reference it. -The cert is automatically mounted into both the backend and xGT, and `security.oidc.ca_cert` -is injected into xGT's config automatically. +If the identity provider uses a private or self-signed CA, create a Secret and reference it in the component that makes the HTTPS requests. ```bash kubectl create secret generic oidc-ca --from-file=oidc-ca.pem=/path/to/ca.pem -n ``` ```yaml +xgt: + oidc: + caCertExistingSecret: oidc-ca backend: oidc: caCertExistingSecret: oidc-ca tlsVerify: /etc/ssl/certs/oidc-ca.pem ``` -The mount supplies the certificate file; `tlsVerify` selects that file for backend HTTPS verification. Both are needed when the CA is not already trusted. +`xgt.oidc.caCertExistingSecret` mounts the CA into xGT at `/etc/ssl/certs/oidc-ca.pem` and fills in `security.oidc.ca_cert` in the generated configuration when that field is absent. An explicit `xgt.extraConfig.security.oidc.ca_cert` is unnecessary for this mount. For an external ConfigMap or files PVC, set that path in the mounted configuration yourself. Omit the backend section when Mission Control is disabled. + +For Mission Control, `backend.oidc.caCertExistingSecret` supplies its backend's mount and `tlsVerify` selects that file for backend HTTPS verification. The two components can reuse the same Secret or trust different bundles. An xGT-specific CA source takes precedence for xGT; when neither `xgt.oidc.caCertExistingSecret` nor `xgt.oidc.caCert` is set, the chart still uses the legacy backend CA settings for xGT. Existing values files keep working. ### Site Configuration @@ -974,22 +1169,31 @@ The Ingress routes to the frontend service on port 80. The ingress controller te | Parameter | Description | Default | |-------------------------------|-----------------------------------------------------------------------------------------------|---------| -| `frontend.tls.existingSecret` | Secret with keys: `public.pem`, `private.pem`, optionally `chain.pem` for mTLS | `""` | +| `frontend.tls.existingSecret` | TLS Secret; key names selected by `secretKeys` | `""` | +| `frontend.tls.secretKeys` | Certificate, private-key and client-CA source keys in existing or chart-generated Secrets | `{cert: public.pem, key: private.pem, caCert: chain.pem}` | | `frontend.tls.publicCert` | Inline public cert PEM | `""` | | `frontend.tls.privateKey` | Inline private key PEM | `""` | -| `frontend.tls.certChain` | Inline cert chain PEM (enables mTLS) | `""` | +| `frontend.tls.certChain` | Inline client-CA chain PEM, mounted when `frontend.tls.mtls` is true | `""` | +| `frontend.tls.mtls` | Require browser client certificates | `false` | | `frontend.tls.external` | TLS terminated upstream (Ingress TLS / edge route); marks session cookies `Secure` | `false` | -| `backend.tls.existingSecret` | Secret with keys: `xgt-server.pem`, optionally `proxy-client-cert.pem`/`proxy-client-key.pem` | `""` | +| `backend.tls.existingSecret` | TLS Secret; key names selected by `secretKeys` | `""` | +| `backend.tls.secretKeys` | Client certificate/key and XGT CA source keys in existing or chart-generated Secrets | `{cert: proxy-client-cert.pem, key: proxy-client-key.pem, caCert: xgt-server.pem}` | | `backend.tls.xgtServerCert` | Inline xGT server CA cert PEM | `""` | | `backend.tls.proxyClientCert` | Inline proxy client cert PEM | `""` | | `backend.tls.proxyClientKey` | Inline proxy client key PEM | `""` | | `backend.tls.mtls` | Enable mTLS for backend connections to xGT (requires `existingSecret` or inline cert+key) | `false` | +| `backend.tls.xgtServerCertConfigMap` | Existing ConfigMap holding the xGT CA, e.g. one filled by OpenShift's `service.beta.openshift.io/inject-cabundle`; used instead of `xgt-server.pem` | `""` | +| `backend.tls.xgtServerCertConfigMapKey` | Key in `xgtServerCertConfigMap` that holds the CA | `service-ca.crt` | | `xgt.ssl.enabled` | Enable SSL on xGT server | `false` | -| `xgt.ssl.existingSecret` | Secret with keys: `server.cert.pem`, `server.key.pem`, optionally `ca-chain.cert.pem` | `""` | +| `xgt.ssl.existingSecret` | Secret with the server cert, key and optionally CA chain, under the names in `secretKeys` | `""` | +| `xgt.ssl.secretKeys.cert` | Key holding the server cert in the xGT TLS secret (e.g. `tls.crt`) | `server.cert.pem` | +| `xgt.ssl.secretKeys.key` | Key holding the server private key in the xGT TLS secret (e.g. `tls.key`) | `server.key.pem` | +| `xgt.ssl.secretKeys.caCert` | Key holding the CA chain for validating client certs when `mtls` is true, in `caCertExistingSecret` if set | `ca-chain.cert.pem` | | `xgt.ssl.cert` | Inline xGT server cert PEM | `""` | | `xgt.ssl.key` | Inline xGT server key PEM | `""` | -| `xgt.ssl.mtls` | Require client certificates on xGT server (needs `ca-chain.cert.pem` in secret or `caCert`) | `false` | +| `xgt.ssl.mtls` | Require client certificates on xGT server (needs a client CA in the secret, `caCertExistingSecret` or `caCert`) | `false` | | `xgt.ssl.caCert` | Inline CA cert PEM for validating client certs (`ca-chain.cert.pem`) | `""` | +| `xgt.ssl.caCertExistingSecret` | Separate Secret holding the client CA under `secretKeys.caCert`, for when the server cert's Secret is managed elsewhere | `""` | ### Backend Environment @@ -1013,14 +1217,16 @@ The Ingress routes to the frontend service on port 80. The ingress controller te | `backend.oidc.issuer` | Override OIDC issuer URL (auto-discovered from xGT if empty) | `""` | | `backend.oidc.clientId` | Override OAuth2 client ID (auto-discovered from xGT if empty) | `""` | | `backend.oidc.clientSecret` | Client secret — inline value creates a Secret | `""` | -| `backend.oidc.existingSecret` | Existing Secret with key `MC_OIDC_CLIENT_SECRET` | `""` | +| `backend.oidc.existingSecret` | Existing Secret with the key selected by `secretKeys.clientSecret` | `""` | +| `backend.oidc.secretKeys.clientSecret` | Client secret key in existing and chart-generated Secrets | `MC_OIDC_CLIENT_SECRET` | | `backend.oidc.scopes` | Optional scope override; uses xGT-advertised scopes during discovery when empty | `""` | | `backend.oidc.frontendUrl` | Override public frontend origin for post-login redirects and the derived callback | `""` | | `backend.oidc.redirectUri` | Override redirect URI sent to the IdP | `""` | | `backend.oidc.allowedOrigins` | Comma-separated allowed origins (defense-in-depth, optional) | `""` | | `backend.oidc.tlsVerify` | `true`, `false`, or path to CA bundle for OIDC HTTP calls | `""` | -| `backend.oidc.caCert` | Inline CA PEM — creates a Secret, mounted into backend and xGT at `/etc/ssl/certs/oidc-ca.pem` | `""` | -| `backend.oidc.caCertExistingSecret`| Existing Secret with key `oidc-ca.pem` | `""` | +| `backend.oidc.caCert` | Inline CA PEM for backend HTTPS; legacy fallback for xGT when no xGT-specific source is set | `""` | +| `backend.oidc.caCertExistingSecret`| Existing Secret with the key selected by `secretKeys.caCert` | `""` | +| `backend.oidc.secretKeys.caCert` | Backend CA bundle key; also used by xGT when falling back to backend CA settings | `oidc-ca.pem` | | `backend.oidc.xgtAllowedHosts` | xGT host:port allowlist (SSRF prevention). Defaults to internal xGT service. | `""` | ### Persistence @@ -1065,6 +1271,9 @@ The Ingress routes to the frontend service on port 80. The ingress controller te |-----------------------------|--------------------------------------|----------------| | `xgt.enabled` | Deploy xGT as part of the release | `true` | | `xgt.hostname` | Fixed container OS hostname for licensing; does not change the pod or Service name | `""` | +| `xgt.oidc.caCert` | Inline CA PEM for xGT OIDC HTTPS requests; creates an xGT CA Secret | `""` | +| `xgt.oidc.caCertExistingSecret` | Existing xGT OIDC CA Secret; preferred over inline CA. Uses legacy backend CA settings if both xGT sources are empty | `""` | +| `xgt.oidc.secretKeys.caCert` | CA bundle key in the xGT OIDC CA Secret; mounted at `/etc/ssl/certs/oidc-ca.pem` | `oidc-ca.pem` | | `xgt.files.existingClaim` | Common PVC for conf/license/data/log; separate data/log existing claims override their mounts | `""` | | `xgt.files.subPath` | Optional relative parent directory on the common files PVC; does not apply to separate data/log claims | `""` | | `xgt.persistence.data.existingClaim` | Existing data PVC mounted at `/data`; takes precedence over the files PVC | `""` | @@ -1098,7 +1307,8 @@ The Ingress routes to the frontend service on port 80. The ingress controller te | `openshift.enabled` | Create a ServiceAccount and configure the selected SCC profile | `false` | | `openshift.scc` | `anyuid`, `nonroot`, or `restricted-v2` for XGT/Mission Control/MongoDB (no elevated binding) | `anyuid` | | `networkPolicy.enabled` | Restrict inter-component traffic with per-component policies | `true` | -| `xgt.license.existingSecret` | Secret with key `xgtd.lic` (direct file mount) | `""` | +| `xgt.license.existingSecret` | Secret with the license file key selected by `secretKey` | `""` | +| `xgt.license.secretKey` | Key in existing and chart-generated Secrets; mounted at `/license/xgtd.lic` | `xgtd.lic` | | `xgt.license.data` | Inline license content (use `--set-file`) | `""` | ### License Manager Parameters diff --git a/charts/rocketgraph/examples/xgt_openshift_service_tls.yaml b/charts/rocketgraph/examples/xgt_openshift_service_tls.yaml new file mode 100644 index 0000000..b6eab2c --- /dev/null +++ b/charts/rocketgraph/examples/xgt_openshift_service_tls.yaml @@ -0,0 +1,38 @@ +# XGT-only with an OpenShift-generated serving certificate under restricted-v2. +# Create the license Secret first and replace the hostname for your license. +missionControl: + enabled: false +mongodb: + enabled: false +openshift: + enabled: true + scc: restricted-v2 +fips: + enabled: true +xgt: + hostname: demo-xgt-test + image: + tag: '2.7.1' + license: + existingSecret: xgt-license + service: + annotations: + service.beta.openshift.io/serving-cert-secret-name: xgt-serving-tls + ssl: + enabled: true + existingSecret: xgt-serving-tls + secretKeys: + cert: tls.crt + key: tls.key + # For mTLS, create a Secret with ca-chain.cert.pem containing the client CA: + # mtls: true + # caCertExistingSecret: xgt-client-ca + extraConfig: + system.max_memory: '1' + system.worker_threads: '2' + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 1536Mi diff --git a/charts/rocketgraph/templates/_helpers.tpl b/charts/rocketgraph/templates/_helpers.tpl index f56aa87..45fcd08 100644 --- a/charts/rocketgraph/templates/_helpers.tpl +++ b/charts/rocketgraph/templates/_helpers.tpl @@ -121,6 +121,24 @@ Backend OIDC CA cert secret name {{- .Values.backend.oidc.caCertExistingSecret | default (printf "%s-backend-oidc-ca" .Release.Name) }} {{- end }} +{{/* xGT owns its OIDC CA; backend settings remain a legacy fallback. */}} +{{- define "rocketgraph.xgtOidcCa" -}} +{{- $oidc := .Values.xgt.oidc | default dict -}} +{{- $source := .Values.backend.oidc -}} +{{- $keys := include "rocketgraph.backendOidcKeys" . | fromYaml -}} +{{- $name := include "rocketgraph.backendOidcCaSecret" . -}} +{{- $owner := "backend" -}} +{{- if or $oidc.caCert $oidc.caCertExistingSecret -}} + {{- $source = $oidc -}} + {{- $keys = merge (deepCopy ($oidc.secretKeys | default dict)) (dict "caCert" "oidc-ca.pem") -}} + {{- $name = $oidc.caCertExistingSecret | default (printf "%s-xgt-oidc-ca" .Release.Name) -}} + {{- $owner = "xgt" -}} +{{- end -}} +{{- dict "enabled" (or (not (empty $source.caCert)) (not (empty $source.caCertExistingSecret))) + "existingSecret" ($source.caCertExistingSecret | default "") + "data" ($source.caCert | default "") "name" $name "key" $keys.caCert "owner" $owner | toYaml -}} +{{- end -}} + {{/* FIPS image tag suffix — appends "-fips" when fips.enabled=true, empty otherwise. */}} diff --git a/charts/rocketgraph/templates/_secret_keys.tpl b/charts/rocketgraph/templates/_secret_keys.tpl new file mode 100644 index 0000000..e597533 --- /dev/null +++ b/charts/rocketgraph/templates/_secret_keys.tpl @@ -0,0 +1,9 @@ +{{/* Keep historical keys when --reuse-values omits new chart defaults. */}} +{{- define "rocketgraph.backendOidcKeys" -}} +{{- merge (deepCopy (.Values.backend.oidc.secretKeys | default dict)) (dict + "clientSecret" "MC_OIDC_CLIENT_SECRET" "caCert" "oidc-ca.pem") | toYaml -}} +{{- end -}} + +{{- define "rocketgraph.xgtLicenseKey" -}} +{{- .Values.xgt.license.secretKey | default "xgtd.lic" -}} +{{- end -}} diff --git a/charts/rocketgraph/templates/_tls.tpl b/charts/rocketgraph/templates/_tls.tpl new file mode 100644 index 0000000..5d0c651 --- /dev/null +++ b/charts/rocketgraph/templates/_tls.tpl @@ -0,0 +1,29 @@ +{{/* Keep legacy key names when --reuse-values omits new chart defaults. */}} +{{- define "rocketgraph.frontendTlsKeys" -}} +{{- merge (deepCopy (.Values.frontend.tls.secretKeys | default dict)) (dict + "cert" "public.pem" "key" "private.pem" "caCert" "chain.pem") | toYaml -}} +{{- end -}} + +{{- define "rocketgraph.backendTlsKeys" -}} +{{- merge (deepCopy (.Values.backend.tls.secretKeys | default dict)) (dict + "cert" "proxy-client-cert.pem" "key" "proxy-client-key.pem" "caCert" "xgt-server.pem") | toYaml -}} +{{- end -}} + +{{- define "rocketgraph.xgtTlsKeys" -}} +{{- merge (deepCopy (.Values.xgt.ssl.secretKeys | default dict)) (dict + "cert" "server.cert.pem" "key" "server.key.pem" "caCert" "ca-chain.cert.pem") | toYaml -}} +{{- end -}} + +{{/* Only emitted inline fields must be distinct; existing Secrets may use PEM bundles. */}} +{{- define "rocketgraph.validateInlineTlsKeys" -}} +{{- $used := dict -}} +{{- range $field, $payload := .inline -}} + {{- if $payload -}} + {{- $key := index $.keys $field -}} + {{- if hasKey $used $key -}} + {{- fail (printf "%s.secretKeys.%s and %s.secretKeys.%s both select %q; set distinct Secret key names for inline certificates" $.prefix (index $used $key) $.prefix $field $key) -}} + {{- end -}} + {{- $_ := set $used $key $field -}} + {{- end -}} +{{- end -}} +{{- end -}} diff --git a/charts/rocketgraph/templates/_validation.tpl b/charts/rocketgraph/templates/_validation.tpl index 8cc9cde..16c4e23 100644 --- a/charts/rocketgraph/templates/_validation.tpl +++ b/charts/rocketgraph/templates/_validation.tpl @@ -4,6 +4,24 @@ Call via: {{- include "rocketgraph.validate" . }} */}} {{- define "rocketgraph.validate" -}} +{{- if .Values.missionControl.enabled }} + {{- if not .Values.frontend.tls.existingSecret }} + {{- include "rocketgraph.validateInlineTlsKeys" (dict + "prefix" "frontend.tls" "keys" (include "rocketgraph.frontendTlsKeys" . | fromYaml) + "inline" (dict "cert" .Values.frontend.tls.publicCert "key" .Values.frontend.tls.privateKey "caCert" .Values.frontend.tls.certChain)) }} + {{- end }} + {{- if not .Values.backend.tls.existingSecret }} + {{- include "rocketgraph.validateInlineTlsKeys" (dict + "prefix" "backend.tls" "keys" (include "rocketgraph.backendTlsKeys" . | fromYaml) + "inline" (dict "cert" .Values.backend.tls.proxyClientCert "key" .Values.backend.tls.proxyClientKey "caCert" .Values.backend.tls.xgtServerCert)) }} + {{- end }} +{{- end }} +{{- if and .Values.xgt.enabled (not .Values.xgt.files.existingClaim) .Values.xgt.ssl.enabled (not .Values.xgt.ssl.existingSecret) }} + {{- include "rocketgraph.validateInlineTlsKeys" (dict + "prefix" "xgt.ssl" "keys" (include "rocketgraph.xgtTlsKeys" . | fromYaml) + "inline" (dict "cert" .Values.xgt.ssl.cert "key" .Values.xgt.ssl.key "caCert" .Values.xgt.ssl.caCert)) }} +{{- end }} + {{- if and .Values.openshift.enabled (eq .Values.openshift.scc "restricted-v2") }} {{- if and .Values.missionControl.enabled (not .Values.fips.enabled) }} {{- fail "restricted-v2 with Mission Control requires fips.enabled=true; the non-FIPS frontend image has different startup and writable paths" }} @@ -39,7 +57,7 @@ Call via: {{- include "rocketgraph.validate" . }} {{- if or .Values.xgt.config.existingConfigMap .Values.xgt.config.grouplabelCsv .Values.xgt.config.labelCsv .Values.xgt.config.proxyList .Values.xgt.extraConfig }} {{- fail "xgt.files.existingClaim uses configuration files on the PVC; remove xgt.config overrides and xgt.extraConfig and edit the PVC files instead" }} {{- end }} - {{- if or .Values.xgt.license.existingSecret .Values.xgt.license.data .Values.xgt.licenseManager.enabled .Values.xgt.ldap.enabled .Values.xgt.ssl.existingSecret .Values.xgt.ssl.cert .Values.xgt.ssl.key .Values.xgt.ssl.caCert }} + {{- if or .Values.xgt.license.existingSecret .Values.xgt.license.data .Values.xgt.licenseManager.enabled .Values.xgt.ldap.enabled .Values.xgt.ssl.existingSecret .Values.xgt.ssl.cert .Values.xgt.ssl.key .Values.xgt.ssl.caCert .Values.xgt.ssl.caCertExistingSecret }} {{- fail "xgt.files.existingClaim supplies license and TLS files on the PVC; remove separate license/TLS/LDAP sources and the bundled license manager" }} {{- end }} {{- end }} @@ -88,11 +106,22 @@ Call via: {{- include "rocketgraph.validate" . }} {{- if and .Values.backend.tls.mtls (not .Values.backend.tls.existingSecret) (not .Values.backend.tls.proxyClientCert) (not .Values.backend.tls.proxyClientKey) }} {{- fail "backend.tls.mtls is true but no existingSecret or inline proxyClientCert/proxyClientKey provided" }} {{- end }} +{{- if and .Values.backend.tls.xgtServerCertConfigMap .Values.backend.tls.xgtServerCert }} + {{- fail "backend.tls.xgtServerCert is ignored when xgtServerCertConfigMap is set — set only one source for the xGT CA" }} +{{- end }} {{- end }} -{{- if and .Values.xgt.enabled (not .Values.xgt.files.existingClaim) .Values.xgt.ssl.enabled .Values.xgt.ssl.mtls (not .Values.xgt.ssl.existingSecret) (not .Values.xgt.ssl.caCert) }} - {{- fail "xgt.ssl.mtls is true but no existingSecret or inline caCert provided for ca-chain.cert.pem" }} +{{- if and .Values.xgt.enabled (not .Values.xgt.files.existingClaim) .Values.xgt.ssl.enabled .Values.xgt.ssl.mtls (not .Values.xgt.ssl.existingSecret) (not .Values.xgt.ssl.caCertExistingSecret) (not .Values.xgt.ssl.caCert) }} + {{- fail "xgt.ssl.mtls is true but no existingSecret, caCertExistingSecret or inline caCert provided for ca-chain.cert.pem" }} +{{- end }} +{{- if and .Values.xgt.enabled (not .Values.xgt.files.existingClaim) .Values.xgt.ssl.caCertExistingSecret }} + {{- if not (and .Values.xgt.ssl.enabled .Values.xgt.ssl.mtls) }} + {{- fail "xgt.ssl.caCertExistingSecret is only used when xgt.ssl.enabled and xgt.ssl.mtls are true" }} + {{- end }} + {{- if .Values.xgt.ssl.caCert }} + {{- fail "xgt.ssl.caCert is ignored when caCertExistingSecret is set — set only one source for the client CA" }} + {{- end }} {{- end }} {{- if and .Values.xgt.enabled (not .Values.xgt.files.existingClaim) .Values.xgt.ssl.enabled .Values.xgt.ssl.mtls .Values.xgt.ssl.existingSecret .Values.xgt.ssl.caCert }} {{- fail "xgt.ssl.caCert is ignored when existingSecret is set — include ca-chain.cert.pem in the existing secret instead" }} diff --git a/charts/rocketgraph/templates/backend-deployment.yaml b/charts/rocketgraph/templates/backend-deployment.yaml index d08a97c..0d203f7 100644 --- a/charts/rocketgraph/templates/backend-deployment.yaml +++ b/charts/rocketgraph/templates/backend-deployment.yaml @@ -1,4 +1,6 @@ {{- if .Values.missionControl.enabled }} +{{- $tlsKeys := include "rocketgraph.backendTlsKeys" . | fromYaml }} +{{- $oidcKeys := include "rocketgraph.backendOidcKeys" . | fromYaml }} apiVersion: apps/v1 kind: Deployment metadata: @@ -132,7 +134,7 @@ spec: valueFrom: secretKeyRef: name: {{ include "rocketgraph.backendOidcSecret" . }} - key: MC_OIDC_CLIENT_SECRET + key: {{ $oidcKeys.clientSecret | quote }} {{- end }} {{- if .Values.backend.oidc.scopes }} - name: MC_OIDC_SCOPES @@ -189,23 +191,28 @@ spec: least one condition holds — a bare "volumeMounts:" renders null and fails strict schema validation. Keep this condition the union of the entry conditions below. */}} - {{- $hasMounts := or .Values.backend.tls.existingSecret .Values.backend.tls.xgtServerCert .Values.backend.tls.mtls .Values.backend.odbc.enabled .Values.backend.iaccess.enabled .Values.backend.siteConfig.yml .Values.backend.siteConfig.py .Values.backend.oidc.caCert .Values.backend.oidc.caCertExistingSecret (and .Values.mongodb.tls.enabled (or .Values.mongodb.tls.caCert .Values.mongodb.tls.existingSecret)) }} + {{- $hasMounts := or .Values.backend.tls.existingSecret .Values.backend.tls.xgtServerCert .Values.backend.tls.xgtServerCertConfigMap .Values.backend.tls.mtls .Values.backend.odbc.enabled .Values.backend.iaccess.enabled .Values.backend.siteConfig.yml .Values.backend.siteConfig.py .Values.backend.oidc.caCert .Values.backend.oidc.caCertExistingSecret (and .Values.mongodb.tls.enabled (or .Values.mongodb.tls.caCert .Values.mongodb.tls.existingSecret)) }} {{- if $hasMounts }} volumeMounts: - {{- if or .Values.backend.tls.existingSecret .Values.backend.tls.xgtServerCert }} - - name: tls-certs + {{- if .Values.backend.tls.xgtServerCertConfigMap }} + - name: xgt-server-ca mountPath: /etc/ssl/certs/xgt-server.pem subPath: xgt-server.pem readOnly: true + {{- else if or .Values.backend.tls.existingSecret .Values.backend.tls.xgtServerCert }} + - name: tls-certs + mountPath: /etc/ssl/certs/xgt-server.pem + subPath: {{ $tlsKeys.caCert | quote }} + readOnly: true {{- end }} {{- if .Values.backend.tls.mtls }} - name: tls-certs mountPath: /etc/ssl/certs/proxy-client-cert.pem - subPath: proxy-client-cert.pem + subPath: {{ $tlsKeys.cert | quote }} readOnly: true - name: tls-certs mountPath: /etc/ssl/private/proxy-client-key.pem - subPath: proxy-client-key.pem + subPath: {{ $tlsKeys.key | quote }} readOnly: true {{- end }} {{- /* When odbc is disabled nothing mounts at /odbc: the image @@ -234,7 +241,7 @@ spec: {{- if or .Values.backend.oidc.caCert .Values.backend.oidc.caCertExistingSecret }} - name: oidc-ca-cert mountPath: /etc/ssl/certs/oidc-ca.pem - subPath: oidc-ca.pem + subPath: {{ $oidcKeys.caCert | quote }} readOnly: true {{- end }} {{- if and .Values.mongodb.tls.enabled (or .Values.mongodb.tls.caCert .Values.mongodb.tls.existingSecret) }} @@ -265,7 +272,7 @@ spec: restartPolicy: Always {{- /* Same rationale as volumeMounts above: all entries are conditional, so gate the key on the union of their conditions. */}} - {{- $hasVolumes := or .Values.backend.tls.existingSecret .Values.backend.tls.xgtServerCert .Values.backend.tls.proxyClientCert .Values.backend.tls.proxyClientKey .Values.backend.odbc.enabled .Values.backend.iaccess.enabled .Values.backend.siteConfig.yml .Values.backend.siteConfig.py .Values.backend.oidc.caCert .Values.backend.oidc.caCertExistingSecret (and .Values.mongodb.tls.enabled (or .Values.mongodb.tls.caCert .Values.mongodb.tls.existingSecret)) }} + {{- $hasVolumes := or .Values.backend.tls.existingSecret .Values.backend.tls.xgtServerCert .Values.backend.tls.xgtServerCertConfigMap .Values.backend.tls.proxyClientCert .Values.backend.tls.proxyClientKey .Values.backend.odbc.enabled .Values.backend.iaccess.enabled .Values.backend.siteConfig.yml .Values.backend.siteConfig.py .Values.backend.oidc.caCert .Values.backend.oidc.caCertExistingSecret (and .Values.mongodb.tls.enabled (or .Values.mongodb.tls.caCert .Values.mongodb.tls.existingSecret)) }} {{- if $hasVolumes }} volumes: {{- if or .Values.backend.tls.existingSecret .Values.backend.tls.xgtServerCert .Values.backend.tls.proxyClientCert .Values.backend.tls.proxyClientKey }} @@ -273,6 +280,14 @@ spec: secret: secretName: {{ include "rocketgraph.backendTlsSecret" . }} {{- end }} + {{- with .Values.backend.tls.xgtServerCertConfigMap }} + - name: xgt-server-ca + configMap: + name: {{ . | quote }} + items: + - key: {{ $.Values.backend.tls.xgtServerCertConfigMapKey | default "service-ca.crt" | quote }} + path: xgt-server.pem + {{- end }} {{- if .Values.backend.odbc.enabled }} - name: odbc-drivers persistentVolumeClaim: diff --git a/charts/rocketgraph/templates/backend-oidc-secret.yaml b/charts/rocketgraph/templates/backend-oidc-secret.yaml index a2fd601..502f5df 100644 --- a/charts/rocketgraph/templates/backend-oidc-secret.yaml +++ b/charts/rocketgraph/templates/backend-oidc-secret.yaml @@ -1,3 +1,4 @@ +{{- $oidcKeys := include "rocketgraph.backendOidcKeys" . | fromYaml -}} {{- if and .Values.missionControl.enabled (not .Values.backend.oidc.existingSecret) .Values.backend.oidc.clientSecret -}} apiVersion: v1 kind: Secret @@ -8,7 +9,7 @@ metadata: {{- include "rocketgraph.labels" . | nindent 4 }} type: Opaque stringData: - MC_OIDC_CLIENT_SECRET: {{ .Values.backend.oidc.clientSecret | quote }} + {{ $oidcKeys.clientSecret | quote }}: {{ .Values.backend.oidc.clientSecret | quote }} {{- end }} {{- if and (or .Values.missionControl.enabled .Values.xgt.enabled) (not .Values.backend.oidc.caCertExistingSecret) .Values.backend.oidc.caCert }} --- @@ -21,5 +22,5 @@ metadata: {{- include "rocketgraph.labels" . | nindent 4 }} type: Opaque stringData: - oidc-ca.pem: {{ .Values.backend.oidc.caCert | quote }} + {{ $oidcKeys.caCert | quote }}: {{ .Values.backend.oidc.caCert | quote }} {{- end }} diff --git a/charts/rocketgraph/templates/backend-tls-secret.yaml b/charts/rocketgraph/templates/backend-tls-secret.yaml index df0f69c..253cb7a 100644 --- a/charts/rocketgraph/templates/backend-tls-secret.yaml +++ b/charts/rocketgraph/templates/backend-tls-secret.yaml @@ -1,4 +1,5 @@ {{- if .Values.missionControl.enabled }} +{{- $tlsKeys := include "rocketgraph.backendTlsKeys" . | fromYaml }} {{- if and (not .Values.backend.tls.existingSecret) (or .Values.backend.tls.xgtServerCert .Values.backend.tls.proxyClientCert .Values.backend.tls.proxyClientKey) }} apiVersion: v1 kind: Secret @@ -10,13 +11,13 @@ metadata: type: Opaque stringData: {{- if .Values.backend.tls.xgtServerCert }} - xgt-server.pem: {{ .Values.backend.tls.xgtServerCert | quote }} + {{ $tlsKeys.caCert | quote }}: {{ .Values.backend.tls.xgtServerCert | quote }} {{- end }} {{- if .Values.backend.tls.proxyClientCert }} - proxy-client-cert.pem: {{ .Values.backend.tls.proxyClientCert | quote }} + {{ $tlsKeys.cert | quote }}: {{ .Values.backend.tls.proxyClientCert | quote }} {{- end }} {{- if .Values.backend.tls.proxyClientKey }} - proxy-client-key.pem: {{ .Values.backend.tls.proxyClientKey | quote }} + {{ $tlsKeys.key | quote }}: {{ .Values.backend.tls.proxyClientKey | quote }} {{- end }} {{- end }} diff --git a/charts/rocketgraph/templates/frontend-deployment.yaml b/charts/rocketgraph/templates/frontend-deployment.yaml index 453ae32..007cab5 100644 --- a/charts/rocketgraph/templates/frontend-deployment.yaml +++ b/charts/rocketgraph/templates/frontend-deployment.yaml @@ -1,4 +1,5 @@ {{- if .Values.missionControl.enabled }} +{{- $tlsKeys := include "rocketgraph.frontendTlsKeys" . | fromYaml }} {{- $restricted := and .Values.openshift.enabled (eq .Values.openshift.scc "restricted-v2") }} {{- $tls := or .Values.frontend.tls.existingSecret .Values.frontend.tls.publicCert .Values.frontend.tls.privateKey }} apiVersion: apps/v1 @@ -110,16 +111,16 @@ spec: {{- if $tls }} - name: tls-certs mountPath: /etc/ssl/certs/td.pem - subPath: public.pem + subPath: {{ $tlsKeys.cert | quote }} readOnly: true - name: tls-certs mountPath: /etc/ssl/private/td.pem - subPath: private.pem + subPath: {{ $tlsKeys.key | quote }} readOnly: true {{- if and .Values.frontend.tls.mtls (or .Values.frontend.tls.certChain .Values.frontend.tls.existingSecret) }} - name: tls-certs mountPath: /etc/ssl/certs/ca-chain.pem - subPath: chain.pem + subPath: {{ $tlsKeys.caCert | quote }} readOnly: true {{- end }} {{- end }} diff --git a/charts/rocketgraph/templates/frontend-tls-secret.yaml b/charts/rocketgraph/templates/frontend-tls-secret.yaml index 3945383..ec38066 100644 --- a/charts/rocketgraph/templates/frontend-tls-secret.yaml +++ b/charts/rocketgraph/templates/frontend-tls-secret.yaml @@ -1,4 +1,5 @@ {{- if .Values.missionControl.enabled }} +{{- $tlsKeys := include "rocketgraph.frontendTlsKeys" . | fromYaml }} {{- if and (not .Values.frontend.tls.existingSecret) (or .Values.frontend.tls.publicCert .Values.frontend.tls.privateKey .Values.frontend.tls.certChain) }} apiVersion: v1 kind: Secret @@ -10,13 +11,13 @@ metadata: type: Opaque stringData: {{- if .Values.frontend.tls.publicCert }} - public.pem: {{ .Values.frontend.tls.publicCert | quote }} + {{ $tlsKeys.cert | quote }}: {{ .Values.frontend.tls.publicCert | quote }} {{- end }} {{- if .Values.frontend.tls.privateKey }} - private.pem: {{ .Values.frontend.tls.privateKey | quote }} + {{ $tlsKeys.key | quote }}: {{ .Values.frontend.tls.privateKey | quote }} {{- end }} {{- if .Values.frontend.tls.certChain }} - chain.pem: {{ .Values.frontend.tls.certChain | quote }} + {{ $tlsKeys.caCert | quote }}: {{ .Values.frontend.tls.certChain | quote }} {{- end }} {{- end }} diff --git a/charts/rocketgraph/templates/xgt-configmap.yaml b/charts/rocketgraph/templates/xgt-configmap.yaml index e93ae1c..e7bce19 100644 --- a/charts/rocketgraph/templates/xgt-configmap.yaml +++ b/charts/rocketgraph/templates/xgt-configmap.yaml @@ -1,4 +1,5 @@ {{- if and .Values.xgt.enabled (not .Values.xgt.files.existingClaim) (not .Values.xgt.config.existingConfigMap) }} +{{- $oidcCa := include "rocketgraph.xgtOidcCa" . | fromYaml }} apiVersion: v1 kind: ConfigMap metadata: @@ -58,7 +59,7 @@ data: {{- $_ := set $defaults "security.proxy_list" $proxyStr }} {{- end }} {{- $merged := merge (deepCopy (.Values.xgt.extraConfig | default dict)) $defaults }} - {{- if and (index $merged "security.oidc") (or .Values.backend.oidc.caCert .Values.backend.oidc.caCertExistingSecret) }} + {{- if and (index $merged "security.oidc") $oidcCa.enabled }} {{- $oidc := index $merged "security.oidc" }} {{- if not (hasKey $oidc "ca_cert") }} {{- $_ := set $oidc "ca_cert" "/etc/ssl/certs/oidc-ca.pem" }} diff --git a/charts/rocketgraph/templates/xgt-deployment.yaml b/charts/rocketgraph/templates/xgt-deployment.yaml index fb11c70..93967a4 100644 --- a/charts/rocketgraph/templates/xgt-deployment.yaml +++ b/charts/rocketgraph/templates/xgt-deployment.yaml @@ -1,4 +1,6 @@ {{- if .Values.xgt.enabled }} +{{- $tlsKeys := include "rocketgraph.xgtTlsKeys" . | fromYaml }} +{{- $oidcCa := include "rocketgraph.xgtOidcCa" . | fromYaml }} {{- $restricted := and .Values.openshift.enabled (eq .Values.openshift.scc "restricted-v2") }} {{- $files := .Values.xgt.files.existingClaim }} {{- $direct := or $restricted $files }} @@ -26,8 +28,8 @@ spec: {{- if not (or $files .Values.xgt.config.existingConfigMap) }} checksum/config: {{ include (print $.Template.BasePath "/xgt-configmap.yaml") . | sha256sum }} {{- end }} - {{- if or .Values.backend.oidc.caCert .Values.backend.oidc.caCertExistingSecret }} - checksum/oidc-ca-secret: {{ .Values.backend.oidc.caCert | default .Values.backend.oidc.caCertExistingSecret | sha256sum }} + {{- if $oidcCa.enabled }} + checksum/oidc-ca-secret: {{ include "rocketgraph.xgtOidcCa" . | sha256sum }} {{- end }} {{- with .Values.xgt.podAnnotations }} {{- toYaml . | nindent 8 }} @@ -169,7 +171,7 @@ spec: {{- if or .Values.xgt.license.existingSecret .Values.xgt.license.data }} - name: xgt-license mountPath: /license/xgtd.lic - subPath: xgtd.lic + subPath: {{ include "rocketgraph.xgtLicenseKey" . | quote }} readOnly: true {{- end }} {{- if .Values.xgt.ldap.enabled }} @@ -178,10 +180,10 @@ spec: readOnly: true {{- end }} {{- end }} - {{- if or .Values.backend.oidc.caCert .Values.backend.oidc.caCertExistingSecret }} + {{- if $oidcCa.enabled }} - name: oidc-ca-cert mountPath: /etc/ssl/certs/oidc-ca.pem - subPath: oidc-ca.pem + subPath: {{ $oidcCa.key | quote }} readOnly: true {{- end }} {{- with .Values.xgt.extraVolumeMounts }} @@ -222,18 +224,37 @@ spec: - name: xgt-log persistentVolumeClaim: claimName: {{ .Values.xgt.persistence.log.existingClaim | default (printf "%s-xgt-log" .Release.Name) }} - {{- if .Values.xgt.ssl.enabled }} + {{- if and .Values.xgt.ssl.enabled .Values.xgt.ssl.caCertExistingSecret }} + {{- /* Projected so the client CA, kept in a Secret of its own, lands + in /conf/ssl beside the server certificate. */}} + - name: xgt-tls + projected: + sources: + - secret: + name: {{ include "rocketgraph.xgtTlsSecret" . }} + items: + - key: {{ $tlsKeys.cert | quote }} + path: certs/server.cert.pem + - key: {{ $tlsKeys.key | quote }} + path: private/server.key.pem + mode: {{ ternary "0440" "0400" $restricted }} + - secret: + name: {{ .Values.xgt.ssl.caCertExistingSecret | quote }} + items: + - key: {{ $tlsKeys.caCert | quote }} + path: certs/ca-chain.cert.pem + {{- else if .Values.xgt.ssl.enabled }} - name: xgt-tls secret: secretName: {{ include "rocketgraph.xgtTlsSecret" . }} items: - - key: server.cert.pem + - key: {{ $tlsKeys.cert | quote }} path: certs/server.cert.pem - - key: server.key.pem + - key: {{ $tlsKeys.key | quote }} path: private/server.key.pem mode: {{ ternary "0440" "0400" $restricted }} {{- if and .Values.xgt.ssl.mtls (or .Values.xgt.ssl.caCert .Values.xgt.ssl.existingSecret) }} - - key: ca-chain.cert.pem + - key: {{ $tlsKeys.caCert | quote }} path: certs/ca-chain.cert.pem {{- end }} {{- end }} @@ -252,10 +273,10 @@ spec: mode: 0600 {{- end }} {{- end }} - {{- if or .Values.backend.oidc.caCert .Values.backend.oidc.caCertExistingSecret }} + {{- if $oidcCa.enabled }} - name: oidc-ca-cert secret: - secretName: {{ include "rocketgraph.backendOidcCaSecret" . }} + secretName: {{ $oidcCa.name | quote }} {{- end }} {{- with .Values.xgt.extraVolumes }} {{- toYaml . | nindent 8 }} diff --git a/charts/rocketgraph/templates/xgt-license-secret.yaml b/charts/rocketgraph/templates/xgt-license-secret.yaml index 2183967..b88147a 100644 --- a/charts/rocketgraph/templates/xgt-license-secret.yaml +++ b/charts/rocketgraph/templates/xgt-license-secret.yaml @@ -8,5 +8,5 @@ metadata: {{- include "rocketgraph.labels" . | nindent 4 }} type: Opaque stringData: - xgtd.lic: {{ .Values.xgt.license.data | quote }} + {{ include "rocketgraph.xgtLicenseKey" . | quote }}: {{ .Values.xgt.license.data | quote }} {{- end }} diff --git a/charts/rocketgraph/templates/xgt-oidc-secret.yaml b/charts/rocketgraph/templates/xgt-oidc-secret.yaml new file mode 100644 index 0000000..33755a9 --- /dev/null +++ b/charts/rocketgraph/templates/xgt-oidc-secret.yaml @@ -0,0 +1,13 @@ +{{- $ca := include "rocketgraph.xgtOidcCa" . | fromYaml -}} +{{- if and .Values.xgt.enabled $ca.enabled (eq $ca.owner "xgt") (not $ca.existingSecret) }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ $ca.name | quote }} + labels: + app: xgt + {{- include "rocketgraph.labels" . | nindent 4 }} +type: Opaque +stringData: + {{ $ca.key | quote }}: {{ $ca.data | quote }} +{{- end }} diff --git a/charts/rocketgraph/templates/xgt-tls-secret.yaml b/charts/rocketgraph/templates/xgt-tls-secret.yaml index 96e5948..361ef8f 100644 --- a/charts/rocketgraph/templates/xgt-tls-secret.yaml +++ b/charts/rocketgraph/templates/xgt-tls-secret.yaml @@ -1,4 +1,5 @@ {{- if and .Values.xgt.enabled (not .Values.xgt.files.existingClaim) .Values.xgt.ssl.enabled (not .Values.xgt.ssl.existingSecret) (or .Values.xgt.ssl.cert .Values.xgt.ssl.key .Values.xgt.ssl.caCert) }} +{{- $tlsKeys := include "rocketgraph.xgtTlsKeys" . | fromYaml }} apiVersion: v1 kind: Secret metadata: @@ -9,12 +10,12 @@ metadata: type: Opaque stringData: {{- if .Values.xgt.ssl.cert }} - server.cert.pem: {{ .Values.xgt.ssl.cert | quote }} + {{ $tlsKeys.cert | quote }}: {{ .Values.xgt.ssl.cert | quote }} {{- end }} {{- if .Values.xgt.ssl.key }} - server.key.pem: {{ .Values.xgt.ssl.key | quote }} + {{ $tlsKeys.key | quote }}: {{ .Values.xgt.ssl.key | quote }} {{- end }} {{- if .Values.xgt.ssl.caCert }} - ca-chain.cert.pem: {{ .Values.xgt.ssl.caCert | quote }} + {{ $tlsKeys.caCert | quote }}: {{ .Values.xgt.ssl.caCert | quote }} {{- end }} {{- end }} diff --git a/charts/rocketgraph/tests/snapshots/default.yaml b/charts/rocketgraph/tests/snapshots/default.yaml index f48828c..949b609 100644 --- a/charts/rocketgraph/tests/snapshots/default.yaml +++ b/charts/rocketgraph/tests/snapshots/default.yaml @@ -5,7 +5,7 @@ kind: NetworkPolicy metadata: name: test-release-frontend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -31,7 +31,7 @@ kind: NetworkPolicy metadata: name: test-release-backend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -60,7 +60,7 @@ kind: NetworkPolicy metadata: name: test-release-xgt labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -84,7 +84,7 @@ kind: NetworkPolicy metadata: name: test-release-mongodb labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -121,7 +121,7 @@ metadata: name: test-release-xgt-config labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -177,7 +177,7 @@ metadata: name: test-release-mongodb-data labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -197,7 +197,7 @@ metadata: name: test-release-xgt-data labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -217,7 +217,7 @@ metadata: name: test-release-xgt-log labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -237,7 +237,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -261,7 +261,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -287,7 +287,7 @@ metadata: name: test-release-mongodb labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -310,7 +310,7 @@ metadata: name: test-release-xgt labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -334,7 +334,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -413,7 +413,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -473,7 +473,7 @@ metadata: name: test-release-mongodb labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -546,7 +546,7 @@ metadata: name: test-release-xgt labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -565,7 +565,7 @@ spec: app: xgt app.kubernetes.io/instance: test-release annotations: - checksum/config: 290f91d7dc1717af6598d81375db26883184b759d2b07ff3abceeb35af500758 + checksum/config: 6bb7e1d27b1c13562f26a8f28a0e3045f6859565b4a2b1bc6208f724212614af spec: containers: - name: xgt diff --git a/charts/rocketgraph/tests/snapshots/external-mongodb.yaml b/charts/rocketgraph/tests/snapshots/external-mongodb.yaml index c92c274..41e7dab 100644 --- a/charts/rocketgraph/tests/snapshots/external-mongodb.yaml +++ b/charts/rocketgraph/tests/snapshots/external-mongodb.yaml @@ -5,7 +5,7 @@ kind: NetworkPolicy metadata: name: test-release-frontend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -31,7 +31,7 @@ kind: NetworkPolicy metadata: name: test-release-backend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -60,7 +60,7 @@ kind: NetworkPolicy metadata: name: test-release-xgt labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -85,7 +85,7 @@ metadata: name: test-release-xgt-config labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -141,7 +141,7 @@ metadata: name: test-release-xgt-data labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -161,7 +161,7 @@ metadata: name: test-release-xgt-log labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -181,7 +181,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -205,7 +205,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -231,7 +231,7 @@ metadata: name: test-release-xgt labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -255,7 +255,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -334,7 +334,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -394,7 +394,7 @@ metadata: name: test-release-xgt labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -413,7 +413,7 @@ spec: app: xgt app.kubernetes.io/instance: test-release annotations: - checksum/config: 290f91d7dc1717af6598d81375db26883184b759d2b07ff3abceeb35af500758 + checksum/config: 6bb7e1d27b1c13562f26a8f28a0e3045f6859565b4a2b1bc6208f724212614af spec: containers: - name: xgt diff --git a/charts/rocketgraph/tests/snapshots/external-xgt.yaml b/charts/rocketgraph/tests/snapshots/external-xgt.yaml index 6cc6773..8b5e45a 100644 --- a/charts/rocketgraph/tests/snapshots/external-xgt.yaml +++ b/charts/rocketgraph/tests/snapshots/external-xgt.yaml @@ -5,7 +5,7 @@ kind: NetworkPolicy metadata: name: test-release-frontend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -31,7 +31,7 @@ kind: NetworkPolicy metadata: name: test-release-backend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -60,7 +60,7 @@ kind: NetworkPolicy metadata: name: test-release-mongodb labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -97,7 +97,7 @@ metadata: name: test-release-mongodb-data labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -117,7 +117,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -141,7 +141,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -167,7 +167,7 @@ metadata: name: test-release-mongodb labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -190,7 +190,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -269,7 +269,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -329,7 +329,7 @@ metadata: name: test-release-mongodb labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm diff --git a/charts/rocketgraph/tests/snapshots/ldap.yaml b/charts/rocketgraph/tests/snapshots/ldap.yaml index be1cc83..a3e8ee7 100644 --- a/charts/rocketgraph/tests/snapshots/ldap.yaml +++ b/charts/rocketgraph/tests/snapshots/ldap.yaml @@ -5,7 +5,7 @@ kind: NetworkPolicy metadata: name: test-release-frontend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -31,7 +31,7 @@ kind: NetworkPolicy metadata: name: test-release-backend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -60,7 +60,7 @@ kind: NetworkPolicy metadata: name: test-release-xgt labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -84,7 +84,7 @@ kind: NetworkPolicy metadata: name: test-release-mongodb labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -121,7 +121,7 @@ metadata: name: test-release-xgt-ldap labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -152,7 +152,7 @@ metadata: name: test-release-xgt-config labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -208,7 +208,7 @@ metadata: name: test-release-mongodb-data labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -228,7 +228,7 @@ metadata: name: test-release-xgt-data labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -248,7 +248,7 @@ metadata: name: test-release-xgt-log labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -268,7 +268,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -292,7 +292,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -318,7 +318,7 @@ metadata: name: test-release-mongodb labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -341,7 +341,7 @@ metadata: name: test-release-xgt labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -365,7 +365,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -444,7 +444,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -504,7 +504,7 @@ metadata: name: test-release-mongodb labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -577,7 +577,7 @@ metadata: name: test-release-xgt labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -596,7 +596,7 @@ spec: app: xgt app.kubernetes.io/instance: test-release annotations: - checksum/config: 290f91d7dc1717af6598d81375db26883184b759d2b07ff3abceeb35af500758 + checksum/config: 6bb7e1d27b1c13562f26a8f28a0e3045f6859565b4a2b1bc6208f724212614af spec: containers: - name: xgt diff --git a/charts/rocketgraph/tests/snapshots/openshift.yaml b/charts/rocketgraph/tests/snapshots/openshift.yaml index 2a78a51..c6c496a 100644 --- a/charts/rocketgraph/tests/snapshots/openshift.yaml +++ b/charts/rocketgraph/tests/snapshots/openshift.yaml @@ -5,7 +5,7 @@ kind: NetworkPolicy metadata: name: test-release-frontend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -31,7 +31,7 @@ kind: NetworkPolicy metadata: name: test-release-backend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -60,7 +60,7 @@ kind: NetworkPolicy metadata: name: test-release-xgt labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -84,7 +84,7 @@ kind: NetworkPolicy metadata: name: test-release-mongodb labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -120,7 +120,7 @@ kind: ServiceAccount metadata: name: test-release-rocketgraph labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -134,7 +134,7 @@ metadata: name: test-release-xgt-config labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -190,7 +190,7 @@ metadata: name: test-release-mongodb-data labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -210,7 +210,7 @@ metadata: name: test-release-xgt-data labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -230,7 +230,7 @@ metadata: name: test-release-xgt-log labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -249,7 +249,7 @@ kind: ClusterRoleBinding metadata: name: test-release-rocketgraph-anyuid-default labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -271,7 +271,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -295,7 +295,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -321,7 +321,7 @@ metadata: name: test-release-mongodb labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -344,7 +344,7 @@ metadata: name: test-release-xgt labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -368,7 +368,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -448,7 +448,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -509,7 +509,7 @@ metadata: name: test-release-mongodb labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -583,7 +583,7 @@ metadata: name: test-release-xgt labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -602,7 +602,7 @@ spec: app: xgt app.kubernetes.io/instance: test-release annotations: - checksum/config: 290f91d7dc1717af6598d81375db26883184b759d2b07ff3abceeb35af500758 + checksum/config: 6bb7e1d27b1c13562f26a8f28a0e3045f6859565b4a2b1bc6208f724212614af spec: serviceAccountName: test-release-rocketgraph containers: diff --git a/charts/rocketgraph/tests/snapshots/tls.yaml b/charts/rocketgraph/tests/snapshots/tls.yaml index 4ae978f..ff110bc 100644 --- a/charts/rocketgraph/tests/snapshots/tls.yaml +++ b/charts/rocketgraph/tests/snapshots/tls.yaml @@ -5,7 +5,7 @@ kind: NetworkPolicy metadata: name: test-release-frontend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -31,7 +31,7 @@ kind: NetworkPolicy metadata: name: test-release-backend labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -60,7 +60,7 @@ kind: NetworkPolicy metadata: name: test-release-xgt labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -84,7 +84,7 @@ kind: NetworkPolicy metadata: name: test-release-mongodb labels: - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -121,16 +121,16 @@ metadata: name: test-release-backend-tls labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: test-release type: Opaque stringData: - xgt-server.pem: "test-ca" - proxy-client-cert.pem: "test-client-cert" - proxy-client-key.pem: "test-client-key" + "xgt-server.pem": "test-ca" + "proxy-client-cert.pem": "test-client-cert" + "proxy-client-key.pem": "test-client-key" --- # Source: rocketgraph/templates/frontend-tls-secret.yaml @@ -140,15 +140,15 @@ metadata: name: test-release-frontend-tls labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: test-release type: Opaque stringData: - public.pem: "test-cert" - private.pem: "test-key" + "public.pem": "test-cert" + "private.pem": "test-key" --- # Source: rocketgraph/templates/xgt-tls-secret.yaml @@ -158,15 +158,15 @@ metadata: name: test-release-xgt-tls labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: test-release type: Opaque stringData: - server.cert.pem: "test-xgt-cert" - server.key.pem: "test-xgt-key" + "server.cert.pem": "test-xgt-cert" + "server.key.pem": "test-xgt-key" --- # Source: rocketgraph/templates/xgt-configmap.yaml @@ -176,7 +176,7 @@ metadata: name: test-release-xgt-config labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -232,7 +232,7 @@ metadata: name: test-release-mongodb-data labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -252,7 +252,7 @@ metadata: name: test-release-xgt-data labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -272,7 +272,7 @@ metadata: name: test-release-xgt-log labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -292,7 +292,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -316,7 +316,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -342,7 +342,7 @@ metadata: name: test-release-mongodb labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -365,7 +365,7 @@ metadata: name: test-release-xgt labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -389,7 +389,7 @@ metadata: name: test-release-backend labels: app: backend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -461,7 +461,7 @@ spec: volumeMounts: - name: tls-certs mountPath: /etc/ssl/certs/xgt-server.pem - subPath: xgt-server.pem + subPath: "xgt-server.pem" readOnly: true restartPolicy: Always volumes: @@ -477,7 +477,7 @@ metadata: name: test-release-frontend labels: app: frontend - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -530,11 +530,11 @@ spec: volumeMounts: - name: tls-certs mountPath: /etc/ssl/certs/td.pem - subPath: public.pem + subPath: "public.pem" readOnly: true - name: tls-certs mountPath: /etc/ssl/private/td.pem - subPath: private.pem + subPath: "private.pem" readOnly: true restartPolicy: Always volumes: @@ -550,7 +550,7 @@ metadata: name: test-release-mongodb labels: app: mongodb - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -623,7 +623,7 @@ metadata: name: test-release-xgt labels: app: xgt - helm.sh/chart: rocketgraph-0.4.0 + helm.sh/chart: rocketgraph-0.5.0 app.kubernetes.io/name: rocketgraph app.kubernetes.io/version: "2.7.0" app.kubernetes.io/managed-by: Helm @@ -642,7 +642,7 @@ spec: app: xgt app.kubernetes.io/instance: test-release annotations: - checksum/config: 019e668f8163b2c54d737b72aa245ba6914971d0e482e5de0d15bde056ad906e + checksum/config: 88defb4f4b330c19a46db120505f0571ba990747fd409f023571c04c655a4cd1 spec: containers: - name: xgt @@ -707,8 +707,8 @@ spec: secret: secretName: test-release-xgt-tls items: - - key: server.cert.pem + - key: "server.cert.pem" path: certs/server.cert.pem - - key: server.key.pem + - key: "server.key.pem" path: private/server.key.pem mode: 0400 diff --git a/charts/rocketgraph/tests/test_backend_tls_keys.py b/charts/rocketgraph/tests/test_backend_tls_keys.py new file mode 100644 index 0000000..ec21932 --- /dev/null +++ b/charts/rocketgraph/tests/test_backend_tls_keys.py @@ -0,0 +1,100 @@ +"""Backend TLS key mapping preserves application paths and existing defaults.""" +import unittest + +from test_render import component, render + + +class BackendTlsKeysTests(unittest.TestCase): + def profiles(self): + return [{}, {'openshift': {'enabled': True, 'scc': 'restricted-v2'}, + 'fips': {'enabled': True}}] + + def values(self, profile, tls): + return dict(profile, xgt={'license': {'existingSecret': 'license'}}, + backend={'tls': tls}) + + def mounts(self, objects): + pod = component(objects, 'Deployment', 'backend')['spec']['template']['spec'] + return {m['mountPath']: m for m in pod['containers'][0]['volumeMounts']}, pod + + def test_custom_secret_keys_keep_application_paths_and_mtls_environment(self): + for profile in self.profiles(): + for mtls in (False, True): + with self.subTest(profile=profile, mtls=mtls): + values = self.values(profile, {'existingSecret': 'custom-client', + 'mtls': mtls, 'secretKeys': { + 'cert': 'tls.crt', 'key': 'tls.key', 'caCert': 'ca.crt'}}) + objects = render(values) + mounts, pod = self.mounts(objects) + self.assertEqual(mounts['/etc/ssl/certs/xgt-server.pem']['subPath'], 'ca.crt') + paths = {'/etc/ssl/certs/proxy-client-cert.pem': 'tls.crt', + '/etc/ssl/private/proxy-client-key.pem': 'tls.key'} + for path, key in paths.items(): + if mtls: + self.assertEqual(mounts[path]['subPath'], key) + self.assertTrue(mounts[path]['readOnly']) + else: + self.assertNotIn(path, mounts) + tls = next(v for v in pod['volumes'] if v['name'] == 'tls-certs') + self.assertEqual(tls['secret']['secretName'], 'custom-client') + self.assertFalse(any(o['kind'] == 'Secret' and + o['metadata']['labels'].get('app') == 'backend' for o in objects)) + env = {e['name']: e.get('value') for e in pod['containers'][0]['env']} + if mtls: + self.assertEqual(env['MC_SSL_PROXY_PUBLIC_CERT'], + '/etc/ssl/certs/proxy-client-cert.pem') + self.assertEqual(env['MC_SSL_PROXY_PRIVATE_KEY'], + '/etc/ssl/private/proxy-client-key.pem') + else: + self.assertNotIn('MC_SSL_PROXY_PUBLIC_CERT', env) + + def test_configmap_ca_and_secret_client_credentials_are_independent(self): + for profile in self.profiles(): + values = self.values(profile, {'existingSecret': 'client', 'mtls': True, + 'xgtServerCertConfigMap': 'service-ca', + 'xgtServerCertConfigMapKey': 'custom-service-ca.pem', + 'secretKeys': {'cert': 'tls.crt', 'key': 'tls.key', 'caCert': 'unused.pem'}}) + mounts, pod = self.mounts(render(values)) + self.assertEqual(mounts['/etc/ssl/certs/xgt-server.pem'], { + 'name': 'xgt-server-ca', 'mountPath': '/etc/ssl/certs/xgt-server.pem', + 'subPath': 'xgt-server.pem', 'readOnly': True}) + self.assertEqual(mounts['/etc/ssl/certs/proxy-client-cert.pem']['subPath'], 'tls.crt') + ca = next(v for v in pod['volumes'] if v['name'] == 'xgt-server-ca') + self.assertEqual(ca['configMap']['items'], [ + {'key': 'custom-service-ca.pem', 'path': 'xgt-server.pem'}]) + + def test_generated_secret_and_mounts_use_matching_keys(self): + for keys in ({'cert': 'tls.crt', 'key': 'tls.key', 'caCert': 'ca.crt'}, + {'cert': 'true', 'key': '123', 'caCert': 'null'}): + values = self.values({}, {'mtls': True, 'proxyClientCert': 'client', + 'proxyClientKey': 'private', 'xgtServerCert': 'server-ca', 'secretKeys': keys}) + objects = render(values) + secret = component(objects, 'Secret', 'backend') + self.assertEqual(secret['stringData'], { + keys['cert']: 'client', keys['key']: 'private', keys['caCert']: 'server-ca'}) + mounts, _ = self.mounts(objects) + self.assertEqual(mounts['/etc/ssl/certs/xgt-server.pem']['subPath'], keys['caCert']) + self.assertEqual(mounts['/etc/ssl/certs/proxy-client-cert.pem']['subPath'], keys['cert']) + self.assertEqual(mounts['/etc/ssl/private/proxy-client-key.pem']['subPath'], keys['key']) + + def test_legacy_defaults_and_partial_overrides(self): + for overrides in ({}, {'cert': 'custom-client.pem'}): + values = self.values({}, {'mtls': True, 'proxyClientCert': 'client', + 'proxyClientKey': 'private', 'xgtServerCert': 'ca', 'secretKeys': overrides}) + objects = render(values) + cert = overrides.get('cert', 'proxy-client-cert.pem') + secret = component(objects, 'Secret', 'backend') + self.assertEqual(secret['stringData'], { + cert: 'client', 'proxy-client-key.pem': 'private', 'xgt-server.pem': 'ca'}) + mounts, _ = self.mounts(objects) + self.assertEqual(mounts['/etc/ssl/certs/proxy-client-cert.pem']['subPath'], cert) + + def test_invalid_secret_keys_are_rejected(self): + for field in ('cert', 'key', 'caCert'): + for key in ('', 'nested/file.pem', 'bad key', 'x' * 254): + values = self.values({}, {'secretKeys': {field: key}}) + self.assertIn('secretKeys/' + field, render(values, fails=True)) + + +if __name__ == '__main__': + unittest.main() diff --git a/charts/rocketgraph/tests/test_render.py b/charts/rocketgraph/tests/test_render.py index 9ffdae3..39c2e5e 100644 --- a/charts/rocketgraph/tests/test_render.py +++ b/charts/rocketgraph/tests/test_render.py @@ -487,5 +487,110 @@ def test_rejects_fixed_ids_and_elevated_contexts_on_each_component(self): self.assertTrue(render(values)) +class ServingCertTests(unittest.TestCase): + """Certificates whose Secret and ConfigMap key names the chart does not choose, + such as OpenShift service serving certificates.""" + + def xgt_tls(self, objects): + pod = component(objects, 'Deployment', 'xgt')['spec']['template']['spec'] + return next(v for v in pod['volumes'] if v['name'] == 'xgt-tls')['secret'] + + def backend_pod(self, objects): + return component(objects, 'Deployment', 'backend')['spec']['template']['spec'] + + def test_xgt_existing_secret_with_custom_key_names(self): + objects = render({'xgt': {'ssl': { + 'enabled': True, 'existingSecret': 'xgt-serving', 'mtls': True, + 'secretKeys': {'cert': 'tls.crt', 'key': 'tls.key', 'caCert': 'ca.crt'}}}}) + secret = self.xgt_tls(objects) + self.assertEqual(secret['secretName'], 'xgt-serving') + self.assertEqual({i['key']: i['path'] for i in secret['items']}, { + 'tls.crt': 'certs/server.cert.pem', + 'tls.key': 'private/server.key.pem', + 'ca.crt': 'certs/ca-chain.cert.pem'}) + + def test_xgt_generated_secret_uses_the_same_key_names(self): + objects = render({'xgt': {'ssl': { + 'enabled': True, 'cert': 'CERT', 'key': 'KEY', + 'secretKeys': {'cert': 'tls.crt', 'key': 'tls.key'}}}}) + generated = component([o for o in objects if o['kind'] == 'Secret'], 'Secret', 'xgt') + self.assertEqual(generated['stringData'], {'tls.crt': 'CERT', 'tls.key': 'KEY'}) + self.assertEqual({i['key'] for i in self.xgt_tls(objects)['items']}, + {'tls.crt', 'tls.key'}) + + def test_backend_reads_xgt_ca_from_configmap(self): + objects = render({'backend': {'tls': { + 'xgtServerCertConfigMap': 'xgt-service-ca'}}}) + pod = self.backend_pod(objects) + volume = next(v for v in pod['volumes'] if v['name'] == 'xgt-server-ca') + self.assertEqual(volume['configMap'], { + 'name': 'xgt-service-ca', + 'items': [{'key': 'service-ca.crt', 'path': 'xgt-server.pem'}]}) + mounts = [m for m in pod['containers'][0]['volumeMounts'] + if m['mountPath'] == '/etc/ssl/certs/xgt-server.pem'] + self.assertEqual(mounts, [{'name': 'xgt-server-ca', + 'mountPath': '/etc/ssl/certs/xgt-server.pem', + 'subPath': 'xgt-server.pem', 'readOnly': True}]) + self.assertNotIn('tls-certs', {v['name'] for v in pod['volumes']}) + + def test_backend_configmap_ca_with_client_cert_from_secret(self): + objects = render({'backend': {'tls': { + 'existingSecret': 'backend-client', 'mtls': True, + 'xgtServerCertConfigMap': 'xgt-service-ca', + 'xgtServerCertConfigMapKey': 'ca-bundle.crt'}}}) + pod = self.backend_pod(objects) + mounts = {m['mountPath']: m['name'] for m in pod['containers'][0]['volumeMounts']} + self.assertEqual(mounts['/etc/ssl/certs/xgt-server.pem'], 'xgt-server-ca') + self.assertEqual(mounts['/etc/ssl/certs/proxy-client-cert.pem'], 'tls-certs') + self.assertEqual(mounts['/etc/ssl/private/proxy-client-key.pem'], 'tls-certs') + volume = next(v for v in pod['volumes'] if v['name'] == 'xgt-server-ca') + self.assertEqual(volume['configMap']['items'][0]['key'], 'ca-bundle.crt') + + def test_backend_rejects_two_xgt_ca_sources(self): + self.assertIn('xgtServerCertConfigMap', render({'backend': {'tls': { + 'xgtServerCert': 'CA', 'xgtServerCertConfigMap': 'xgt-service-ca'}}}, + fails=True)) + + def xgt_tls_sources(self, objects): + pod = component(objects, 'Deployment', 'xgt')['spec']['template']['spec'] + volume = next(v for v in pod['volumes'] if v['name'] == 'xgt-tls') + return [source['secret'] for source in volume['projected']['sources']] + + def test_xgt_client_ca_from_separate_secret(self): + objects = render({'xgt': {'ssl': { + 'enabled': True, 'existingSecret': 'xgt-serving', 'mtls': True, + 'caCertExistingSecret': 'client-ca', + 'secretKeys': {'cert': 'tls.crt', 'key': 'tls.key', 'caCert': 'ca.crt'}}}}) + server, client = self.xgt_tls_sources(objects) + self.assertEqual(server['name'], 'xgt-serving') + self.assertEqual({i['key']: i['path'] for i in server['items']}, { + 'tls.crt': 'certs/server.cert.pem', 'tls.key': 'private/server.key.pem'}) + self.assertEqual(client, {'name': 'client-ca', 'items': [ + {'key': 'ca.crt', 'path': 'certs/ca-chain.cert.pem'}]}) + + def test_xgt_client_ca_secret_with_inline_server_cert(self): + objects = render({'xgt': {'ssl': { + 'enabled': True, 'cert': 'CERT', 'key': 'KEY', 'mtls': True, + 'caCertExistingSecret': 'client-ca'}}}) + server, client = self.xgt_tls_sources(objects) + self.assertEqual(server['name'], 'test-xgt-tls') + self.assertEqual(client['name'], 'client-ca') + generated = component([o for o in objects if o['kind'] == 'Secret'], 'Secret', 'xgt') + self.assertEqual(set(generated['stringData']), {'server.cert.pem', 'server.key.pem'}) + + def test_xgt_client_ca_secret_rejected_where_unused_or_duplicated(self): + cases = [ + ({'ssl': {'enabled': True, 'existingSecret': 's', 'caCertExistingSecret': 'ca'}}, + 'only used when'), + ({'ssl': {'enabled': True, 'cert': 'C', 'key': 'K', 'mtls': True, + 'caCert': 'CA', 'caCertExistingSecret': 'ca'}}, + 'one source for the client CA'), + ({'files': {'existingClaim': 'files'}, 'ssl': {'caCertExistingSecret': 'ca'}}, + 'existingClaim supplies license and TLS files')] + for xgt, message in cases: + with self.subTest(xgt=xgt): + self.assertIn(message, render({'xgt': xgt}, fails=True)) + + if __name__ == '__main__': unittest.main() diff --git a/charts/rocketgraph/tests/test_secret_source_keys.py b/charts/rocketgraph/tests/test_secret_source_keys.py new file mode 100644 index 0000000..1a6331a --- /dev/null +++ b/charts/rocketgraph/tests/test_secret_source_keys.py @@ -0,0 +1,260 @@ +"""Secret source mappings, legacy upgrades and ConfigMap scalar names.""" +import json +from pathlib import Path +import shutil +import tempfile +import unittest + +import yaml + +from test_render import CHART, component, render + +class SecretSourceKeyTests(unittest.TestCase): + def test_configmap_names_and_keys_remain_strings(self) -> None: + for name, key in [("true", "123"), ("123", "false")]: + with self.subTest(name = name, key = key): + objects = render({ "backend": { "tls": { + "xgtServerCertConfigMap": name, + "xgtServerCertConfigMapKey": key } } }) + pod = component(objects, "Deployment", "backend")["spec"]["template"] + volume = next(v for v in pod["spec"]["volumes"] + if v["name"] == "xgt-server-ca") + self.assertEqual(volume["configMap"]["name"], name) + self.assertEqual(volume["configMap"]["items"][0]["key"], key) + + def values(self, inline: bool) -> dict: + return { + "xgt": { + "license": { "data": "license" } if inline else + { "existingSecret": "customer-license" }, + "extraConfig": { "security.oidc": { + "issuer": "https://idp.example.com", "audience": "xgt" } } + }, + "backend": { "oidc": { + "clientSecret": "password", "caCert": "ca" } if inline else { + "existingSecret": "customer-oidc", + "caCertExistingSecret": "customer-ca" } } + } + + def assert_sources(self, objects: list, keys: dict, inline: bool, + mc: bool = True) -> None: + for app in (["backend", "xgt"] if mc else ["xgt"]): + spec = component(objects, "Deployment", app)["spec"]["template"]["spec"] + mounts = spec["containers"][0]["volumeMounts"] + ca = next(m for m in mounts if m["name"] == "oidc-ca-cert") + self.assertEqual(ca["subPath"], keys["caCert"]) + self.assertEqual(ca["mountPath"], "/etc/ssl/certs/oidc-ca.pem") + self.assertTrue(ca["readOnly"]) + if app == "xgt": + license_mount = next(m for m in mounts if m["name"] == "xgt-license") + self.assertEqual(license_mount["subPath"], keys["license"]) + self.assertEqual(license_mount["mountPath"], "/license/xgtd.lic") + self.assertTrue(license_mount["readOnly"]) + else: + env = spec["containers"][0]["env"] + secret = next(e for e in env if e["name"] == "MC_OIDC_CLIENT_SECRET") + ref = secret["valueFrom"]["secretKeyRef"] + self.assertEqual(ref["key"], keys["clientSecret"]) + self.assertEqual(ref["name"], + "test-backend-oidc" if inline else "customer-oidc") + conf = json.loads(component(objects, "ConfigMap", "xgt") + ["data"]["xgtd.conf"]) + self.assertEqual(conf["security.oidc"]["ca_cert"], + "/etc/ssl/certs/oidc-ca.pem") + secrets = { o["metadata"]["name"]: o["stringData"] + for o in objects if o["kind"] == "Secret" } + if inline: + self.assertEqual(secrets["test-xgt-license"], + { keys["license"]: "license" }) + self.assertEqual(secrets["test-backend-oidc-ca"], + { keys["caCert"]: "ca" }) + if mc: + self.assertEqual(secrets["test-backend-oidc"], + { keys["clientSecret"]: "password" }) + else: + self.assertNotIn("test-backend-oidc", secrets) + else: + self.assertEqual(secrets, {}) + + def test_custom_keys_preserve_application_paths_and_env_names(self) -> None: + keys = { "license": "123", "clientSecret": "false", "caCert": "true" } + for inline in [False, True]: + for restricted in [False, True]: + with self.subTest(inline = inline, restricted = restricted): + values = self.values(inline) + values["xgt"]["license"]["secretKey"] = keys["license"] + values["backend"]["oidc"]["secretKeys"] = { + k: keys[k] for k in ["clientSecret", "caCert"] } + if restricted: + values["openshift"] = { + "enabled": True, "scc": "restricted-v2" } + values["fips"] = { "enabled": True } + self.assert_sources(render(values), keys, inline) + + def test_xgt_only_can_use_a_custom_oidc_ca_key(self) -> None: + values = self.values(True) + values["missionControl"] = { "enabled": False } + values["mongodb"] = { "enabled": False } + values["backend"]["oidc"]["secretKeys"] = { "caCert": "root-ca.pem" } + keys = { "license": "xgtd.lic", "clientSecret": "MC_OIDC_CLIENT_SECRET", + "caCert": "root-ca.pem" } + self.assert_sources(render(values), keys, True, mc = False) + + def test_reused_values_keep_defaults_and_allow_partial_overrides(self) -> None: + with tempfile.TemporaryDirectory() as directory: + chart = Path(directory) / "rocketgraph" + shutil.copytree(CHART, chart) + path = chart / "values.yaml" + defaults = yaml.safe_load(path.read_text()) + # Normal coalescing otherwise hides missing --reuse-values fallbacks. + defaults["xgt"]["license"].pop("secretKey") + defaults["backend"]["oidc"].pop("secretKeys") + path.write_text(yaml.safe_dump(defaults)) + for inline in [False, True]: + for partial in [False, True]: + with self.subTest(inline = inline, partial = partial): + values = self.values(inline) + keys = { "license": "xgtd.lic", + "clientSecret": "MC_OIDC_CLIENT_SECRET", + "caCert": "oidc-ca.pem" } + if partial: + keys["clientSecret"] = "client-password" + values["backend"]["oidc"]["secretKeys"] = { + "clientSecret": keys["clientSecret"] } + self.assert_sources(render(values, chart = chart), keys, inline) + + def test_invalid_source_keys_are_rejected(self) -> None: + for field in ["license", "clientSecret", "caCert"]: + for key in ["", ".", "..data", "bad/key", "a" * 254]: + with self.subTest(field = field, key = key): + values = self.values(True) + if field == "license": + values["xgt"]["license"]["secretKey"] = key + path = "secretKey" + else: + values["backend"]["oidc"]["secretKeys"] = { field: key } + path = "secretKeys/" + field + self.assertIn(path, render(values, fails = True)) + +class XgtOidcCaTests(unittest.TestCase): + def values(self) -> dict: + return { + "missionControl": { "enabled": False }, + "mongodb": { "enabled": False }, + "xgt": { "extraConfig": { "security.oidc": { + "issuer": "https://keycloak.example.com", "audience": "xgt" } } } + } + + def assert_ca(self, objects: list, app: str, name: str, key: str) -> None: + spec = component(objects, "Deployment", app)["spec"]["template"]["spec"] + volume = next(v for v in spec["volumes"] if v["name"] == "oidc-ca-cert") + self.assertEqual(volume["secret"]["secretName"], name) + mount = next(m for m in spec["containers"][0]["volumeMounts"] + if m["name"] == "oidc-ca-cert") + self.assertEqual(mount["subPath"], key) + self.assertEqual(mount["mountPath"], "/etc/ssl/certs/oidc-ca.pem") + self.assertTrue(mount["readOnly"]) + + def test_xgt_only_ca_is_mounted_and_automatically_configured(self) -> None: + for inline in [False, True]: + values = self.values() + values["xgt"]["oidc"] = { "caCert": "ca" } if inline else { + "caCertExistingSecret": "true" } + values["xgt"]["oidc"]["secretKeys"] = { "caCert": "123" } + if inline: + values["openshift"] = { "enabled": True, "scc": "restricted-v2" } + values["fips"] = { "enabled": True } + values["xgt"]["license"] = { "existingSecret": "license" } + objects = render(values) + name = "test-xgt-oidc-ca" if inline else "true" + self.assert_ca(objects, "xgt", name, "123") + conf = json.loads(component(objects, "ConfigMap", "xgt") + ["data"]["xgtd.conf"]) + self.assertEqual(conf["security.oidc"]["ca_cert"], + "/etc/ssl/certs/oidc-ca.pem") + secrets = [o for o in objects if o["kind"] == "Secret"] + if inline: + self.assertEqual(secrets[0]["stringData"], { "123": "ca" }) + self.assertEqual(len(secrets), int(inline)) + + def test_xgt_and_backend_can_trust_different_ca_bundles(self) -> None: + for inline in [False, True]: + values = self.values() + values["missionControl"]["enabled"] = True + values["mongodb"]["enabled"] = True + values["xgt"]["oidc"] = { "caCert": "xgt-ca" } if inline else { + "caCertExistingSecret": "xgt-issuer-ca" } + values["xgt"]["oidc"]["secretKeys"] = { "caCert": "root.crt" } + values["backend"] = { "oidc": { "caCert": "backend-ca" } if inline + else { "caCertExistingSecret": "backend-ca" } } + values["backend"]["oidc"]["secretKeys"] = { "caCert": "ca.crt" } + objects = render(values) + self.assert_ca(objects, "xgt", + "test-xgt-oidc-ca" if inline else "xgt-issuer-ca", + "root.crt") + self.assert_ca(objects, "backend", + "test-backend-oidc-ca" if inline else "backend-ca", + "ca.crt") + if inline: + secrets = { o["metadata"]["name"]: o["stringData"] + for o in objects if o["kind"] == "Secret" } + self.assertEqual(secrets["test-xgt-oidc-ca"], { "root.crt": "xgt-ca" }) + self.assertEqual(secrets["test-backend-oidc-ca"], + { "ca.crt": "backend-ca" }) + + def test_external_config_and_explicit_ca_path_are_preserved(self) -> None: + values = self.values() + values["xgt"]["oidc"] = { "caCertExistingSecret": "keycloak-ca" } + values["xgt"]["extraConfig"]["security.oidc"]["ca_cert"] = \ + "/conf/company-ca.pem" + objects = render(values) + conf = json.loads(component(objects, "ConfigMap", "xgt") + ["data"]["xgtd.conf"]) + self.assertEqual(conf["security.oidc"]["ca_cert"], "/conf/company-ca.pem") + values["xgt"].pop("extraConfig") + values["xgt"]["config"] = { "existingConfigMap": "mounted-config" } + objects = render(values) + self.assert_ca(objects, "xgt", "keycloak-ca", "oidc-ca.pem") + self.assertFalse(any(o["kind"] == "ConfigMap" and + "xgtd.conf" in o.get("data", {}) for o in objects)) + values["xgt"].pop("config") + values["xgt"]["files"] = { "existingClaim": "all-files" } + self.assert_ca(render(values), "xgt", "keycloak-ca", "oidc-ca.pem") + + def test_ca_secret_is_not_created_for_a_disabled_xgt(self) -> None: + values = self.values() + values["xgt"].update(enabled = False, oidc = { "caCert": "ca" }) + objects = render(values) + self.assertFalse(any(o["kind"] == "Secret" for o in objects)) + + def test_existing_xgt_secret_takes_precedence_over_inline_ca(self) -> None: + values = self.values() + values["xgt"]["oidc"] = { + "caCertExistingSecret": "keycloak-ca", "caCert": "ignored" } + objects = render(values) + self.assert_ca(objects, "xgt", "keycloak-ca", "oidc-ca.pem") + self.assertFalse(any(o["kind"] == "Secret" for o in objects)) + + def test_legacy_backend_fallback_works_without_the_new_defaults(self) -> None: + with tempfile.TemporaryDirectory() as directory: + chart = Path(directory) / "rocketgraph" + shutil.copytree(CHART, chart) + path = chart / "values.yaml" + defaults = yaml.safe_load(path.read_text()) + defaults["xgt"].pop("oidc") + path.write_text(yaml.safe_dump(defaults)) + values = self.values() + values["backend"] = { "oidc": { + "caCertExistingSecret": "legacy-ca", + "secretKeys": { "caCert": "legacy.pem" } } } + objects = render(values, chart = chart) + self.assert_ca(objects, "xgt", "legacy-ca", "legacy.pem") + + def test_invalid_xgt_ca_key_is_rejected(self) -> None: + values = self.values() + values["xgt"]["oidc"] = { + "caCert": "ca", "secretKeys": { "caCert": "..data" } } + self.assertIn("secretKeys/caCert", render(values, fails = True)) + +if __name__ == "__main__": + unittest.main() diff --git a/charts/rocketgraph/tests/test_tls_secrets.py b/charts/rocketgraph/tests/test_tls_secrets.py new file mode 100644 index 0000000..52394f1 --- /dev/null +++ b/charts/rocketgraph/tests/test_tls_secrets.py @@ -0,0 +1,186 @@ +"""TLS Secret compatibility checks for legacy, Kubernetes and OpenShift keys.""" +import json +import unittest + +import yaml + +from test_render import CHART, component, render + + +class TlsSecretTests(unittest.TestCase): + def profiles(self): + return [{}, {'openshift': {'enabled': True, 'scc': 'restricted-v2'}, + 'fips': {'enabled': True}}] + + def values(self, profile): + return dict(profile, xgt={'license': {'existingSecret': 'license'}}) + + def volume(self, objects, app, name): + pod = component(objects, 'Deployment', app)['spec']['template']['spec'] + return next(v for v in pod['volumes'] if v['name'] == name), pod + + def test_standard_secret_keys_keep_fixed_container_paths(self): + for profile in self.profiles(): + with self.subTest(profile=profile): + values = self.values(profile) + values['xgt']['ssl'] = {'enabled': True, 'existingSecret': 'xgt-serving', + 'secretKeys': {'cert': 'tls.crt', 'key': 'tls.key'}} + values['xgt']['service'] = {'annotations': { + 'service.beta.openshift.io/serving-cert-secret-name': 'xgt-serving'}} + values['frontend'] = {'tls': {'existingSecret': 'frontend-serving', + 'secretKeys': {'cert': 'tls.crt', 'key': 'tls.key'}}} + objects = render(values) + volume, pod = self.volume(objects, 'xgt', 'xgt-tls') + items = volume['secret']['items'] + self.assertEqual({i['key']: i['path'] for i in items}, + {'tls.crt': 'certs/server.cert.pem', + 'tls.key': 'private/server.key.pem'}) + self.assertEqual(items[1]['mode'], 0o440 if profile else 0o400) + self.assertEqual(volume['secret']['secretName'], 'xgt-serving') + self.assertEqual(json.loads(component(objects, 'ConfigMap', 'xgt') + ['data']['xgtd.conf'])['system.usessl'], 'true') + self.assertEqual(component(objects, 'Service', 'xgt')['metadata']['annotations'], + values['xgt']['service']['annotations']) + frontend, pod = self.volume(objects, 'frontend', 'tls-certs') + self.assertEqual(frontend['secret']['secretName'], 'frontend-serving') + mounts = {m['mountPath']: m for m in pod['containers'][0]['volumeMounts']} + self.assertEqual(mounts['/etc/ssl/certs/td.pem']['subPath'], 'tls.crt') + self.assertEqual(mounts['/etc/ssl/private/td.pem']['subPath'], 'tls.key') + self.assertFalse(any(o['kind'] == 'Secret' and o['metadata']['labels'] + .get('app') in ['frontend', 'xgt'] for o in objects)) + + def test_separate_client_ca_supports_external_and_inline_server_certificates(self): + for profile in self.profiles(): + for external in [True, False]: + with self.subTest(profile=profile, external=external): + values = self.values(profile) + ssl = {'enabled': True, 'mtls': True, 'caCertExistingSecret': 'clients-ca', + 'secretKeys': {'caCert': 'client-ca.pem'}} + ssl.update({'existingSecret': 'serving', + 'secretKeys': {'cert': 'tls.crt', 'key': 'tls.key', + 'caCert': 'client-ca.pem'}} + if external else {'cert': 'server', 'key': 'private'}) + values['xgt']['ssl'] = ssl + objects = render(values) + volume, _ = self.volume(objects, 'xgt', 'xgt-tls') + sources = volume['projected']['sources'] + self.assertEqual(len(sources), 2) + cert, ca = [s['secret'] for s in sources] + self.assertEqual(ca, {'name': 'clients-ca', 'items': [ + {'key': 'client-ca.pem', 'path': 'certs/ca-chain.cert.pem'}]}) + self.assertEqual(cert['name'], 'serving' if external else 'test-xgt-tls') + self.assertEqual([i['key'] for i in cert['items']], + ['tls.crt', 'tls.key'] if external else + ['server.cert.pem', 'server.key.pem']) + config = json.loads(component(objects, 'ConfigMap', 'xgt') + ['data']['xgtd.conf']) + self.assertEqual(config['system.usemtls'], 'true') + + def test_legacy_secret_keys_and_same_secret_mtls_are_preserved(self): + for profile in self.profiles(): + values = self.values(profile) + values['xgt']['ssl'] = {'enabled': True, 'existingSecret': 'legacy', 'mtls': True} + values['frontend'] = {'tls': {'existingSecret': 'frontend-legacy', 'mtls': True}} + objects = render(values) + volume, _ = self.volume(objects, 'xgt', 'xgt-tls') + self.assertEqual([i['key'] for i in volume['secret']['items']], + ['server.cert.pem', 'server.key.pem', 'ca-chain.cert.pem']) + _, pod = self.volume(objects, 'frontend', 'tls-certs') + self.assertEqual([m['subPath'] for m in pod['containers'][0]['volumeMounts'] + if m['name'] == 'tls-certs'], + ['public.pem', 'private.pem', 'chain.pem']) + + def test_custom_same_secret_client_ca_and_yaml_scalar_keys(self): + values = self.values({}) + values['xgt']['ssl'] = {'enabled': True, 'existingSecret': 'custom', 'mtls': True, + 'secretKeys': {'cert': 'true', 'key': '123', 'caCert': 'null'}} + values['frontend'] = {'tls': {'existingSecret': 'frontend-custom', 'mtls': True, + 'secretKeys': {'cert': 'true', 'key': '123', 'caCert': 'null'}}} + objects = render(values) + volume, _ = self.volume(objects, 'xgt', 'xgt-tls') + self.assertEqual([i['key'] for i in volume['secret']['items']], ['true', '123', 'null']) + _, pod = self.volume(objects, 'frontend', 'tls-certs') + self.assertEqual([m['subPath'] for m in pod['containers'][0]['volumeMounts'] + if m['name'] == 'tls-certs'], ['true', '123', 'null']) + + def test_inline_certificates_and_mounts_use_selected_secret_keys(self): + values = self.values({}) + values['xgt']['ssl'] = {'enabled': True, 'mtls': True, 'cert': 'cert', 'key': 'key', + 'caCert': 'ca', 'secretKeys': {'cert': 'tls.crt', 'key': 'tls.key'}} + values['frontend'] = {'tls': {'publicCert': 'cert', 'privateKey': 'key', + 'secretKeys': {'cert': 'tls.crt', 'key': 'tls.key'}}} + objects = render(values) + volume, _ = self.volume(objects, 'xgt', 'xgt-tls') + self.assertEqual([i['key'] for i in volume['secret']['items']], + ['tls.crt', 'tls.key', 'ca-chain.cert.pem']) + _, pod = self.volume(objects, 'frontend', 'tls-certs') + self.assertEqual([m['subPath'] for m in pod['containers'][0]['volumeMounts'] + if m['name'] == 'tls-certs'], ['tls.crt', 'tls.key']) + + generated = {o['metadata']['labels']['app']: o['stringData'] + for o in objects if o['kind'] == 'Secret' + and o['metadata']['labels'].get('app') in ['xgt', 'frontend']} + self.assertEqual(generated['xgt'], + {'tls.crt': 'cert', 'tls.key': 'key', 'ca-chain.cert.pem': 'ca'}) + self.assertEqual(generated['frontend'], {'tls.crt': 'cert', 'tls.key': 'key'}) + + def test_rejects_invalid_key_names_and_conflicting_ca_sources(self): + for component_name, field in [('xgt', 'ssl'), ('frontend', 'tls')]: + for key in ['', 'nested/tls.crt', 'bad key']: + values = self.values({}) + values.setdefault(component_name, {})[field] = { + 'existingSecret': 'tls', 'secretKeys': {'cert': key}} + self.assertIn('secretKeys/cert', render(values, fails=True)) + values = self.values({}) + values['xgt']['ssl'] = {'enabled': True, 'cert': 'cert', 'key': 'key', + 'mtls': True, 'caCert': 'inline', 'caCertExistingSecret': 'other'} + self.assertIn('one source for the client CA', render(values, fails=True)) + values['xgt'] = {'files': {'existingClaim': 'files'}, + 'ssl': {'caCertExistingSecret': 'other'}} + self.assertIn('xgt.files.existingClaim', render(values, fails=True)) + + def test_generated_secrets_preserve_scalar_like_keys_and_frontend_client_ca(self): + values = self.values({}) + keys = {'cert': 'true', 'key': '123', 'caCert': 'null'} + values['xgt']['ssl'] = {'enabled': True, 'mtls': True, + 'cert': 'server', 'key': 'private', 'caCert': 'clients', 'secretKeys': keys} + values['frontend'] = {'tls': {'mtls': True, + 'publicCert': 'server', 'privateKey': 'private', 'certChain': 'clients', + 'secretKeys': keys}} + objects = render(values) + generated = [o for o in objects if o['kind'] == 'Secret' + and o['metadata']['labels'].get('app') in ['xgt', 'frontend']] + self.assertEqual(len(generated), 2) + for secret in generated: + self.assertEqual(secret['stringData'], + {'true': 'server', '123': 'private', 'null': 'clients'}) + _, pod = self.volume(objects, 'frontend', 'tls-certs') + self.assertEqual([m['subPath'] for m in pod['containers'][0]['volumeMounts'] + if m['name'] == 'tls-certs'], ['true', '123', 'null']) + + def test_existing_configmap_is_not_replaced_and_disabled_components_ignore_tls(self): + values = self.values({}) + values['xgt']['config'] = {'existingConfigMap': 'existing'} + values['xgt']['ssl'] = {'enabled': True, 'existingSecret': 'serving', + 'secretKeys': {'cert': 'tls.crt', 'key': 'tls.key'}} + values['missionControl'] = {'enabled': False} + values['mongodb'] = {'enabled': False} + objects = render(values) + self.assertFalse(any(o['kind'] == 'ConfigMap' for o in objects)) + volume, pod = self.volume(objects, 'xgt', 'xgt-tls') + self.assertEqual(next(v for v in pod['volumes'] if v['name'] == 'xgt-config') + ['configMap']['name'], 'existing') + self.assertEqual(volume['secret']['items'][0]['key'], 'tls.crt') + + def test_shipped_service_ca_example(self): + values = yaml.safe_load((CHART / 'examples/xgt_openshift_service_tls.yaml').read_text()) + objects = render(values) + volume, _ = self.volume(objects, 'xgt', 'xgt-tls') + self.assertEqual(volume['secret']['secretName'], 'xgt-serving-tls') + self.assertEqual(volume['secret']['items'][0]['key'], 'tls.crt') + self.assertEqual(component(objects, 'Service', 'xgt')['metadata']['annotations'][ + 'service.beta.openshift.io/serving-cert-secret-name'], 'xgt-serving-tls') + + +if __name__ == '__main__': + unittest.main() diff --git a/charts/rocketgraph/tests/test_tls_upgrade_validation.py b/charts/rocketgraph/tests/test_tls_upgrade_validation.py new file mode 100644 index 0000000..77c3793 --- /dev/null +++ b/charts/rocketgraph/tests/test_tls_upgrade_validation.py @@ -0,0 +1,185 @@ +"""Upgrade compatibility and invalid TLS Secret key regressions.""" +import itertools +from pathlib import Path +import shutil +import tempfile +import unittest + +import yaml + +from test_render import CHART, component, render + + +TLS_FIELDS = {'frontend': 'tls', 'backend': 'tls', 'xgt': 'ssl'} +LEGACY_KEYS = { + 'frontend': {'cert': 'public.pem', 'key': 'private.pem', 'caCert': 'chain.pem'}, + 'backend': {'cert': 'proxy-client-cert.pem', 'key': 'proxy-client-key.pem', + 'caCert': 'xgt-server.pem'}, + 'xgt': {'cert': 'server.cert.pem', 'key': 'server.key.pem', + 'caCert': 'ca-chain.cert.pem'}, +} + + +def inline_tls(app): + return { + 'frontend': {'mtls': True, 'publicCert': 'cert', 'privateKey': 'key', + 'certChain': 'ca'}, + 'backend': {'mtls': True, 'proxyClientCert': 'cert', 'proxyClientKey': 'key', + 'xgtServerCert': 'ca'}, + 'xgt': {'enabled': True, 'mtls': True, 'cert': 'cert', 'key': 'key', + 'caCert': 'ca'}, + }[app] + + +class TlsUpgradeValidationTests(unittest.TestCase): + def legacy_chart(self, directory): + # --reuse-values uses the previous chart's defaults rather than new ones. + # Remove the new maps from chart defaults so normal coalescing cannot hide + # a missing fallback, unlike simply omitting secretKeys from an overlay. + chart = Path(directory) / 'rocketgraph' + shutil.copytree(CHART, chart) + path = chart / 'values.yaml' + defaults = yaml.safe_load(path.read_text()) + for app, field in TLS_FIELDS.items(): + defaults[app][field].pop('secretKeys') + defaults['backend']['tls'].pop('xgtServerCertConfigMapKey') + path.write_text(yaml.safe_dump(defaults)) + return chart + + def assert_keys(self, objects, expected, inline): + for app, keys in expected.items(): + pod = component(objects, 'Deployment', app)['spec']['template']['spec'] + if app == 'xgt': + volume = next(v for v in pod['volumes'] if v['name'] == 'xgt-tls') + actual = {item['key'] for item in volume['secret']['items']} + else: + actual = {mount['subPath'] for mount in + pod['containers'][0]['volumeMounts'] + if mount['name'] == 'tls-certs'} + self.assertEqual(actual, set(keys.values())) + if inline: + secret = component(objects, 'Secret', app) + self.assertEqual(secret['stringData'], + {keys['cert']: 'cert', keys['key']: 'key', + keys['caCert']: 'ca'}) + + def test_reused_values_without_key_maps_keep_legacy_mounts_and_inline_data(self): + with tempfile.TemporaryDirectory() as directory: + chart = self.legacy_chart(directory) + for inline in (False, True): + with self.subTest(inline=inline): + values = {app: {field: inline_tls(app) if inline else { + 'existingSecret': app + '-tls', 'mtls': True, + **({'enabled': True} if app == 'xgt' else {})}} + for app, field in TLS_FIELDS.items()} + self.assert_keys(render(values, chart=chart), LEGACY_KEYS, inline) + + def test_partial_key_maps_without_new_defaults_keep_unspecified_legacy_keys(self): + with tempfile.TemporaryDirectory() as directory: + chart = self.legacy_chart(directory) + values = {app: {field: dict(inline_tls(app), secretKeys={'cert': 'tls.crt'})} + for app, field in TLS_FIELDS.items()} + expected = {app: dict(keys, cert='tls.crt') + for app, keys in LEGACY_KEYS.items()} + self.assert_keys(render(values, chart=chart), expected, True) + + def test_reused_values_keep_configmap_ca_key_default_and_overrides(self): + with tempfile.TemporaryDirectory() as directory: + chart = self.legacy_chart(directory) + for key in (None, 'company-ca.pem', '123'): + with self.subTest(key=key): + tls = {'xgtServerCertConfigMap': 'true'} + if key is not None: + tls['xgtServerCertConfigMapKey'] = key + objects = render({'backend': {'tls': tls}}, chart=chart) + pod = component(objects, 'Deployment', 'backend') + volumes = pod['spec']['template']['spec']['volumes'] + volume = next(v for v in volumes + if v['name'] == 'xgt-server-ca') + self.assertEqual(volume['configMap'], { + 'name': 'true', + 'items': [{'key': key or 'service-ca.crt', + 'path': 'xgt-server.pem'}], + }) + + def test_reserved_names_are_rejected_for_every_component_and_key(self): + for app, field in TLS_FIELDS.items(): + for key in ('cert', 'key', 'caCert'): + for invalid in ('.', '..', '..data', '...pem'): + with self.subTest(app=app, key=key, invalid=invalid): + values = {app: {field: dict(inline_tls(app), + secretKeys={key: invalid})}} + self.assertIn('secretKeys/' + key, render(values, fails=True)) + + def test_configmap_ca_keys_reject_invalid_names_and_preserve_valid_names(self): + for key in ('', 'ca/bundle.crt', '.', '..', '..data', 'a' * 254): + with self.subTest(invalid=key): + values = {'backend': {'tls': { + 'xgtServerCertConfigMap': 'xgt-service-ca', + 'xgtServerCertConfigMapKey': key, + }}} + self.assertIn('xgtServerCertConfigMapKey', + render(values, fails=True)) + for key in ('service-ca.crt', '.ca.pem', '-ca_bundle', 'ca..pem', + '123', 'a' * 253): + with self.subTest(valid=key): + objects = render({'backend': {'tls': { + 'xgtServerCertConfigMap': 'xgt-service-ca', + 'xgtServerCertConfigMapKey': key, + }}}) + pod = component(objects, 'Deployment', 'backend') + volumes = pod['spec']['template']['spec']['volumes'] + volume = next(v for v in volumes + if v['name'] == 'xgt-server-ca') + self.assertEqual(volume['configMap']['items'], + [{'key': key, 'path': 'xgt-server.pem'}]) + + def test_valid_dot_and_punctuation_names_remain_supported(self): + keys = {'cert': '.cert.pem', 'key': '-private_key', 'caCert': 'ca..pem'} + values = {app: {field: dict(inline_tls(app), secretKeys=keys)} + for app, field in TLS_FIELDS.items()} + self.assert_keys(render(values), {app: keys for app in TLS_FIELDS}, True) + + def test_inline_collisions_fail_with_the_conflicting_settings(self): + for app, field in TLS_FIELDS.items(): + for pair in itertools.combinations(('cert', 'key', 'caCert'), 2): + with self.subTest(app=app, pair=pair): + values = {app: {field: dict(inline_tls(app), + secretKeys={key: 'same.pem' for key in pair})}} + error = render(values, fails=True) + self.assertIn('distinct Secret key names', error) + for key in pair: + self.assertIn(f'{app}.{field}.secretKeys.{key}', error) + + def test_unused_inline_ca_key_can_match_the_certificate_key(self): + values = {} + for app, field in TLS_FIELDS.items(): + tls = inline_tls(app) + tls.pop({'frontend': 'certChain', 'backend': 'xgtServerCert', + 'xgt': 'caCert'}[app]) + tls['mtls'] = False + tls['secretKeys'] = {'cert': 'same.pem', 'caCert': 'same.pem'} + values[app] = {field: tls} + objects = render(values) + for app in TLS_FIELDS: + data = component(objects, 'Secret', app)['stringData'] + self.assertEqual(data['same.pem'], 'cert') + self.assertEqual(len(data), 2) + + def test_existing_secret_bundles_and_disabled_components_are_not_rejected(self): + keys = {'cert': 'bundle.pem', 'key': 'bundle.pem', 'caCert': 'bundle.pem'} + values = {app: {field: {'existingSecret': app + '-tls', 'mtls': True, + 'secretKeys': keys, **({'enabled': True} if app == 'xgt' else {})}} + for app, field in TLS_FIELDS.items()} + objects = render(values) + self.assertFalse(any(obj['kind'] == 'Secret' for obj in objects)) + values['missionControl'] = {'enabled': False} + for app, field in TLS_FIELDS.items(): + values[app][field] = dict(inline_tls(app), secretKeys=keys) + values['xgt']['ssl']['enabled'] = False + objects = render(values) + self.assertFalse(any(obj['kind'] == 'Secret' for obj in objects)) + + +if __name__ == '__main__': + unittest.main() diff --git a/charts/rocketgraph/values.schema.json b/charts/rocketgraph/values.schema.json index 3ef7a67..6d65a16 100644 --- a/charts/rocketgraph/values.schema.json +++ b/charts/rocketgraph/values.schema.json @@ -207,7 +207,7 @@ "properties": { "existingSecret": { "type": "string", - "description": "Name of an existing Secret containing keys 'public.pem', 'private.pem', and optionally 'chain.pem'", + "description": "Name of an existing Secret containing frontend certificate keys selected by secretKeys", "default": "" }, "publicCert": { @@ -227,13 +227,41 @@ }, "mtls": { "type": "boolean", - "description": "Enable browser mTLS; mounts chain.pem from existingSecret or certChain as the CA for validating browser client certificates", + "description": "Enable browser mTLS; client CA comes from secretKeys.caCert in existingSecret or inline certChain", "default": false }, "external": { "type": "boolean", "description": "Set when TLS is terminated upstream (Ingress TLS or an edge-terminated route) so the backend marks session cookies Secure", "default": false + }, + "secretKeys": { + "type": "object", + "description": "Key names in the frontend TLS Secret, whether existingSecret or the one the chart creates", + "additionalProperties": false, + "properties": { + "cert": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "public.pem" + }, + "key": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "private.pem" + }, + "caCert": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "chain.pem" + } + } } } } @@ -485,7 +513,7 @@ "properties": { "existingSecret": { "type": "string", - "description": "Name of an existing Secret containing key 'xgt-server.pem'. For mTLS, also include 'proxy-client-cert.pem' and 'proxy-client-key.pem' and set the corresponding inline values to enable mounting.", + "description": "Name of an existing Secret containing certificate keys selected by secretKeys. For mTLS include the client certificate/key and set mtls=true; include the XGT CA unless supplied by xgtServerCertConfigMap.", "default": "" }, "xgtServerCert": { @@ -507,6 +535,47 @@ "type": "boolean", "description": "Enable mTLS for backend connections to xGT. Requires either existingSecret to contain the client cert/key, or for them to be provided inline", "default": false + }, + "xgtServerCertConfigMap": { + "type": "string", + "description": "Name of an existing ConfigMap holding the xGT CA certificate, such as one filled by OpenShift's service.beta.openshift.io/inject-cabundle annotation. Used instead of xgt-server.pem from existingSecret or xgtServerCert", + "default": "" + }, + "xgtServerCertConfigMapKey": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "description": "Key in xgtServerCertConfigMap that holds the CA certificate", + "default": "service-ca.crt" + }, + "secretKeys": { + "type": "object", + "description": "Key names in the backend TLS Secret, whether existingSecret or the one the chart creates; cert/key are client credentials and caCert verifies XGT", + "additionalProperties": false, + "properties": { + "cert": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "proxy-client-cert.pem" + }, + "key": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "proxy-client-key.pem" + }, + "caCert": { + "type": "string", + "minLength": 1, + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "xgt-server.pem" + } + } } } }, @@ -549,7 +618,7 @@ }, "existingSecret": { "type": "string", - "description": "Name of an existing Secret containing key MC_OIDC_CLIENT_SECRET", + "description": "Name of an existing Secret containing the client secret under secretKeys.clientSecret", "default": "" }, "scopes": { @@ -584,13 +653,36 @@ }, "caCertExistingSecret": { "type": "string", - "description": "Name of an existing Secret containing key oidc-ca.pem", + "description": "Name of an existing Secret containing the OIDC CA bundle under secretKeys.caCert", "default": "" }, "xgtAllowedHosts": { "type": "string", "description": "Comma-separated host:port allowlist for xGT connections (SSRF prevention). Defaults to the internal xGT service when xgt.enabled=true. Empty when xgt.enabled=false — set explicitly when using an external xGT.", "default": "" + }, + "secretKeys": { + "type": "object", + "description": "Source key names for OIDC client secret and CA bundle; application destinations remain unchanged", + "additionalProperties": false, + "properties": { + "clientSecret": { + "type": "string", + "minLength": 1, + "description": "Client secret key in existing and chart-generated Secrets", + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "MC_OIDC_CLIENT_SECRET" + }, + "caCert": { + "type": "string", + "minLength": 1, + "description": "OIDC CA bundle key in existing and chart-generated Secrets; used by both xGT and the backend", + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "oidc-ca.pem" + } + } } } }, @@ -1226,7 +1318,7 @@ }, "existingSecret": { "type": "string", - "description": "Name of an existing Secret containing keys 'server.cert.pem' and 'server.key.pem'", + "description": "Name of an existing Secret containing the server cert and key under the names in secretKeys", "default": "" }, "cert": { @@ -1241,13 +1333,49 @@ }, "mtls": { "type": "boolean", - "description": "Require client certificates; needs ca-chain.cert.pem in existingSecret or provided via the caCert parameter", + "description": "Require client certificates; client CA comes from caCertExistingSecret, secretKeys.caCert in existingSecret, or inline caCert", "default": false }, "caCert": { "type": "string", "description": "PEM-encoded CA certificate for validating client certificates (ca-chain.cert.pem)", "default": "" + }, + "caCertExistingSecret": { + "type": "string", + "description": "Separate Secret holding the mTLS client CA under secretKeys.caCert; can be used with an OpenShift-generated server Secret", + "default": "" + }, + "secretKeys": { + "type": "object", + "description": "Key names in the xGT TLS Secret, whether existingSecret or the one the chart creates", + "additionalProperties": false, + "properties": { + "cert": { + "type": "string", + "minLength": 1, + "description": "Key holding the server certificate (e.g. tls.crt)", + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "server.cert.pem" + }, + "key": { + "type": "string", + "minLength": 1, + "description": "Key holding the server private key (e.g. tls.key)", + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "server.key.pem" + }, + "caCert": { + "type": "string", + "minLength": 1, + "description": "Key holding the CA chain used to validate client certificates when mtls is true", + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "ca-chain.cert.pem" + } + } } } }, @@ -1258,13 +1386,21 @@ "properties": { "existingSecret": { "type": "string", - "description": "Name of an existing Secret containing the key 'xgtd.lic' with the license data", + "description": "Name of an existing Secret containing the license file under secretKey", "default": "" }, "data": { "type": "string", "description": "Plain-text license file contents, not database data or base64. Ignored when existingSecret is provided.", "default": "" + }, + "secretKey": { + "type": "string", + "minLength": 1, + "description": "License file key in existing and chart-generated Secrets; mounted at /license/xgtd.lic", + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "xgtd.lic" } } }, @@ -1630,6 +1766,37 @@ "type": "object" }, "default": [] + }, + "oidc": { + "type": "object", + "description": "xGT OIDC HTTPS CA trust. Falls back to backend.oidc CA settings when neither CA source is set.", + "additionalProperties": false, + "properties": { + "caCert": { + "type": "string", + "description": "Inline PEM CA bundle for xGT OIDC HTTPS requests; creates an xGT CA Secret", + "default": "" + }, + "caCertExistingSecret": { + "type": "string", + "description": "Existing Secret holding the xGT OIDC CA bundle under secretKeys.caCert; preferred over inline caCert", + "default": "" + }, + "secretKeys": { + "type": "object", + "additionalProperties": false, + "properties": { + "caCert": { + "type": "string", + "minLength": 1, + "description": "CA bundle key in the xGT OIDC CA Secret; mounted at /etc/ssl/certs/oidc-ca.pem", + "maxLength": 253, + "pattern": "^([a-zA-Z0-9_-]|\\.[a-zA-Z0-9_-])[a-zA-Z0-9._-]*$", + "default": "oidc-ca.pem" + } + } + } + } } } }, diff --git a/charts/rocketgraph/values.yaml b/charts/rocketgraph/values.yaml index b87ea15..098b21e 100644 --- a/charts/rocketgraph/values.yaml +++ b/charts/rocketgraph/values.yaml @@ -49,12 +49,18 @@ frontend: failureThreshold: 3 # TLS certificates — provide either existingSecret OR inline cert data tls: - existingSecret: "" # Must have keys: public.pem, private.pem (optional: chain.pem for mTLS) + existingSecret: "" # Certificate keys are selected by secretKeys publicCert: "" # Plain-text PEM content (auto base64-encoded by k8s) privateKey: "" certChain: "" # Inline CA chain PEM for validating browser client certs - mtls: false # Enable browser mTLS; mounts chain.pem from existingSecret or certChain + mtls: false # Enable browser mTLS; client CA key selected by secretKeys.caCert external: false # TLS terminated upstream (Ingress TLS / edge route); marks session cookies Secure + # Source keys in an existing or chart-generated TLS Secret. + # Use cert: tls.crt and key: tls.key for a Kubernetes TLS Secret. + secretKeys: + cert: public.pem + key: private.pem + caCert: chain.pem backend: image: @@ -109,11 +115,22 @@ backend: MC_SSL_PORT: "" # Frontend HTTPS port (defaults to frontend.service.httpsPort) # TLS certificates tls: - existingSecret: "" # Must have key: xgt-server.pem (optional: proxy-client-cert.pem, proxy-client-key.pem) + existingSecret: "" # Certificate keys are selected by secretKeys xgtServerCert: "" proxyClientCert: "" proxyClientKey: "" mtls: false # Enable mTLS for backend connections to xGT + # Existing ConfigMap holding the xGT CA, e.g. one OpenShift fills through the + # service.beta.openshift.io/inject-cabundle annotation. Replaces xgt-server.pem. + xgtServerCertConfigMap: "" + xgtServerCertConfigMapKey: service-ca.crt + # Source keys in an existing or chart-generated TLS Secret. + # cert/key are this backend's mTLS client credentials; + # caCert is the CA used to verify XGT (unless supplied by the ConfigMap). + secretKeys: + cert: proxy-client-cert.pem + key: proxy-client-key.pem + caCert: xgt-server.pem # Site configuration files (inline content) siteConfig: yml: "" @@ -123,14 +140,19 @@ backend: issuer: "" # e.g. https://idp.example.com/realms/xgt clientId: "" clientSecret: "" # inline (creates a Secret); use existingSecret in production - existingSecret: "" # existing Secret with key: MC_OIDC_CLIENT_SECRET + existingSecret: "" # Client secret key is selected by secretKeys.clientSecret scopes: "" # e.g. "openid profile email" frontendUrl: "" # e.g. https://mc.example.com redirectUri: "" # e.g. https://mc.example.com/api/login/oidc/callback allowedOrigins: "" tlsVerify: "" # "true" or "false"; leave empty to use default caCert: "" # inline CA PEM for OIDC provider TLS (creates a Secret) - caCertExistingSecret: "" # existing Secret with key: oidc-ca.pem + caCertExistingSecret: "" # CA bundle key is selected by secretKeys.caCert + # Source keys for existing and chart-generated Secrets. Container file paths + # and the MC_OIDC_CLIENT_SECRET environment variable remain unchanged. + secretKeys: + clientSecret: MC_OIDC_CLIENT_SECRET + caCert: oidc-ca.pem # Allowlist of xGT host:port pairs the backend may connect to (SSRF prevention). # Defaults to the internal xGT service when xgt.enabled=true. # Set explicitly when using an external xGT (e.g. "xgt.myns.svc.cluster.local:4367"). @@ -291,14 +313,32 @@ xgt: existingClaim: "" # Also overrides /log when files.existingClaim is set. ssl: enabled: false - existingSecret: "" # Must have keys: server.cert.pem, server.key.pem + existingSecret: "" # Must have the cert and key under the names in secretKeys cert: "" # Inline server cert PEM key: "" # Inline server key PEM - mtls: false # Require client certs; needs ca-chain.cert.pem in existingSecret or via caCert + mtls: false # Require client certs; CA from caCertExistingSecret, existingSecret or caCert caCert: "" # Inline CA cert PEM for validating client certs (ca-chain.cert.pem) + # Optional separate Secret holding the mTLS client CA. The key is + # secretKeys.caCert. Supports OpenShift-generated server certificates. + caCertExistingSecret: "" + # Key names in the Secret, e.g. tls.crt and tls.key for an OpenShift + # service serving certificate. The chart's own Secret uses them too. + secretKeys: + cert: server.cert.pem + key: server.key.pem + caCert: ca-chain.cert.pem license: - existingSecret: "" # Must have key: xgtd.lic + existingSecret: "" # License file key is selected by secretKey + secretKey: xgtd.lic # Also used for inline data; mounted as /license/xgtd.lic data: "" # License FILE TEXT, not database data or base64. Prefer existingSecret. + # CA trust for xGT's HTTPS requests to its OIDC issuer. + # If no source is set here, legacy backend.oidc CA settings still apply to xGT. + # Mission Control uses backend.oidc for its own CA settings. + oidc: + caCert: "" # Inline PEM bundle; creates an xGT CA Secret + caCertExistingSecret: "" # Existing Secret; preferred over inline caCert + secretKeys: + caCert: oidc-ca.pem # Mounted at /etc/ssl/certs/oidc-ca.pem # LDAP authentication via SSSD ldap: enabled: false diff --git a/doc/keycloak_setup/README.md b/doc/keycloak_setup/README.md new file mode 100644 index 0000000..ae48521 --- /dev/null +++ b/doc/keycloak_setup/README.md @@ -0,0 +1,317 @@ +# Keycloak Setup for xGT + +Use Keycloak to sign in as a normal user or an automation service account. Keycloak issues a token; xGT validates it and maps its groups to security labels. LDAP federation and Mission Control are optional. + +Experimental: OIDC authentication may change in future releases. + +Start with xGT 2.7.1 and an existing Keycloak realm. Python must reach xGT; Python, xGT and the login browser must reach the Keycloak HTTPS endpoint. Replace the example hostnames and realm with your own. Screenshots show a test realm; settings can appear in different places in other Keycloak versions. The Helm examples use Rocketgraph chart **0.5.0**. + +The minimum setup is: + +1. Create the Keycloak client for the login method you need. +1. Add audience `xgt` to its access tokens. For group-based permissions, include `groups` and assign the user or service account to a group. +1. Configure xGT with the issuer, audience and JWT validation, then map groups to xGT labels. +1. If a component does not trust Keycloak HTTPS, configure its CA trust. +1. Run the matching Python login example below and verify its labels. + +The Keycloak steps and Python examples also apply outside OpenShift. The Helm, `oc` and Route examples are for deployments on OpenShift. When Keycloak issues the tokens, no OpenShift `OAuthClient` or LDAP-to-OpenShift group sync is needed. For tokens issued by OpenShift itself, see [OpenShift and LDAP quickstart](../openshift_ldap_quickstart.md) instead. + +## Guide Files + +Read this page first. Optional steps: [LDAP federation](ldap.md), [HTTPS trust](https_trust.md), and [Mission Control](mission_control.md). The [examples](examples/) are included inline and as downloadable files. Screenshots can be clicked to view their full size. + +For the Helm commands, use a checkout or archive containing Rocketgraph chart **0.5.0** and run from its `doc/keycloak_setup` directory. The chart path is `../../charts/rocketgraph`; if your chart package is stored elsewhere, replace that path with your local 0.5.0 chart. Edit the placeholders in the relevant examples and supply the path to your existing deployment values file. + +## 1. Create the Clients You Need + +In your realm, open **Clients → Create client** and select **OpenID Connect**. Create only the clients needed for your deployment: + +| Setting | Normal-user Python login | Automation scripts | Mission Control | +|----|----|----|----| +| Client ID | `xgt-browser` | `xgt-automation` | `mission-control` | +| Client authentication | Off | On | On | +| Standard flow | On | Off | On | +| Service account roles | Off | On | Off | +| Direct access grants / Implicit flow | Off | Off | Off | +| PKCE | Required, `S256` | Not used | Not required for Mission Control 2.7.0 | +| Valid redirect URIs | `http://127.0.0.1:8765/callback` | None | `https://mc.example.com/api/login/oidc/callback` | + +Keep the default `profile` and `email` client scopes. Client IDs identify applications, not user accounts. Separate clients let Python browser login remain public while keeping the automation and Mission Control secrets independent. Sharing a confidential client is possible, but Python browser login then also needs its secret. + +### Normal-User Login + +The public `xgt-browser` client opens a browser for a person to sign in. Require PKCE with method `S256`; older Keycloak versions expose this under Advanced settings as **PKCE Code Challenge Method**. + +Public browser client with Standard flow and S256 PKCE enabled. + +Capability settings for normal-user Python login. + +Register the callback exactly in **Valid redirect URIs**, without a trailing slash. Change it if you use a different `callback_port` in Python. + +Valid redirect URI http://127.0.0.1:8765/callback. + +The default Python loopback callback. + +### Automation + +The confidential `xgt-automation` client obtains tokens without a browser. Enable **Client authentication** and **Service account roles**. Leave the other authentication flows off. + +Automation client with client authentication and service accounts on. + +Capability settings for automated jobs. + +Open **Credentials** and copy this client's generated **Client Secret**. The Python job uses it to obtain a token. It is not the Keycloak administrator password, and xGT does not need it for JWT validation. + +Credentials tab showing the masked automation client secret. + +Where to obtain the automation client's secret. + +## 2. Add Audience and Group Token Mappers + +Do this on **each client that issues tokens for xGT**, including Mission Control if used. Open **Client scopes → CLIENT_ID-dedicated → Mappers → Add mapper → By configuration**, create the following mappers, and save each one. + +### Audience Mapper + +| Field | Value | +|----|----| +| Mapper type / Name | `Audience` / `xgt-audience` | +| Included Client Audience | Leave empty | +| Included Custom Audience | `xgt` | +| Add to access token | On | +| Add to ID token / Add to lightweight access token | Off | +| Add to token introspection | Needed only for introspection validation | + +`xgt` is the expected audience, not another client that must be registered. It must match `security.oidc.audience` on the server. + +Audience mapper adding xgt as a custom audience to the access token. + +The screenshot also enables introspection; JWT validation uses the access token. + +### Group Membership Mapper + +| Field | Value | +|----|----| +| Mapper type / Name | `Group Membership` / `xgt-groups` | +| Token Claim Name | `groups` | +| Full group path | Off for the flat group names in this example | +| Add to access token | On | +| Add to lightweight access token | Off | +| Add to ID token / Add to userinfo | Not required for JWT validation | +| Add to token introspection | Needed only for introspection validation | + +Group Membership mapper with groups and inclusion in access tokens. + +The screenshot enables additional outputs; JWT validation needs the groups in the access token. + +This mapper copies existing memberships into tokens; it does not assign memberships. LDAP federation uses a separate LDAP group mapper, described in [LDAP federation](ldap.md). + +## 3. Assign Group Memberships + +Reuse existing Keycloak groups, including groups already synchronized from LDAP. Creating a new group is optional. The examples below use `rocketgraph-ldap-admins`, `rocketgraph-ldap-users` and the optional `rocketgraph-automation` group; replace them with your actual names. + +For a normal user, use **Users → USER → Groups**, or manage memberships in LDAP when the directory owns them. For an automation account: + +1. Open **Clients → xgt-automation → Service account roles**. +1. Click the linked username **service-account-xgt-automation**. +1. Open **Groups → Join Group**, select the existing group, and click **Join**. + +Service account roles tab linking to service-account-xgt-automation. + +Open the service-account user through its client. + +Join Group offers existing LDAP groups and an optional automation group. + +Choose the group whose xGT labels the automation job needs. + +Service-account users are normally excluded from the default Users list. Membership is stored in Keycloak; joining a synchronized group does not create an LDAP user or write a membership back to LDAP. The account does not inherit LDAP users' groups automatically. Reconnect with a fresh token and session when memberships change. + +## 4. Configure xGT + +Merge this block into `xgtd.conf`, retaining the deployment's license, storage, resource and TLS settings: + +``` json +{ + "security.oidc": { + "issuer": "https://keycloak.example.com/realms/rocketgraph", + "client_id": "xgt-browser", + "audience": "xgt", + "validation_mode": "jwt", + "username_claim": "preferred_username", + "groups_claim": "groups", + "scopes": "openid profile email" + } +} +``` + +For automation only, omit `client_id`; the job supplies `xgt-automation` explicitly. The configured `client_id` advertises the default browser client, while `audience` controls which tokens xGT accepts. xGT fetches discovery information and public signing keys from Keycloak; JWT validation needs no client secret on xGT. See [xGT Keycloak reference](https://docs.rocketgraph.com/sysadmin_guide/user_authentication.html#keycloak) for validation modes, including introspection, which uses server-side credentials. + +In `grouplabel.csv`, map the selected Keycloak groups to xGT labels: + +``` text +group,label +xgtd,xgtadmin +rocketgraph-ldap-admins,xgtadmin +rocketgraph-ldap-users,data-users +rocketgraph-automation,automation +``` + +Declare the labels in `label.csv`: + +``` text +label +xgtadmin +data-users +automation +``` + +Keep existing mappings your deployment needs. A service account joining `rocketgraph-ldap-users` receives `data-users`; no new automation group or label is required. Grant labels access to the frames the job needs using [configuring groups and labels](https://docs.rocketgraph.com/sysadmin_guide/configuration.html#configuring-groups-and-labels). A label alone does not grant access to all data; `xgtadmin` is the administrator label. + +### Using Helm on OpenShift + +Download [keycloak_values.yaml](examples/keycloak_values.yaml) and merge it into your existing values. It generates the OIDC settings and CSV files described above: + +``` yaml +# Merge into the deployment's existing values; keep its license, hostname, +# images, storage and TLS settings. Update existing mounted config files instead +# if xgt.config.existingConfigMap or a files PVC supplies the configuration. +xgt: + config: + # Reuse your existing groups and labels; these names are examples. + # The rocketgraph-automation group and automation label are optional. + grouplabelCsv: | + group,label + xgtd,xgtadmin + rocketgraph-ldap-admins,xgtadmin + rocketgraph-ldap-users,data-users + rocketgraph-automation,automation + labelCsv: | + label + xgtadmin + data-users + automation + extraConfig: + security.oidc: + issuer: https://keycloak.example.com/realms/rocketgraph + # Default client for normal-user browser login; this is not a username. + # Omit client_id for automation only; Python supplies xgt-automation. + client_id: xgt-browser + audience: xgt + validation_mode: jwt + username_claim: preferred_username + groups_claim: groups + scopes: openid profile email + # If xGT lacks CA trust, see the HTTPS trust page: use keycloak_ca_values.yaml + # or the OpenShift injected ConfigMap alternative openshift_ca_values.yaml. +``` + +Commands assume version **0.5.0** of the [Rocketgraph chart](https://github.com/Rocketgraphai/rocketgraph/tree/main/charts/rocketgraph) is available locally at `../../charts/rocketgraph`. Use your actual chart path, release and namespace, and include all existing deployment values files: + +``` bash +helm upgrade YOUR_RELEASE ../../charts/rocketgraph -n YOUR_NAMESPACE \ + -f YOUR_EXISTING_VALUES.yaml -f examples/keycloak_values.yaml +``` + +If an existing ConfigMap or files PVC supplies `xgtd.conf`, update its OIDC configuration and CSV files directly instead of using this overlay. The chart rejects `xgt.extraConfig` and inline CSV settings alongside external configuration. For a hostname-bound license, retain `xgt.hostname` with a hostname covered by the license; no custom StatefulSet is needed. + +For OpenShift's non-root profile, retain `openshift.enabled: true` and `openshift.scc: restricted-v2`. Select FIPS images with `fips.enabled: true` and keep image tags without a `-fips` suffix; the chart appends it. Mission Control currently requires FIPS images for this profile. Configure each connection's TLS separately. Image selection alone does not establish FIPS compliance, and existing PVC contents must be writable by the admitted UID and volume group. See the chart's restricted-v2 and FIPS sections for deployment requirements; these authentication settings do not replace them. + +## 5. Configure HTTPS Trust If Needed + +Skip extra CA settings only where the application's trust store already trusts Keycloak. A private company CA trusted by an OpenShift node or a browser is not automatically trusted inside the stock containers. + +Follow [HTTPS trust](https_trust.md) to mount an approved CA bundle into xGT and Mission Control and set the matching Python CA path. That page also shows the optional direct mount of an OpenShift-injected trusted bundle. The browser needs its own trust configuration. + +OIDC does not enable TLS for the Python-to-xGT connection. If xGT requires TLS, add the connection flags and certificate trust from [Python connection TLS settings](https://docs.rocketgraph.com/user_ref/usingxgt/connecting_to_server.html#connect-via-ssl-encrypted-network-connection). In SDK 2.7.1, an omitted `ca_cert_path` defaults to `ssl_server_cert` when xGT TLS is enabled. If that file does not trust Keycloak, explicitly set `ca_cert_path` to a bundle that does, even for publicly issued Keycloak certificates. See [HTTPS trust](https_trust.md). + +## 6. Test Automation and Normal-User Login + +Install the matching Python client: + +``` bash +python3 -m pip install xgt==2.7.1 +``` + +### Automation / Service-Account Login + +Download [connect_automation.py](examples/connect_automation.py) or save the complete example below. Replace the host and supply `XGT_AUTOMATION_CLIENT_SECRET` through the environment. For scheduled jobs, populate it from the job's secret store. Uncomment `ca_cert_path` if Python needs a Keycloak CA bundle, including when xGT TLS supplies a different CA. + +``` python +"""Log in to xGT as a Keycloak automation service account.""" +import os + +import xgt + +conn = xgt.Connection( + host = "xgt.example.com", + port = 4367, + # For xGT TLS, add the connection flags described in the SSL guide. + auth = xgt.OidcCredentialsAuth( + client_id = "xgt-automation", + # Set if Python needs a Keycloak CA bundle, including when xGT TLS + # supplies a different ssl_server_cert. + # ca_cert_path = "~/.config/rocketgraph/keycloak-ca.pem", + client_secret = os.environ["XGT_AUTOMATION_CLIENT_SECRET"])) + +print("User:", conn.userid) +print("Labels:", conn.get_user_labels()) +print("Test query:", conn.run_job("RETURN 1 AS ok").get_data()) +``` + +``` bash +printf "Keycloak automation client secret: " +read -r -s XGT_AUTOMATION_CLIENT_SECRET +printf '\n' +export XGT_AUTOMATION_CLIENT_SECRET +python3 examples/connect_automation.py +unset XGT_AUTOMATION_CLIENT_SECRET +``` + +Expect `service-account-xgt-automation`, the chosen group's mapped labels, and query result `[[1]]`. No browser or LDAP password is involved. + +### Normal-User Browser Login + +Download [connect_user.py](examples/connect_user.py) or save this example. It uses the public `xgt-browser` client advertised by xGT; a client secret is unnecessary. The same `ca_cert_path` guidance applies when adding xGT TLS flags. + +``` python +"""Open a browser to log in to xGT with a normal Keycloak or LDAP account.""" +import xgt + +conn = xgt.Connection( + host = "xgt.example.com", + port = 4367, + # For xGT TLS, add the connection flags described in the SSL guide. + auth = xgt.OidcAuth( + flow = "auth_code", + # Set if Python needs a Keycloak CA bundle, including when xGT TLS + # supplies a different ssl_server_cert. + # ca_cert_path = "~/.config/rocketgraph/keycloak-ca.pem", + force_login = True)) + +print("User:", conn.userid) +print("Labels:", conn.get_user_labels()) +print("Test query:", conn.run_job("RETURN 1 AS ok").get_data()) +``` + +``` bash +python3 examples/connect_user.py +``` + +Sign in with your normal Keycloak or federated LDAP account. Keep Python running, and make sure the browser can reach its loopback callback. If the browser runs on another machine, forward port 8765 to the Python machine. Verify the returned identity, labels and query result. Keycloak's issuer hostname must resolve and its HTTPS certificate must be trusted by the browser as well as Python. + +## Troubleshooting + +| Symptom | Check | +|----|----| +| Automation login rejected | Client ID/secret, Client authentication On and Service account roles On. | +| Audience rejected by xGT | Access token contains `xgt` and xGT expects that audience. | +| Login succeeds but labels are missing | Group Membership mapper, memberships and matching CSV names. | +| Labels present but data operation denied | Frame permissions grant access to the required label. | +| Invalid browser redirect URI | Exact callback URI, including scheme, port and `/callback`. | +| HTTPS certificate verification failed | CA trust for the failing component: Python, xGT, backend or browser. | +| Issuer hostname cannot be resolved | DNS on the failing machine; a CA file cannot fix DNS. | + +## Optional Setup + +- [LDAP Federation with Keycloak](ldap.md) +- [HTTPS Trust for Keycloak](https_trust.md) +- [Mission Control with Keycloak](mission_control.md) diff --git a/doc/keycloak_setup/examples/backend_trusted_ca_patch.yaml b/doc/keycloak_setup/examples/backend_trusted_ca_patch.yaml new file mode 100644 index 0000000..c4a496c --- /dev/null +++ b/doc/keycloak_setup/examples/backend_trusted_ca_patch.yaml @@ -0,0 +1,16 @@ +spec: + template: + spec: + volumes: + - name: keycloak-trusted-ca + configMap: + name: trusted-ca-bundle + items: + - key: ca-bundle.crt + path: ca-bundle.crt + containers: + - name: backend + volumeMounts: + - name: keycloak-trusted-ca + mountPath: /etc/keycloak-ca + readOnly: true diff --git a/doc/keycloak_setup/examples/connect_automation.py b/doc/keycloak_setup/examples/connect_automation.py new file mode 100644 index 0000000..ae1829f --- /dev/null +++ b/doc/keycloak_setup/examples/connect_automation.py @@ -0,0 +1,19 @@ +"""Log in to xGT as a Keycloak automation service account.""" +import os + +import xgt + +conn = xgt.Connection( + host = "xgt.example.com", + port = 4367, + # For xGT TLS, add the connection flags described in the SSL guide. + auth = xgt.OidcCredentialsAuth( + client_id = "xgt-automation", + # Set if Python needs a Keycloak CA bundle, including when xGT TLS + # supplies a different ssl_server_cert. + # ca_cert_path = "~/.config/rocketgraph/keycloak-ca.pem", + client_secret = os.environ["XGT_AUTOMATION_CLIENT_SECRET"])) + +print("User:", conn.userid) +print("Labels:", conn.get_user_labels()) +print("Test query:", conn.run_job("RETURN 1 AS ok").get_data()) diff --git a/doc/keycloak_setup/examples/connect_user.py b/doc/keycloak_setup/examples/connect_user.py new file mode 100644 index 0000000..78dffce --- /dev/null +++ b/doc/keycloak_setup/examples/connect_user.py @@ -0,0 +1,17 @@ +"""Open a browser to log in to xGT with a normal Keycloak or LDAP account.""" +import xgt + +conn = xgt.Connection( + host = "xgt.example.com", + port = 4367, + # For xGT TLS, add the connection flags described in the SSL guide. + auth = xgt.OidcAuth( + flow = "auth_code", + # Set if Python needs a Keycloak CA bundle, including when xGT TLS + # supplies a different ssl_server_cert. + # ca_cert_path = "~/.config/rocketgraph/keycloak-ca.pem", + force_login = True)) + +print("User:", conn.userid) +print("Labels:", conn.get_user_labels()) +print("Test query:", conn.run_job("RETURN 1 AS ok").get_data()) diff --git a/doc/keycloak_setup/examples/keycloak_ca_values.yaml b/doc/keycloak_setup/examples/keycloak_ca_values.yaml new file mode 100644 index 0000000..0eba774 --- /dev/null +++ b/doc/keycloak_setup/examples/keycloak_ca_values.yaml @@ -0,0 +1,18 @@ +# Simplest CA setup for Keycloak using a private company CA. +# Stock xGT/MC images do not include your company's private CA. +# Skip only if their application trust stores already trust Keycloak HTTPS. +# Requires Rocketgraph chart 0.5.0. +# Existing ConfigMap/files PVC: set ca_cert in the mounted xgtd.conf; +# omit keycloak_values.yaml from the Helm command and keep this overlay. +# First create Secret keycloak-ca with key oidc-ca.pem in the release namespace. +# Apply after the existing deployment values and keycloak_values.yaml. +# This mounts the public CA bundle in xGT and the Mission Control backend. +xgt: + oidc: + caCertExistingSecret: keycloak-ca +# Omit this backend section when Mission Control is disabled. +backend: + oidc: + caCert: "" + caCertExistingSecret: keycloak-ca + tlsVerify: /etc/ssl/certs/oidc-ca.pem diff --git a/doc/keycloak_setup/examples/keycloak_values.yaml b/doc/keycloak_setup/examples/keycloak_values.yaml new file mode 100644 index 0000000..1cd9c0f --- /dev/null +++ b/doc/keycloak_setup/examples/keycloak_values.yaml @@ -0,0 +1,31 @@ +# Merge into the deployment's existing values; keep its license, hostname, +# images, storage and TLS settings. Update existing mounted config files instead +# if xgt.config.existingConfigMap or a files PVC supplies the configuration. +xgt: + config: + # Reuse your existing groups and labels; these names are examples. + # The rocketgraph-automation group and automation label are optional. + grouplabelCsv: | + group,label + xgtd,xgtadmin + rocketgraph-ldap-admins,xgtadmin + rocketgraph-ldap-users,data-users + rocketgraph-automation,automation + labelCsv: | + label + xgtadmin + data-users + automation + extraConfig: + security.oidc: + issuer: https://keycloak.example.com/realms/rocketgraph + # Default client for normal-user browser login; this is not a username. + # Omit client_id for automation only; Python supplies xgt-automation. + client_id: xgt-browser + audience: xgt + validation_mode: jwt + username_claim: preferred_username + groups_claim: groups + scopes: openid profile email + # If xGT lacks CA trust, see the HTTPS trust page: use keycloak_ca_values.yaml + # or the OpenShift injected ConfigMap alternative openshift_ca_values.yaml. diff --git a/doc/keycloak_setup/examples/mission_control_oidc_secret.yaml b/doc/keycloak_setup/examples/mission_control_oidc_secret.yaml new file mode 100644 index 0000000..e66f345 --- /dev/null +++ b/doc/keycloak_setup/examples/mission_control_oidc_secret.yaml @@ -0,0 +1,9 @@ +# Replace with this Keycloak client's generated secret before applying. +# Apply in the same namespace as the Mission Control Helm release. +apiVersion: v1 +kind: Secret +metadata: + name: mission-control-oidc +type: Opaque +stringData: + MC_OIDC_CLIENT_SECRET: REPLACE_WITH_MISSION_CONTROL_CLIENT_SECRET diff --git a/doc/keycloak_setup/examples/mission_control_route.yaml b/doc/keycloak_setup/examples/mission_control_route.yaml new file mode 100644 index 0000000..2786eb7 --- /dev/null +++ b/doc/keycloak_setup/examples/mission_control_route.yaml @@ -0,0 +1,16 @@ +# Replace host and Service name. The hostname must be covered by the ingress +# certificate, or the administrator must configure a matching Route certificate. +apiVersion: route.openshift.io/v1 +kind: Route +metadata: + name: mission-control +spec: + host: mc.example.com + to: + kind: Service + name: YOUR_RELEASE-frontend + port: + targetPort: http + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect diff --git a/doc/keycloak_setup/examples/mission_control_values.yaml b/doc/keycloak_setup/examples/mission_control_values.yaml new file mode 100644 index 0000000..b47e21e --- /dev/null +++ b/doc/keycloak_setup/examples/mission_control_values.yaml @@ -0,0 +1,19 @@ +# Merge with the release's existing values, keeping xGT OIDC, mappings, +# image/FIPS/SCC settings, license, hostname and storage configuration. +missionControl: + enabled: true +frontend: + tls: + external: true # HTTPS terminates at the OpenShift edge Route. +backend: + env: + XGT_AUTH_TYPES: "['OidcAuth']" + MC_DEFAULT_XGT_PORT: "4367" + oidc: + clientId: mission-control + existingSecret: mission-control-oidc + # Replace with the public URL; also register its callback in Keycloak. + frontendUrl: https://mc.example.com +mongodb: + # For an external MongoDB, set false and retain its URI/Secret settings. + enabled: true diff --git a/doc/keycloak_setup/examples/openshift_ca_values.yaml b/doc/keycloak_setup/examples/openshift_ca_values.yaml new file mode 100644 index 0000000..d1ace9f --- /dev/null +++ b/doc/keycloak_setup/examples/openshift_ca_values.yaml @@ -0,0 +1,27 @@ +# Use only when trusted-ca-bundle includes the CA for the Keycloak endpoint. +# Apply after the deployment values and keycloak_values.yaml. +# Existing config/PVC: remove extraConfig and edit ca_cert in the mounted file. +xgt: + oidc: + caCert: "" + caCertExistingSecret: "" + extraConfig: + security.oidc: + ca_cert: /etc/keycloak-ca/ca-bundle.crt + extraVolumes: + - name: keycloak-trusted-ca + configMap: + name: trusted-ca-bundle + items: + - key: ca-bundle.crt + path: ca-bundle.crt + extraVolumeMounts: + - name: keycloak-trusted-ca + mountPath: /etc/keycloak-ca + readOnly: true +backend: + oidc: + caCert: "" + caCertExistingSecret: "" + # Mission Control also requires backend_trusted_ca_patch.yaml. + tlsVerify: /etc/keycloak-ca/ca-bundle.crt diff --git a/doc/keycloak_setup/examples/openshift_trusted_ca.yaml b/doc/keycloak_setup/examples/openshift_trusted_ca.yaml new file mode 100644 index 0000000..5627db2 --- /dev/null +++ b/doc/keycloak_setup/examples/openshift_trusted_ca.yaml @@ -0,0 +1,8 @@ +# Optional: ask OpenShift to populate the cluster's merged trusted CA bundle. +# Use a dedicated empty ConfigMap in the xGT namespace; OpenShift owns its data. +apiVersion: v1 +kind: ConfigMap +metadata: + name: trusted-ca-bundle + labels: + config.openshift.io/inject-trusted-cabundle: "true" diff --git a/doc/keycloak_setup/https_trust.md b/doc/keycloak_setup/https_trust.md new file mode 100644 index 0000000..c8a3872 --- /dev/null +++ b/doc/keycloak_setup/https_trust.md @@ -0,0 +1,197 @@ +[Keycloak Setup](README.md) + +# HTTPS Trust for Keycloak + +Python obtains tokens over HTTPS, while xGT fetches Keycloak's discovery information and signing keys over HTTPS. Mission Control's backend and the user's browser also connect to Keycloak when used. Check each component's trust separately. The Helm examples on this page use Rocketgraph chart **0.5.0**. + +Skip the corresponding CA setting when that application already trusts the issuer's certificate. For a private company CA, the simplest Helm setup is an approved PEM bundle mounted through a Secret. Trust on an OpenShift node or in a browser does not establish trust inside the stock containers. + +These public CA certificates are separate from JWT signing keys, client secrets and private keys. If a Route or proxy terminates Keycloak HTTPS, trust the CA that issued the certificate seen at that endpoint, and ensure the certificate covers the hostname in the issuer URL. + +## 1. Obtain the Approved CA Bundle + +Ask the Keycloak or PKI administrator for the public CA bundle in PEM format, including the trusted root and required intermediates. Save it as `keycloak-ca.pem`. A PEM certificate contains `BEGIN CERTIFICATE` and `END CERTIFICATE` lines; renaming another format to `.pem` does not convert it. A deliberately self-signed server certificate can itself be a trust anchor. + +## 2. Configure the Python Machine and Browser + +On the Python machine, put the approved bundle at a stable path: + +``` bash +mkdir -p "$HOME/.config/rocketgraph" +cp ./keycloak-ca.pem "$HOME/.config/rocketgraph/keycloak-ca.pem" +``` + +Set `ca_cert_path` on `xgt.OidcAuth` or `xgt.OidcCredentialsAuth`, using the path on that machine: + +``` python +auth = xgt.OidcAuth( + flow = "auth_code", + ca_cert_path = "~/.config/rocketgraph/keycloak-ca.pem") +``` + +The SDK expands `~`. The same parameter works on the automation authentication object. Copying the file alone does not configure trust. Import the approved CA into the browser's certificate store or the OS store it uses if needed; Python's setting does not configure the browser. + +With SDK 2.7.1, if xGT TLS is enabled and `ca_cert_path` is omitted, the client uses `ssl_server_cert` for Keycloak HTTPS too. If that file trusts only xGT's CA, explicitly set `ca_cert_path` to a bundle that trusts Keycloak. This also applies to publicly issued Keycloak certificates: the explicit bundle must include their trusted CA roots. A bundle covering both endpoints works, but each connection can use its own bundle. + +## 3. Mount the CA Through a Helm Secret + +On the machine running `oc`, create the Secret in the application namespace. The source filename can vary; these examples use the default Secret key `oidc-ca.pem`: + +``` bash +oc -n YOUR_NAMESPACE create secret generic keycloak-ca \ + --from-file=oidc-ca.pem=./keycloak-ca.pem \ + --dry-run=client -o yaml | oc -n YOUR_NAMESPACE apply -f - +``` + +Download [keycloak_ca_values.yaml](examples/keycloak_ca_values.yaml) or save this overlay: + +``` yaml +# Simplest CA setup for Keycloak using a private company CA. +# Stock xGT/MC images do not include your company's private CA. +# Skip only if their application trust stores already trust Keycloak HTTPS. +# Requires Rocketgraph chart 0.5.0. +# Existing ConfigMap/files PVC: set ca_cert in the mounted xgtd.conf; +# omit keycloak_values.yaml from the Helm command and keep this overlay. +# First create Secret keycloak-ca with key oidc-ca.pem in the release namespace. +# Apply after the existing deployment values and keycloak_values.yaml. +# This mounts the public CA bundle in xGT and the Mission Control backend. +xgt: + oidc: + caCertExistingSecret: keycloak-ca +# Omit this backend section when Mission Control is disabled. +backend: + oidc: + caCert: "" + caCertExistingSecret: keycloak-ca + tlsVerify: /etc/ssl/certs/oidc-ca.pem +``` + +`xgt.oidc.caCertExistingSecret` mounts the bundle at `/etc/ssl/certs/oidc-ca.pem` in xGT. The chart fills in `security.oidc.ca_cert` in generated configuration when the field is absent; no `xgt.extraConfig` CA override is needed. For Mission Control, `backend.oidc.caCertExistingSecret` supplies its backend's mount, and `tlsVerify` selects that file for Keycloak HTTPS. Omit the backend settings when Mission Control is disabled. + +To reuse a Secret with another CA key, set `xgt.oidc.secretKeys.caCert` and, when used, `backend.oidc.secretKeys.caCert` to that key name. Each component can use the same Secret or a different bundle. Mounting at an arbitrary path does not automatically configure application trust. + +``` bash +helm upgrade YOUR_RELEASE ../../charts/rocketgraph -n YOUR_NAMESPACE \ + -f YOUR_EXISTING_VALUES.yaml -f examples/keycloak_values.yaml \ + -f examples/keycloak_ca_values.yaml +``` + +If an existing ConfigMap or files PVC supplies `xgtd.conf`, omit `examples/keycloak_values.yaml` and keep the CA Secret overlay. Set `security.oidc.ca_cert` in the mounted configuration to `/etc/ssl/certs/oidc-ca.pem` and edit its CSV files directly. + +For a non-container xGT server, put the approved bundle at a readable path, set `security.oidc.ca_cert` to it, and restart xGT. The Python machine still uses its own local CA path. + +## Alternative: Mount an OpenShift-Injected Bundle + +Use this **instead of the CA Secret overlay** when the cluster's trusted bundle already includes the CA needed for the Keycloak endpoint. An administrator must register a missing company CA in cluster trust first. Injection does not automatically trust every Route certificate or install certificates in a pod. + +Download [openshift_trusted_ca.yaml](examples/openshift_trusted_ca.yaml) and create the dedicated ConfigMap: + +``` yaml +# Optional: ask OpenShift to populate the cluster's merged trusted CA bundle. +# Use a dedicated empty ConfigMap in the xGT namespace; OpenShift owns its data. +apiVersion: v1 +kind: ConfigMap +metadata: + name: trusted-ca-bundle + labels: + config.openshift.io/inject-trusted-cabundle: "true" +``` + +``` bash +oc -n YOUR_NAMESPACE apply -f examples/openshift_trusted_ca.yaml +oc -n YOUR_NAMESPACE get configmap trusted-ca-bundle \ + -o jsonpath='{.data.ca-bundle\.crt}' +``` + +The injection mechanism uses a **label**, not an annotation. Wait for a non-empty `ca-bundle.crt` containing the required CA. Do not add the service CA injection annotation to the same ConfigMap; it is a different trust bundle. See [OpenShift custom PKI](https://docs.redhat.com/en/documentation/openshift_container_platform/4.15/html/networking/configuring-a-custom-pki). + +Download [openshift_ca_values.yaml](examples/openshift_ca_values.yaml) and apply it after the authentication overlay: + +``` yaml +# Use only when trusted-ca-bundle includes the CA for the Keycloak endpoint. +# Apply after the deployment values and keycloak_values.yaml. +# Existing config/PVC: remove extraConfig and edit ca_cert in the mounted file. +xgt: + oidc: + caCert: "" + caCertExistingSecret: "" + extraConfig: + security.oidc: + ca_cert: /etc/keycloak-ca/ca-bundle.crt + extraVolumes: + - name: keycloak-trusted-ca + configMap: + name: trusted-ca-bundle + items: + - key: ca-bundle.crt + path: ca-bundle.crt + extraVolumeMounts: + - name: keycloak-trusted-ca + mountPath: /etc/keycloak-ca + readOnly: true +backend: + oidc: + caCert: "" + caCertExistingSecret: "" + # Mission Control also requires backend_trusted_ca_patch.yaml. + tlsVerify: /etc/keycloak-ca/ca-bundle.crt +``` + +``` bash +helm upgrade YOUR_RELEASE ../../charts/rocketgraph -n YOUR_NAMESPACE \ + -f YOUR_EXISTING_VALUES.yaml -f examples/keycloak_values.yaml \ + -f examples/openshift_ca_values.yaml +``` + +The xGT pod mounts the ConfigMap directly at `/etc/keycloak-ca`; xGT uses `/etc/keycloak-ca/ca-bundle.crt` explicitly. This avoids image-specific system trust-store paths. Merge existing extra volumes and mounts into these lists; Helm replaces lists when combining values files. + +For external configuration, omit `examples/keycloak_values.yaml`, remove `xgt.extraConfig` from the CA overlay, and set the mounted OIDC `ca_cert` to `/etc/keycloak-ca/ca-bundle.crt` instead. + +If Mission Control is enabled, also download [backend_trusted_ca_patch.yaml](examples/backend_trusted_ca_patch.yaml) and mount the same ConfigMap in its backend: + +``` yaml +spec: + template: + spec: + volumes: + - name: keycloak-trusted-ca + configMap: + name: trusted-ca-bundle + items: + - key: ca-bundle.crt + path: ca-bundle.crt + containers: + - name: backend + volumeMounts: + - name: keycloak-trusted-ca + mountPath: /etc/keycloak-ca + readOnly: true +``` + +``` bash +oc -n YOUR_NAMESPACE patch deployment YOUR_RELEASE-backend \ + --type=strategic --patch-file=examples/backend_trusted_ca_patch.yaml +``` + +The chart has no backend extra-volume setting. Keep this patch in your GitOps/deployment workflow and reapply it after Helm upgrades. The overlay's `backend.oidc.tlsVerify` points to the backend's mounted bundle. Skip the patch when Mission Control is disabled. This container mount does not configure trust on the Python machine or in the browser. + +## Restart and Verify + +Restart the applications after CA changes. The CA Secret method uses `subPath` mounts, so changing an existing Secret's contents alone does not refresh the mounted file: + +``` bash +oc -n YOUR_NAMESPACE rollout restart deployment/YOUR_RELEASE-xgt +oc -n YOUR_NAMESPACE rollout restart deployment/YOUR_RELEASE-backend +``` + +Use the actual resource names, and omit the backend command for xGT-only releases. Confirm DNS and HTTPS from the Python machine: + +``` bash +getent hosts keycloak.example.com +curl --fail --show-error --cacert ./keycloak-ca.pem \ + https://keycloak.example.com/realms/rocketgraph/.well-known/openid-configuration +``` + +An unknown issuer points to CA trust or an incomplete certificate chain; a hostname mismatch points to the certificate's names. A DNS failure needs a DNS fix, not another CA file. Keep HTTPS verification enabled. + +Python → xGT and backend → xGT TLS protect different connections from Keycloak HTTPS. Use [Python connection TLS settings](https://docs.rocketgraph.com/user_ref/usingxgt/connecting_to_server.html#connect-via-ssl-encrypted-network-connection) and retain the deployment's xGT certificate settings; enabling OIDC does not enable TLS on port 4367. For SDK 2.7.1, explicitly set the Keycloak `ca_cert_path` when the xGT TLS CA bundle does not also trust Keycloak. diff --git a/doc/keycloak_setup/images/audience-mapper-framed.svg b/doc/keycloak_setup/images/audience-mapper-framed.svg new file mode 100644 index 0000000..47cbfc5 --- /dev/null +++ b/doc/keycloak_setup/images/audience-mapper-framed.svg @@ -0,0 +1,5 @@ + + Audience mapper adding xgt as a custom audience to the access token. + + + diff --git a/doc/keycloak_setup/images/audience-mapper.png b/doc/keycloak_setup/images/audience-mapper.png new file mode 100644 index 0000000..0c087e4 Binary files /dev/null and b/doc/keycloak_setup/images/audience-mapper.png differ diff --git a/doc/keycloak_setup/images/automation-capabilities-framed.svg b/doc/keycloak_setup/images/automation-capabilities-framed.svg new file mode 100644 index 0000000..8e56e88 --- /dev/null +++ b/doc/keycloak_setup/images/automation-capabilities-framed.svg @@ -0,0 +1,5 @@ + + Automation client with client authentication and service accounts on. + + + diff --git a/doc/keycloak_setup/images/automation-capabilities.png b/doc/keycloak_setup/images/automation-capabilities.png new file mode 100644 index 0000000..c96fc2b Binary files /dev/null and b/doc/keycloak_setup/images/automation-capabilities.png differ diff --git a/doc/keycloak_setup/images/automation-credentials-framed.svg b/doc/keycloak_setup/images/automation-credentials-framed.svg new file mode 100644 index 0000000..286133b --- /dev/null +++ b/doc/keycloak_setup/images/automation-credentials-framed.svg @@ -0,0 +1,5 @@ + + Credentials tab showing the masked automation client secret. + + + diff --git a/doc/keycloak_setup/images/automation-credentials.png b/doc/keycloak_setup/images/automation-credentials.png new file mode 100644 index 0000000..eae4087 Binary files /dev/null and b/doc/keycloak_setup/images/automation-credentials.png differ diff --git a/doc/keycloak_setup/images/browser-callback-framed.svg b/doc/keycloak_setup/images/browser-callback-framed.svg new file mode 100644 index 0000000..29b135c --- /dev/null +++ b/doc/keycloak_setup/images/browser-callback-framed.svg @@ -0,0 +1,5 @@ + + Valid redirect URI http://127.0.0.1:8765/callback. + + + diff --git a/doc/keycloak_setup/images/browser-callback.png b/doc/keycloak_setup/images/browser-callback.png new file mode 100644 index 0000000..f801c80 Binary files /dev/null and b/doc/keycloak_setup/images/browser-callback.png differ diff --git a/doc/keycloak_setup/images/browser-capabilities-framed.svg b/doc/keycloak_setup/images/browser-capabilities-framed.svg new file mode 100644 index 0000000..3c8b9df --- /dev/null +++ b/doc/keycloak_setup/images/browser-capabilities-framed.svg @@ -0,0 +1,5 @@ + + Public browser client with Standard flow and S256 PKCE enabled. + + + diff --git a/doc/keycloak_setup/images/browser-capabilities.png b/doc/keycloak_setup/images/browser-capabilities.png new file mode 100644 index 0000000..edc113a Binary files /dev/null and b/doc/keycloak_setup/images/browser-capabilities.png differ diff --git a/doc/keycloak_setup/images/groups-mapper-framed.svg b/doc/keycloak_setup/images/groups-mapper-framed.svg new file mode 100644 index 0000000..db803de --- /dev/null +++ b/doc/keycloak_setup/images/groups-mapper-framed.svg @@ -0,0 +1,5 @@ + + Group Membership mapper with groups and inclusion in access tokens. + + + diff --git a/doc/keycloak_setup/images/groups-mapper.png b/doc/keycloak_setup/images/groups-mapper.png new file mode 100644 index 0000000..b483f1d Binary files /dev/null and b/doc/keycloak_setup/images/groups-mapper.png differ diff --git a/doc/keycloak_setup/images/ldap-group-mapper-framed.svg b/doc/keycloak_setup/images/ldap-group-mapper-framed.svg new file mode 100644 index 0000000..80a3e02 --- /dev/null +++ b/doc/keycloak_setup/images/ldap-group-mapper-framed.svg @@ -0,0 +1,5 @@ + + LDAP group mapper with groupOfNames, member DN and read-only mode. + + + diff --git a/doc/keycloak_setup/images/ldap-group-mapper.png b/doc/keycloak_setup/images/ldap-group-mapper.png new file mode 100644 index 0000000..70c7989 Binary files /dev/null and b/doc/keycloak_setup/images/ldap-group-mapper.png differ diff --git a/doc/keycloak_setup/images/service-account-join-groups.png b/doc/keycloak_setup/images/service-account-join-groups.png new file mode 100644 index 0000000..d1262ab Binary files /dev/null and b/doc/keycloak_setup/images/service-account-join-groups.png differ diff --git a/doc/keycloak_setup/images/service-account-link-framed.svg b/doc/keycloak_setup/images/service-account-link-framed.svg new file mode 100644 index 0000000..080fda8 --- /dev/null +++ b/doc/keycloak_setup/images/service-account-link-framed.svg @@ -0,0 +1,5 @@ + + Service account roles tab linking to service-account-xgt-automation. + + + diff --git a/doc/keycloak_setup/images/service-account-link.png b/doc/keycloak_setup/images/service-account-link.png new file mode 100644 index 0000000..1c9da43 Binary files /dev/null and b/doc/keycloak_setup/images/service-account-link.png differ diff --git a/doc/keycloak_setup/ldap.md b/doc/keycloak_setup/ldap.md new file mode 100644 index 0000000..e0942a3 --- /dev/null +++ b/doc/keycloak_setup/ldap.md @@ -0,0 +1,45 @@ +[Keycloak Setup](README.md) + +# LDAP Federation with Keycloak + +Use this when human users and groups already exist in LDAP. Keycloak validates their passwords and includes their groups in access tokens. xGT does not bind to LDAP. The Keycloak automation service account does not need LDAP federation. + +## Add the LDAP Provider + +In your realm, open **User federation → Add LDAP provider**. Obtain the LDAP settings and bind credentials from the directory administrator. For an OpenLDAP directory using `uid` and `groupOfNames`: + +| Setting | Example | +|----|----| +| Connection URL | `ldaps://ldap.example.com:636` | +| Bind DN / Bind credentials | Directory administrator's read-only application account and password | +| Users DN | `ou=people,dc=example,dc=com` | +| Username and RDN LDAP attributes | `uid` | +| UUID LDAP attribute | `entryUUID` | +| User object classes | `inetOrgPerson` | +| Edit mode / Import users | `READ_ONLY` / On | + +Adapt these attributes to the actual directory; Active Directory uses different schema settings. Keycloak must reach LDAP and trust its LDAPS certificate. Test the connection and authentication, then save. + +## Add the LDAP Group Mapper + +Open the provider's **Mappers → Add mapper** and select `group-ldap-mapper`. This imports groups into Keycloak; it is separate from the Group Membership token mapper on each OIDC client. + +| Setting | Example | +|----|----| +| LDAP Groups DN | `ou=groups,dc=example,dc=com` | +| Group Name LDAP Attribute / Group Object Classes | `cn` / `groupOfNames` | +| Membership LDAP Attribute / Membership Attribute Type | `member` / `DN` | +| Membership User LDAP Attribute | `uid` | +| Mode | `READ_ONLY` | +| User Groups Retrieve Strategy | `LOAD_GROUPS_BY_MEMBER_ATTRIBUTE` | +| Preserve Group Inheritance | Off for flat group names | + +LDAP group mapper with groupOfNames, member DN and read-only mode. + +The screenshot uses a test directory DN; substitute your own directory's DN. + +Run **Sync LDAP Groups to Keycloak** on the mapper and **Synchronize all users** on the provider. Confirm the resulting user memberships, and use their exact group names in xGT's `grouplabel.csv`. + +User synchronization and the group mapper's group synchronization are separate operations. Configure recurring synchronization appropriate for the directory, and verify it covers both. Reconnect with a fresh token and xGT session after memberships change. + +An automation service account can join an existing synchronized group through its client's **Service account roles → username → Groups → Join Group**. That membership is stored in Keycloak, not written back to LDAP. Group creation is optional; return to [Keycloak setup](README.md) for token mappers and xGT label mappings. See [Keycloak LDAP federation](https://www.keycloak.org/docs/latest/server_admin/index.html#_ldap) for directory-specific options. diff --git a/doc/keycloak_setup/mission_control.md b/doc/keycloak_setup/mission_control.md new file mode 100644 index 0000000..f0740d8 --- /dev/null +++ b/doc/keycloak_setup/mission_control.md @@ -0,0 +1,128 @@ +[Keycloak Setup](README.md) + +# Mission Control with Keycloak + +Use these steps with an existing xGT Helm release configured as described in [Keycloak setup](README.md). Keep its images, license, hostname, storage, resource and TLS settings. All YAML needed here is included on this page and available to download. + +## 1. Register the Mission Control Client + +Create an OpenID Connect client named `mission-control`. Enable **Client authentication** and **Standard flow**; disable **Service account roles**, **Direct access grants** and **Implicit flow**. Mission Control 2.7.0 does not send PKCE, so do not require PKCE on this client. + +Register the exact callback in **Valid redirect URIs**: + +``` text +https://mc.example.com/api/login/oidc/callback +``` + +Replace the hostname with the HTTPS address people will open in their browser. Add the Audience and Group Membership mappers from the main guide to `mission-control-dedicated`: access tokens must contain audience `xgt` and the user's `groups`. Keep the default `profile` and `email` scopes. + +Open **Credentials** and copy this client's generated secret. It is separate from the automation secret and the Keycloak administrator password. + +## 2. Store the Client Secret + +Download [mission_control_oidc_secret.yaml](examples/mission_control_oidc_secret.yaml) and replace the placeholder: + +``` yaml +# Replace with this Keycloak client's generated secret before applying. +# Apply in the same namespace as the Mission Control Helm release. +apiVersion: v1 +kind: Secret +metadata: + name: mission-control-oidc +type: Opaque +stringData: + MC_OIDC_CLIENT_SECRET: REPLACE_WITH_MISSION_CONTROL_CLIENT_SECRET +``` + +``` bash +oc -n YOUR_NAMESPACE apply -f examples/mission_control_oidc_secret.yaml +``` + +The chart passes `MC_OIDC_CLIENT_SECRET` to the backend. xGT still needs no client secret in JWT mode. Store real secrets through the deployment tool's secret management instead of committing them to a public repository. + +## 3. Apply the Helm Values + +Download [mission_control_values.yaml](examples/mission_control_values.yaml) and replace the public hostname: + +``` yaml +# Merge with the release's existing values, keeping xGT OIDC, mappings, +# image/FIPS/SCC settings, license, hostname and storage configuration. +missionControl: + enabled: true +frontend: + tls: + external: true # HTTPS terminates at the OpenShift edge Route. +backend: + env: + XGT_AUTH_TYPES: "['OidcAuth']" + MC_DEFAULT_XGT_PORT: "4367" + oidc: + clientId: mission-control + existingSecret: mission-control-oidc + # Replace with the public URL; also register its callback in Keycloak. + frontendUrl: https://mc.example.com +mongodb: + # For an external MongoDB, set false and retain its URI/Secret settings. + enabled: true +``` + +``` bash +helm upgrade YOUR_RELEASE ../../charts/rocketgraph -n YOUR_NAMESPACE \ + -f YOUR_EXISTING_VALUES.yaml -f examples/keycloak_values.yaml \ + -f examples/mission_control_values.yaml +``` + +The backend discovers the issuer and scopes from xGT; `clientId` selects its own confidential client. `frontendUrl` sets the public origin explicitly in this example. Omit it when the deployment already derives the correct public URL. Separate issuer, scopes and redirect URI overrides are unnecessary here. + +For an external configuration ConfigMap or files PVC, omit `examples/keycloak_values.yaml` and configure the mounted xGT OIDC settings directly. For a private CA, apply the chosen CA overlay from [HTTPS trust](https_trust.md) last, and apply its backend patch if using direct ConfigMap injection. + +The example enables bundled MongoDB. If using an external database, retain `mongodb.enabled: false` and its `externalUriSecret` or `externalUri`. For an xGT in another release, set `backend.env.MC_DEFAULT_XGT_HOST` and `backend.oidc.xgtAllowedHosts` to its reachable endpoint. Backend-to-xGT TLS requires its own CA and, if enabled, mTLS client certificate/key; Keycloak's CA does not configure that connection. + +## 4. Expose Mission Control with an HTTPS Route + +Keep an existing HTTPS Route if it already serves the registered hostname. Otherwise download [mission_control_route.yaml](examples/mission_control_route.yaml) and replace the hostname and frontend Service name: + +``` yaml +# Replace host and Service name. The hostname must be covered by the ingress +# certificate, or the administrator must configure a matching Route certificate. +apiVersion: route.openshift.io/v1 +kind: Route +metadata: + name: mission-control +spec: + host: mc.example.com + to: + kind: Service + name: YOUR_RELEASE-frontend + port: + targetPort: http + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect +``` + +``` bash +oc -n YOUR_NAMESPACE apply -f examples/mission_control_route.yaml +``` + +The edge Route terminates HTTPS; `frontend.tls.external: true` tells the backend that users reach the frontend over HTTPS. If the frontend itself terminates HTTPS, retain its existing certificate settings instead. + +The Route uses the ingress controller's default certificate. Choose a hostname covered by it or have an administrator configure the Route certificate. The browser must resolve that hostname and trust its certificate. xGT, the backend and the browser must also reach the Keycloak issuer hostname. These endpoints can use internal DNS; login does not require public internet access. + +## 5. Check the Rollout and Sign In + +``` bash +oc -n YOUR_NAMESPACE rollout status deployment/YOUR_RELEASE-backend +oc -n YOUR_NAMESPACE rollout status deployment/YOUR_RELEASE-frontend +oc -n YOUR_NAMESPACE get route mission-control +``` + +Open `https://mc.example.com`, sign in with a normal Keycloak or LDAP account, and run `RETURN 1 AS ok`. Check its mapped labels and expected data access. After replacing an existing client secret, restart the backend to reload it: + +``` bash +oc -n YOUR_NAMESPACE rollout restart deployment/YOUR_RELEASE-backend +``` + +For invalid redirects, compare the registered URI with the actual callback. For audience or label errors, check this client's token mappers. For HTTPS errors, check the backend's Keycloak trust and the browser's trust separately. + +For an air-gapped installation, obtain the chart, Python package, images and CA bundles beforehand, and point the image repositories to the internal registry. The YAML can also be applied through GitOps or a deployment pipeline; `oc` shows the equivalent manual operations. diff --git a/doc/oidc_configuration.md b/doc/oidc_configuration.md index 56736b6..2899be7 100644 --- a/doc/oidc_configuration.md +++ b/doc/oidc_configuration.md @@ -160,6 +160,8 @@ The first value selects the host file to mount; the second tells the backend to ## Keycloak Example +For an illustrated walkthrough covering normal-user Python login, automation service accounts, group and audience mappers, optional LDAP federation and HTTPS trust, start with [Keycloak Setup for xGT](keycloak_setup/README.md). The [Mission Control steps](keycloak_setup/mission_control.md) include complete YAML and commands. Those Helm examples require chart **0.5.0**. + Use a separate confidential client, such as `mission-control`, with **Client authentication** and **Standard flow** enabled. Register `https://mc.example.com/api/login/oidc/callback`. Add Group Membership and Audience mappers to its access tokens, using the groups claim and audience configured on xGT. Mission Control 2.7.0 does not send a PKCE challenge; do not require PKCE for this confidential client. Keep the separate Python browser client public with PKCE `S256` required and callback `http://127.0.0.1:8765/callback`. @@ -174,6 +176,8 @@ Leave the issuer and scopes unset to discover them from xGT. Supply private-CA s ## OpenShift Example +For a deployment checklist using chart **0.5.0**, see the [OpenShift and LDAP quickstart](openshift_ldap_quickstart.md). + This example uses **OpenShift OAuth2**, through the existing `OidcAuth` interface. An OpenShift `OAuthClient` is a cluster-wide application registration. Its `metadata.name` is the client ID, and its `secret` authenticates the application diff --git a/doc/openshift_ldap_quickstart.md b/doc/openshift_ldap_quickstart.md new file mode 100644 index 0000000..34c5d67 --- /dev/null +++ b/doc/openshift_ldap_quickstart.md @@ -0,0 +1,137 @@ +# OpenShift and LDAP Quickstart + +Use OpenShift to authenticate LDAP users, then map their OpenShift groups to xGT labels. Automated jobs use OpenShift service-account tokens. xGT does not connect directly to LDAP in this configuration. + +Experimental: OIDC authentication may change in future releases. + +This checklist is for the OpenShift and xGT administrators. It assumes an existing LDAP directory, permission to configure OpenShift authentication, and an xGT 2.7.1 deployment using version **0.5.0** of the [Rocketgraph Helm chart](https://github.com/Rocketgraphai/rocketgraph/tree/main/charts/rocketgraph). Replace example hostnames, namespace `xgt`, and group names with your own. For the full configuration reference, see [xGT OpenShift reference](https://docs.rocketgraph.com/sysadmin_guide/user_authentication.html#openshift). + +For a complete test deployment with LDAP provider and group-sync YAML, follow the [OpenShift test-server guide](openshift_test_server/README.md). For Keycloak-issued tokens instead, see [Keycloak Setup](keycloak_setup/README.md). + +## 1. Connect LDAP and Synchronize Groups + +Configure an LDAP identity provider in OpenShift with the directory URL, bind credentials, user attributes, and trusted CA. Prepare an `LDAPSyncConfig` matching the directory schema and a whitelist of the groups to import. Preview the changes, then apply them as an authorized administrator: + +``` shell +oc adm groups sync --sync-config=ldap-sync.yaml --whitelist=groups.txt +oc adm groups sync --sync-config=ldap-sync.yaml --whitelist=groups.txt --confirm +``` + +For a simple access test, use LDAP users Alice and Bob: put Alice in `xgt-admins` and `xgt-users`, and Bob only in `xgt-users`. Confirm their memberships in OpenShift's Group objects. Password checks and group sync are separate; schedule synchronization or rerun it after directory changes, then start new xGT sessions. + +## 2. Register the OAuth Client and Prepare Mounts + +Register an OpenShift OAuthClient named `xgt-client` with a generated secret, `user:info` in `scopeRestrictions`, and these `redirectURIs`: + +- `http://127.0.0.1:8765/callback` for Python browser login. +- `https://mc.apps.example.com/api/login/oidc/callback` if using Mission Control. + +The OAuthClient manifest is in [xGT OpenShift reference](https://docs.rocketgraph.com/sysadmin_guide/user_authentication.html#openshift). Supply its secret separately to Python clients and Mission Control; discovery does not provide credentials. + +In the application namespace, prepare Secret `xgt-license` with the default key `xgtd.lic`, Secret `xgt-oauth-client` with default key `MC_OIDC_CLIENT_SECRET`, and Secret `oidc-ca` with default key `oidc-ca.pem`. For existing Secrets with other keys, set `xgt.license.secretKey`, `backend.oidc.secretKeys.clientSecret`, `xgt.oidc.secretKeys.caCert` and `backend.oidc.secretKeys.caCert` as appropriate. The CA bundle must trust the OAuth and OpenShift User API endpoints. The chart mounts these and its configuration: + +| Content | Container path | +|---------------------------|----------------------------------------------| +| License | `/license/xgtd.lic` | +| Server configuration | `/conf/xgtd.conf` | +| Group mappings and labels | `/conf/grouplabel.csv` and `/conf/label.csv` | +| Trusted CA bundle | `/etc/ssl/certs/oidc-ca.pem` | +| Persistent data | `/data` | + +Set `xgt.hostname` to a hostname covered by the license. The chart sets the container's OS hostname without changing the generated Pod or Service name; no custom StatefulSet is needed. Replace `demo-xgt-test` below with your licensed hostname, and have the OpenShift administrator approve the images' SCC requirements. + +## 3. Configure xGT and Mission Control + +Merge these settings into the deployment's Helm values and apply them using the chart's installation or upgrade instructions: + +``` yaml +xgt: + hostname: demo-xgt-test # Replace with your licensed hostname. + image: + tag: 2.7.1 + license: + existingSecret: xgt-license + oidc: + caCertExistingSecret: oidc-ca + config: + grouplabelCsv: | + group,label + xgtd,xgtadmin + xgt-admins,xgtadmin + xgt-users,data-users + labelCsv: | + label + xgtadmin + data-users + extraConfig: + security.oidc: + issuer: https://oauth-openshift.apps.example.com + client_id: xgt-client + validation_mode: openshift_userapi + openshift_user_api_uri: https://kubernetes.default.svc/apis/user.openshift.io/v1/users/~ + username_claim: metadata.name + groups_claim: groups + scopes: user:info +frontend: + tls: + external: true # For an HTTPS edge Route. +backend: + env: + XGT_AUTH_TYPES: "['OidcAuth']" + MC_DEFAULT_XGT_PORT: '4367' + oidc: + existingSecret: xgt-oauth-client + caCertExistingSecret: oidc-ca + tlsVerify: /etc/ssl/certs/oidc-ca.pem + # Set only if proxy headers produce the wrong public URL: + frontendUrl: https://mc.apps.example.com +``` + +`xgt.oidc` supplies xGT's CA mount and fills in `security.oidc.ca_cert` in generated configuration; `backend.oidc` supplies Mission Control's own CA mount. Omit the CA settings when both endpoints are already trusted. Mission Control discovers the issuer, client ID, and `user:info` from xGT. Its callback is derived from the frontend URL; `redirectUri` is an optional override. Configure the HTTPS Route and DNS for the public Mission Control hostname. + +### Using FIPS Images + +To select the chart's FIPS image variants, add this to the Helm values: + +``` yaml +fips: + enabled: true +``` + +Keep the base image tags without a `-fips` suffix; the chart adds it to xGT and Mission Control tags, for example `2.7.1-fips` and `2.7.0-fips`. The bundled MongoDB image switches to `percona/percona-server-mongodb`. An external MongoDB server must be configured separately. + +Image selection alone does not establish FIPS compliance. Verify the host's FIPS mode and the applications' active crypto-provider configuration, and configure TLS for the required connections. When both `fips.enabled` and `mongodb.tls.enabled` are true, the chart adds `--tlsFIPSMode` to MongoDB; provide the required certificates and CA as described in the [Helm FIPS guide](https://github.com/Rocketgraphai/rocketgraph/tree/main/charts/rocketgraph#fips-mode). The OIDC settings above still apply. Repeat the human and automated login, label, and query checks after switching images. + +> [!NOTE] +> **Existing MongoDB volume migration:** Back up the database before replacing Community MongoDB with Percona, and pause applications writing to it during migration. The Percona image uses UID 1001. Existing database files owned by another UID can prevent WiredTiger from starting even with `fsGroup` set. If this occurs, migrate ownership on the database volume to the image's UID using an administrator-approved procedure. This is a migration step for affected volumes, not a requirement to change permissions on every install. + +## 4. Provision Automated Access + +An administrator can issue an expiring token for a service account: + +``` shell +oc -n xgt create serviceaccount xgt-automation +umask 077 +oc -n xgt create token xgt-automation --duration=1h > xgt.token +``` + +Store the token in the job's secret store and use `xgt.BearerTokenAuth`. Renew it before new connections after expiry; see [OpenShift service accounts](https://docs.rocketgraph.com/sysadmin_guide/user_authentication.html#service-accounts) for rotating tokens and the long-lived Secret alternative. + +To grant an automation label, add `system:serviceaccounts:xgt,automation` to `grouplabelCsv` and `automation` to `labelCsv`. This grants the label to every service account in namespace `xgt`. Mapping that group to `xgtadmin` instead grants all of them xGT administration. These groups come from OpenShift, not LDAP. + +## 5. Log In and Verify + +In Mission Control, choose OIDC login, select the LDAP provider on the OpenShift page, and sign in as Alice or Bob. Alice should be an xGT administrator and Bob should have `data-users` without `xgtadmin`. Neither mapping grants OpenShift cluster administration. + +For Python browser login and automated token login, use the examples in [Python OpenShift login examples](https://docs.rocketgraph.com/user_ref/usingxgt/connecting_to_server.html#openshift-login). Clients need a reachable xGT endpoint or an authorized tunnel; configuring OIDC does not open a network path. Configure connection TLS as described in [Python connection TLS settings](https://docs.rocketgraph.com/user_ref/usingxgt/connecting_to_server.html#connect-via-ssl-encrypted-network-connection). + +After connecting, check: + +``` python +print(conn.userid) +print(conn.is_admin) +print(conn.get_user_labels()) +print(conn.run_job("RETURN 1 AS ok").get_data()) +``` + +Expect `[[1]]` from the query. Also verify rejection of an incorrect password and denial of admin-only data to Bob. Check the automation identity and labels separately. Missing LDAP labels call for checking OpenShift group sync and the xGT label files.