-
Notifications
You must be signed in to change notification settings - Fork 124
Add pod-level TLS termination for Keystone and Barbican - 007 WP-4 #12641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
985950b
c17f9f3
a0c6294
0822dbd
1ca16e3
1cbbd6c
9916149
603bda8
f6ef1b0
308c494
302c279
8477e1a
d5ae952
9f6730a
755cc70
8ee71b7
d8692e4
726f600
397c0ed
cbbf332
fc365c9
8117baf
2afcc22
14e79c9
c03eb82
4df157c
d375298
7015eff
58c154c
e88f5a3
4978ee2
bff7901
ba5fff7
ef5424c
8acb16f
37f97ec
0958691
9dfb2b5
49198b4
150f956
9dd9525
e3b0283
4d09252
2bf1532
33be8fb
22c4f98
a80d4b4
1cf559a
eba65ed
bece5ab
e92ecd9
5116ee2
4ab6e94
a2c0b7b
d4645f0
5566246
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,11 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this | |||||
| {{- printf "%s-%s" .Release.Name $name | trunc 63 | replace "_" "-" | trimSuffix "-" -}} | ||||||
| {{- end -}} | ||||||
|
|
||||||
| {{- define "barbican.external_ip" -}} | ||||||
| {{- $svc := .Values.services | default dict -}} | ||||||
| {{- .Values.global.barbican_external_ip | default $svc.externalip -}} | ||||||
| {{- end -}} | ||||||
|
|
||||||
| {{- define "barbican.db_service" }} | ||||||
| {{- include "utils.db_host" . }} | ||||||
| {{- end }} | ||||||
|
|
@@ -39,3 +44,51 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this | |||||
| {{- .Release.Name }}-{{ $name }}-{{ substr 0 4 $hash }}-{{ .Values.imageVersionBarbicanApi | required "Please set barbican.imageVersionBarbicanApi" }} | ||||||
| {{- end }} | ||||||
| {{- end }} | ||||||
|
|
||||||
| {{- define "barbican.tls.serving" -}} | ||||||
| {{- if or (eq .Values.tls.state "transition") (eq .Values.tls.state "enabled") -}}true{{- end -}} | ||||||
| {{- end -}} | ||||||
|
|
||||||
| {{- define "barbican.tls.ingressActive" -}} | ||||||
| {{- if or (eq .Values.tls.state "disabled") (eq .Values.tls.state "transition") -}}true{{- end -}} | ||||||
| {{- end -}} | ||||||
|
|
||||||
| {{- define "barbican.tls.validate" -}} | ||||||
| {{- if not (has .Values.tls.state (list "disabled" "transition" "enabled")) }} | ||||||
| {{- fail "tls.state must be one of: disabled, transition, enabled" }} | ||||||
| {{- end }} | ||||||
| {{- if include "barbican.tls.serving" . }} | ||||||
| {{- if not .Values.tls.keyGeneration }} | ||||||
| {{- fail "tls.keyGeneration is required when TLS is serving (options: go-crypto, hsm-entropy, hsm-full, tpm-entropy)" }} | ||||||
| {{- end }} | ||||||
| {{- if not .Values.tls.keyWrapping }} | ||||||
| {{- fail "tls.keyWrapping is required when TLS is serving (options: none, vault-transit, hsm, tpm)" }} | ||||||
| {{- end }} | ||||||
| {{- if not .Values.tls.keyStorage }} | ||||||
| {{- fail "tls.keyStorage is required when TLS is serving (options: internal-k8s-secret, k8s-secret, vault-secret)" }} | ||||||
| {{- end }} | ||||||
| {{- if and (eq .Values.tls.keyWrapping "none") (eq .Values.tls.keyStorage "k8s-secret") (not .Values.tls.allowInsecureStorage) }} | ||||||
|
rajivmucheli marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [High] Insecure storage guard misses The check only blocks
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. This is intentional and safe, and it was already discussed in an earlier round. |
||||||
| {{- fail "tls: unwrapped keys cannot be stored as plain-text K8s Secrets. Set tls.keyWrapping or tls.keyStorage, or set tls.allowInsecureStorage: true to acknowledge." }} | ||||||
| {{- end }} | ||||||
| {{- $svc := .Values.services | default dict }} | ||||||
| {{- if not (.Values.global.barbican_external_ip | default $svc.externalip) }} | ||||||
| {{- fail "TLS serving requires an external IP (global.barbican_external_ip or services.externalip): the public TLS Service only renders once the external IP is set." }} | ||||||
| {{- end }} | ||||||
| {{- end }} | ||||||
| {{- $dep := lookup "apps/v1" "Deployment" .Release.Namespace "barbican-api" }} | ||||||
| {{- if $dep }} | ||||||
| {{- $current := index (default dict $dep.metadata.annotations) "cloud.sap/tls-state" }} | ||||||
| {{- if has $current (list "disabled" "transition" "enabled") }} | ||||||
| {{- if or (and (eq $current "disabled") (eq .Values.tls.state "enabled")) (and (eq $current "enabled") (eq .Values.tls.state "disabled")) }} | ||||||
| {{- fail (printf "tls.state cannot change directly from %s to %s; move through transition first." $current .Values.tls.state) }} | ||||||
| {{- end }} | ||||||
| {{- end }} | ||||||
| {{- end }} | ||||||
| {{- if eq .Values.tls.state "disabled" }} | ||||||
| {{- $recName := include "barbican_api_endpoint_host_public" . }} | ||||||
| {{- $rec := lookup "disco.stable.sap.cc/v1" "Record" .Release.Namespace $recName }} | ||||||
| {{- if not (empty $rec) }} | ||||||
| {{- fail (printf "tls.state is disabled but the disco Record %s still exists. Delete it and point %s to the ingress address by hand, then re-run." $recName $recName) }} | ||||||
| {{- end }} | ||||||
| {{- end }} | ||||||
| {{- end }} | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| {{- if (include "barbican.tls.serving" .) }} | ||
| {{- include "barbican.tls.validate" . }} | ||
| apiVersion: batch/v1 | ||
| kind: CronJob | ||
| metadata: | ||
| name: {{ .Release.Name }}-tls-rotation | ||
| labels: | ||
| app: {{ template "fullname" . }} | ||
| chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
| release: "{{ .Release.Name }}" | ||
| component: barbican | ||
| type: tls-rotation | ||
| spec: | ||
| schedule: {{ .Values.tls.rotationSchedule | default "0 3 * * 1" | quote }} | ||
| concurrencyPolicy: Forbid | ||
| successfulJobsHistoryLimit: 3 | ||
| failedJobsHistoryLimit: 3 | ||
| jobTemplate: | ||
| spec: | ||
| activeDeadlineSeconds: 600 | ||
| template: | ||
| spec: | ||
| restartPolicy: Never | ||
| serviceAccountName: {{ .Release.Name }}-tls-manager | ||
| containers: | ||
| - name: tls-rotation | ||
| image: {{ .Values.tls.lifecycle.image }}:{{ .Values.tls.lifecycle.imageTag }} | ||
| imagePullPolicy: IfNotPresent | ||
| args: | ||
| - --mode=rotation | ||
| - --namespace={{ .Release.Namespace }} | ||
| - --secret-name={{ .Values.tls.secretName | default "barbican-tls" }} | ||
| - --key-algorithm={{ .Values.tls.keyAlgorithm | default "ECDSAP256" }} | ||
| - --issuer-name={{ .Values.tls.issuerName | default "digicert-issuer" }} | ||
| - --issuer-kind={{ .Values.tls.issuerKind | default "ClusterIssuer" }} | ||
| - --issuer-group={{ .Values.tls.issuerGroup | default "certmanager.cloud.sap" }} | ||
| - --common-name={{ include "barbican_api_endpoint_host_public" . }} | ||
| - --san-dns={{ include "barbican_api_endpoint_host_public" . }} | ||
| - --renewal-threshold-days=30 | ||
| - --key-generation={{ required "tls.keyGeneration is required" .Values.tls.keyGeneration }} | ||
| - --key-wrapping={{ required "tls.keyWrapping is required" .Values.tls.keyWrapping }} | ||
| - --key-storage={{ required "tls.keyStorage is required" .Values.tls.keyStorage }} | ||
| {{- if .Values.tls.allowInsecureStorage }} | ||
| - --allow-insecure-storage | ||
| {{- end }} | ||
| backoffLimit: 3 | ||
|
tz3 marked this conversation as resolved.
|
||
| {{- end }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| {{/* | ||
| Server-level Apache hardening: suppress the version banner, disable the TRACE | ||
| method, and turn off directory listing for the document root. Parsed after the | ||
| packaged apache2.conf so these directives take precedence. | ||
| */}} | ||
|
|
||
| # Suppress server version banner and disable TRACE | ||
| ServerTokens Prod | ||
| ServerSignature Off | ||
| TraceEnable Off | ||
|
|
||
| # Disable directory listing for the document root | ||
| <Directory /var/www/> | ||
| Options FollowSymLinks | ||
| AllowOverride None | ||
| Require all granted | ||
| </Directory> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| {{/* | ||
| Load mod_ssl and its socache dependency via read-only conf so the module is | ||
| available under a read-only root filesystem without a2enmod. mod_headers is | ||
| required for the HTTP security response headers set in the TLS vhost. | ||
| */}} | ||
|
|
||
| LoadModule socache_shmcb_module /usr/lib/apache2/modules/mod_socache_shmcb.so | ||
| LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so | ||
| LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| {{/* | ||
| Apache TLS protocol hardening configuration. | ||
| Configures TLS 1.3/1.2 with compliant cipher suites, PFS, AEAD modes, | ||
| and brainpool curve preference. Shared between Keystone and Barbican. | ||
| */}} | ||
|
|
||
| # TLS Protocol Versions: only 1.3 and 1.2 | ||
| SSLProtocol -all +TLSv1.3 +TLSv1.2 | ||
|
|
||
| # TLS 1.2 Cipher Suites (ECDHE + AEAD only, PFS required) | ||
| SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256 | ||
|
|
||
| # TLS 1.3 Cipher Suites (AES-GCM and AES-CCM) | ||
| SSLCipherSuite TLSv1.3 TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_SHA256 | ||
|
|
||
| # Server chooses cipher order | ||
| SSLHonorCipherOrder on | ||
|
|
||
| # ECDHE Curve Preference: brainpool first, NIST as fallback | ||
| SSLOpenSSLConfCmd Curves brainpoolP256r1:brainpoolP384r1:prime256v1:secp384r1 | ||
|
|
||
| # Signature algorithms preference | ||
| SSLOpenSSLConfCmd SignatureAlgorithms ecdsa_secp256r1_sha256:ecdsa_secp384r1_sha384:rsa_pss_rsae_sha256:rsa_pss_rsae_sha384 | ||
|
|
||
| # Session cache | ||
| SSLSessionCache shmcb:/run/apache2/ssl_scache(512000) | ||
| SSLSessionCacheTimeout 300 | ||
|
|
||
| # Disable session tickets (for PFS) | ||
| SSLSessionTickets off | ||
|
|
||
| # Strict SNI | ||
| SSLStrictSNIVHostCheck on | ||
|
|
||
| # Disable TLS compression (CRIME mitigation) | ||
| SSLCompression off |
Uh oh!
There was an error while loading. Please reload this page.