-
Notifications
You must be signed in to change notification settings - Fork 123
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
6c57ae2
4d32245
cc1a984
9d6bc92
3e51d1d
09d3265
3a1f88d
4e1f43b
c1cfb41
3c74146
d73c1b3
ebd532f
08de739
d745f52
ac75277
b40d0fe
179516a
028778a
cdca374
185cbfe
9b5b464
1e714f4
4ca585f
92ca7a5
c697331
f837083
ee79d2d
a55791d
c8cf85d
b84a8e3
d29dd51
b1060dc
c3e117f
39ac638
edceddc
c54b682
178552d
52a753d
df6d751
ec3c4af
160b1cf
341bcaf
9c5d4a4
d7bfad0
b347e8e
b557189
0cb0b80
07ab6eb
c41563f
cdbca2b
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,24 @@ 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.validate" -}} | ||||||
| {{- if .Values.tls.enabled }} | ||||||
| {{- if not .Values.tls.keyGeneration }} | ||||||
| {{- fail "tls.keyGeneration is required when tls.enabled (options: go-crypto, hsm-entropy, hsm-full, tpm-entropy)" }} | ||||||
| {{- end }} | ||||||
| {{- if not .Values.tls.keyWrapping }} | ||||||
| {{- fail "tls.keyWrapping is required when tls.enabled (options: none, vault-transit, hsm, tpm)" }} | ||||||
| {{- end }} | ||||||
| {{- if not .Values.tls.keyStorage }} | ||||||
| {{- fail "tls.keyStorage is required when tls.enabled (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.enabled requires an external IP (global.barbican_external_ip or services.externalip): enabling TLS removes the ingress and the public TLS Service only renders once the external IP is set." }} | ||||||
| {{- end }} | ||||||
| {{- end }} | ||||||
| {{- end }} | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| {{- if .Values.tls.enabled }} | ||
|
rajivmucheli marked this conversation as resolved.
|
||
| {{- 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: | ||
| 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 | ||
|
Member
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. |
||
| {{- 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,49 @@ WSGIDaemonProcess barbican-api processes={{ .Values.api.processes | default 1 }} | |
|
|
||
| Listen 0.0.0.0:{{ .Values.api_port_internal }} | ||
|
|
||
| {{- if .Values.tls.enabled }} | ||
| # External HTTPS endpoint | ||
| # mod_ssl is loaded via a conf-enabled snippet, which is parsed after | ||
| # ports.conf, so its ssl_module-gated Listen 443 does not apply here. | ||
| Listen 0.0.0.0:443 | ||
|
|
||
| <VirtualHost *:443> | ||
|
Member
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. Why in Barbican you didn't set the server name similar to what has been done in keystone? |
||
| SSLEngine on | ||
| SSLCertificateFile /mnt/secrets/tls.crt | ||
| SSLCertificateKeyFile /mnt/secrets/tls.key | ||
|
|
||
| # HTTP security response headers | ||
| Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains" | ||
| Header always set X-Content-Type-Options "nosniff" | ||
| Header always set X-Frame-Options "DENY" | ||
| Header always set Content-Security-Policy "default-src 'self'" | ||
| Header always set Referrer-Policy "strict-origin-when-cross-origin" | ||
|
|
||
| WSGIProcessGroup barbican-api | ||
| WSGIScriptAlias / /var/www/cgi-bin/barbican/barbican-wsgi-api | ||
| WSGIApplicationGroup %{GLOBAL} | ||
| WSGIPassAuthorization On | ||
| LimitRequestBody 114688 | ||
|
|
||
| <IfVersion >= 2.4> | ||
| ErrorLogFormat "%{cu}t %M" | ||
| </IfVersion> | ||
| ErrorLog /dev/stderr | ||
| {{- if .Values.use_json }} | ||
| SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded | ||
| CustomLog /dev/stdout json_combined env=!forwarded | ||
| CustomLog /dev/stdout json_proxy env=forwarded | ||
| {{- else }} | ||
| SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded | ||
| CustomLog /dev/stdout combined env=!forwarded | ||
| CustomLog /dev/stdout proxy env=forwarded | ||
| {{- end }} | ||
|
|
||
| KeepAliveTimeout 61 | ||
|
rajivmucheli marked this conversation as resolved.
|
||
| </VirtualHost> | ||
|
rajivmucheli marked this conversation as resolved.
|
||
| {{- end }} | ||
|
|
||
| # Internal HTTP endpoint (protected by Linkerd mTLS at the network layer) | ||
| <VirtualHost *:{{ .Values.api_port_internal }}> | ||
| ServerName {{ include "barbican_api_endpoint_host_public" . }} | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.