Skip to content

Commit

Permalink
main: do not require authentication if no users are configured
Browse files Browse the repository at this point in the history
When TLS is enabled, basic authentication is required, whether there are
users configured or not. If no users are defined, allow unauthenticated
access even with TLS.

Fix typo in config file comment.

Signed-off-by: Robin Jarry <[email protected]>
  • Loading branch information
rjarry authored and atyronesmith committed Jan 8, 2025
1 parent c4a0667 commit bec0185
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions etc/dataplane-node-exporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
#
#tls-key:

# Space separated list of valid users and passwords. Leave empty to disable
# authentication. Authentication will only be enforced when TLS is enabled.
# List of valid users and passwords. Leave empty to disable authentication.
# Authentication will only be enforced when TLS is enabled.
#
# Example:
#
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ func main() {

if config.TlsCert() != "" && config.TlsKey() != "" {
log.Noticef("listening on https://%s%s", config.HttpListen(), config.HttpPath())
server.Handler = basicAuthHandler(mux)
if len(config.AuthUsers()) > 0 {
server.Handler = basicAuthHandler(mux)
}
err = server.ListenAndServeTLS(config.TlsCert(), config.TlsKey())
} else {
log.Noticef("listening on http://%s%s", config.HttpListen(), config.HttpPath())
Expand Down

0 comments on commit bec0185

Please sign in to comment.