Search code examples
consultraefik

traefik - basic auth for entry point via key/value store


I would like to configure basic auth for one of my entry points via key/value store (consul in my case). But traefik seems to ignore the directives.

I tried the following configurations:

traefik/entrypoints/http/auth/basic/users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/"]


traefik/entrypoints/http/auth/basic/users = test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/


traefik/entrypoints/http/auth/basic/users/0 = test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/

I get the following error

-------------------------------------
/var/log/containers/traefik-c9f95e2d3a98-stdouterr.log
-------------------------------------
2017/06/12 15:58:34 Error loading configuration: 1 error(s) decoding:

* error decoding 'EntryPoints[http].Auth.Basic.Users': illegal base64 data at input byte 5

The toml file seems to be ignored if I specify a key/value store...

What am i doing wrong?


Solution

  • I figured out what was wrong.

    If you provide a key/value store like consul it will override the configuration in your config file.

    The correct key or path to store basic auth users looks like this

    traefik/entrypoints/http/auth/basic/users/0
    

    and the value you is the username and the hash separated by a colon

    test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/
    

    If you get the above error message regarding base64 encoding you have to escape the $ with $ so your hash looks like $$apr1$$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/