Web / Traefik Interview questions
How do you configure basic authentication in Traefik?
The BasicAuth middleware protects a router with HTTP Basic Auth, checking credentials against a list of username/hashed-password pairs before letting the request continue.
http: middlewares: auth: basicAuth: users: - "admin:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/"
Passwords must be pre-hashed, typically with htpasswd, since Traefik never stores or accepts plaintext credentials in the configuration itself.
For anything beyond a handful of static users, teams generally move to ForwardAuth against a real identity provider, since BasicAuth has no concept of sessions, expiry, or multi-factor authentication.
The credential list can also be loaded from an external file with usersFile instead of inlining hashes directly in the dynamic configuration, which keeps secrets out of version-controlled config when that matters.
More Related questions...