Long passwords don't allow authentication
I've configured ha-dockermon with a 64 character password and couldn't authenticate afterwards:
http:
username: username
password: Jn8NY8Uq2YkImt3peuQhC8YNX3gvf3CjRAMjZJeZH4FOK6FjsZoXNGxeBfzktSGj
(Just a sample password, don't worry...)
Any requests responded with a 401 Unauthorized header, both from Home Assistant and Curl.
Workaround: Shortening the password to 28 characters in my case allows the request to go through and everything works perfectly.
Strangely I can't see any limitation of password length in the source code of ha-dockermon, neither any indication of it in the used library express-basic-auth.
Well that is certainly interesting.
From some quick Googling around, it may be an issue with the base image of the container. Officially there is no limit to password or username lengths, however once things get encrypted in HTTP headers etc, memory limits start to become an issue.
I'll have to leave this as open until I get some time to tinker around and see if there's something I can adjust, either by switching out the auth library or something else.
@cstuder 👋 do you still see this issue?
I tried today to repro it, but authentication succeeded OK with this configuration:
debug: false
http:
port: 8126
username: username
password: Jn8NY8Uq2YkImt3peuQhC8YNX3gvf3CjRAMjZJeZH4FOK6FjsZoXNGxeBfzktSGj
docker_connection:
type: socket
path: /var/run/docker.sock
Full commands and output
$ cat hado.conf
debug: false
http:
port: 8126
username: username
password: Jn8NY8Uq2YkImt3peuQhC8YNX3gvf3CjRAMjZJeZH4FOK6FjsZoXNGxeBfzktSGj
docker_connection:
type: socket
path: /var/run/docker.sock
$ docker run -d --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$(realpath ./hado.conf)":/config/configuration.yaml -p 8126:8126 philhawthorne/ha-dockermon
$ curl -v --user username:Jn8NY8Uq2YkImt3peuQhC8YNX3gvf3CjRAMjZJeZH4FOK6FjsZoXNGxeBfzktSGj http://localhost:8126/containers
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8126 (#0)
* Server auth using Basic with user 'username'
> GET /containers HTTP/1.1
> Host: localhost:8126
> Authorization: Basic dXNlcm5hbWU6Sm44Tlk4VXEyWWtJbXQzcGV1UWhDOFlOWDNndmYzQ2pSQU1qWkplWkg0Rk9LNkZqc1pvWE5HeGVCZnprdFNHag==
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Content-Type: application/json; charset=utf-8
< Content-Length: 1162
< ETag: W/"48a-Ksk+D39l0v9bLNzQiMpCJQb3he0"
< Date: Sat, 17 Oct 2020 20:08:49 GMT
< Connection: keep-alive
<
[{"Id":"cc48fc18a198340bee7376aa64942ed6b7c1dc14f4e8bec6293c99f32535b264","Names":["/frosty_bartik"],"Image":"philhawthorne/ha-dockermon","ImageID":"sha256:64c96d323dd2643d6434c24a0153c0b74882f4a0175a8188105d1339036bd8ad","Command":"/bin/sh -c 'npm start'","Created":1602965285,"Ports":[{"IP":"0.0.0.0","PrivatePort":8126,"PublicPort":8126,"Type":"tcp"}],"Labels":{},"State":"running","Status":"Up 42 seconds","HostConfig":{"NetworkMode":"default"},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"NetworkID":"2b2aeb7b7d44d641d99b49a842de4490d5b4632eef22a7f06b81e3a29ca5d94f","EndpointID":"30c4f67bf402320fa021db492c41c60796cb272dcbb4007dbeb68359948df04f","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:11:00:02","DriverOpts":null}}},"Mounts":[{"Type":"bind","Source":"/home/solvaholic/hado.conf","Destination":"/config/configuration.yaml","Mode":"","RW":true,"Propagation":"rpriv* Connection #0 to host localhost left intact
ate"},{"Type":"bind","Source":"/var/run/docker.sock","Destination":"/var/run/docker.sock","Mode":"","RW":true,"Propagation":"rprivate"}]}]
I'm not running DockerMon at the moment, so I didn't check this issue for quite some time.
(To be honest, I completely forgot about it...)