-
Notifications
You must be signed in to change notification settings - Fork 108
[Ready for Review] Add HSTS (HTTP Strict Transport Security) support #3165
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: main
Are you sure you want to change the base?
[Ready for Review] Add HSTS (HTTP Strict Transport Security) support #3165
Conversation
This commit implements HSTS as a built-in Nebari feature, addressing
security compliance requirements mentioned in the related issue.
Changes:
- Add HSTS configuration schema to Ingress class with options for:
- enabled: Toggle HSTS on/off (default: false)
- max_age: HSTS max-age in seconds (default: 31536000 = 1 year)
- include_subdomains: Include subdomains in policy (default: true)
- preload: Enable HSTS preload (default: false)
- Create Traefik middleware resource for HSTS headers
- Conditionally created based on hsts-enabled setting
- Applies to both websecure (443) and minio (9080) entrypoints
- Update Traefik deployment to use HSTS middleware when enabled
Users can now enable HSTS in their nebari-config.yaml:
```yaml
ingress:
hsts:
enabled: true
max_age: 31536000
include_subdomains: true
preload: false
```
This replaces the previous workaround of manually creating middleware
resources and using terraform_overrides.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Changed the default HSTS max-age from 31536000 (1 year) to 30 seconds to allow safe initial testing of HSTS configuration. Rationale: - HSTS headers instruct browsers to remember HTTPS enforcement for the specified duration - If misconfigured with a long max-age, users could be locked out until the duration expires - A 30-second default allows administrators to validate the configuration works correctly before committing to a longer duration Added detailed comments in: - Python schema (__init__.py) explaining the conservative default - Terraform variables (variables.tf) noting the production recommendation - Middleware resource (hsts-middleware.tf) with example configuration Users should increase max_age to production values (e.g., 31536000) after validating their deployment works correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
| cert_type = config.get("certificate", {}).get( | ||
| "type", CertificateEnum.selfsigned.value | ||
| ) | ||
| is_valid_cert = cert_type in [CertificateEnum.letsencrypt.value, "existing"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add hsts to nebari config on nebari init ... if cert type is letsencrypt or existing
|
|
||
| # Initialize HSTS based on certificate type if not explicitly configured | ||
| hsts = self.config.ingress.hsts | ||
| if hsts is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if hsts is not in config, then default to enabling it for lets-encrypt and existing certs, otherwise default to disabling it
|
This will be pushed to a minor release after this one is done. |
Closes #3121
Docs Issue - nebari-dev/nebari-docs#605
We should add some stuff in the next release upgrade - #3168
Summary
This PR adds built-in HSTS (HTTP Strict Transport Security) configuration to Nebari's ingress layer.
If HSTS is unspecified, then it will be enabled for existing, and let's encrypt certs, but not enabled for self-signed or no cert.
Example Configuration