Repository navigation
add SHA support to htpasswd - #413
Conversation
Security Concerns with the Current SHA ImplementationWhile I understand this PR was created to address Envoy compatibility (which currently only supports Current SituationEnvoy Limitation:
The Security Issue: Proposed Solution: Add Secure AlternativesInstead of changing the existing Suggested Implementation// Default: bcrypt (most secure)
{{ htpasswd "user" "pass" }}
// Output: user:$2y$05$... (random, non-deterministic)
{{ htpasswd "user" "pass" "bcrypt" }}
// Output: user:$2y$05$... (same as default)
{{ htpasswd "user" "pass" "sha" }}
// Output: user:{SHA}... (unchanged - for Envoy)
{{ htpasswd "user" "pass" "ssha" }}
// Output: user:{SSHA}... (NEW - secure with auto-salt)
{{ htpasswd "user" "pass" "ssha" "fixedsalt" }}
// Output: user:{SSHA}... (NEW - deterministic for testing)
{{ htpasswd "user" "pass" "sha512" }}
// Output: user:$6$... (NEW - for NGINX)
{{ htpasswd "user" "pass" "sha512" "fixedsalt" }}
// Output: user:$6$fixedsalt$... (NEW - deterministic)
{{ htpasswd "user" "pass" "sha256" }}
// Output: user:$5$... (NEW - for NGINX)
{{ htpasswd "user" "pass" "sha256" "fixedsalt" }}
// Output: user:$5$fixedsalt$... (NEW - deterministic)Algorithm Comparison
GitOps Example (reproducible deployments)# Terraform/Helm values - always produces same output
apiVersion: v1
kind: Secret
metadata:
name: app-auth
stringData:
auth: |
{{ htpasswd "deploy-user" "deploy-pass" "sha512" "deploysalt" }}
{{ htpasswd "admin" "admin-pass" "sha256" "adminsalt" }}Mixed Environments Example# Support both Envoy and NGINX from same secret
apiVersion: v1
kind: Secret
metadata:
name: multi-auth
stringData:
# For Envoy
envoy-auth: {{ htpasswd "envoy-user" "pass" "sha" }}
# For NGINX (secure)
nginx-auth: |
{{ htpasswd "nginx-user" "pass" }}
{{ htpasswd "nginx-admin" "secret" "sha512" }}Benefits of This Approach
Related Issues
@vixns @mattfarina Would you be open to a follow-up PR that adds these secure alternatives while keeping the existing SHA implementation for Envoy compatibility? Summary:
|
My use case is to address hashicorp vault > external-password > k8s password > envoy gateway > envoy
envoy only supports sha encoding, external-password uses sprig, sprig encodes to bcrypt
This PR will allow to simplify this chain and partially fix #32.
I've opened a counterpart issue in envoy repo to also add bcrypt decoding support envoyproxy/envoy#36278
I hope this will be fixed both ways, allowing better security with a smooth transition from sha to bcrypt on existing apps