wemake-services / caddy-gen

Automated Caddy reverse proxy for docker containers
https://hub.docker.com/r/wemakeservices/caddy-gen
MIT License
244 stars 23 forks source link

cannot use `basic_auth` #94

Closed casperdcl closed 1 week ago

casperdcl commented 2 weeks ago

basic_auth hashed passwords aren't properly handled:

# docker-compose.yml
  virtual.host.directives: |
    basic_auth {
      foo $2a$14$0Sp4ChWux41qQtLacUlUuOcMO7B2z1u7V2XDaKfJy0X5dgcqHglDu
    }
docker compose up
docker compose exec caddy cat /etc/caddy/Caddyfile | grep foo
WARN[0000] The "rpRTWRijdH41OrZeZvbvBunD4mkXapj3tN1qDc1sqIlTYjK1jOWaC" variable is not set. Defaulting to a blank string. 
      foo $2a$14
casperdcl commented 2 weeks ago

looks like the fix is to use double $$:

foo $2a$14$$0Sp4ChWux41qQtLacUlUuOcMO7B2z1u7V2XDaKfJy0X5dgcqHglDu

perhaps https://docs.docker.com/reference/compose-file/interpolation/ is worth documenting?

sobolevn commented 2 weeks ago

@casperdcl please, send a PR :)

casperdcl commented 1 week ago

Done in #95 :)