Skip to content

Commit 7c9711f

Browse files
hdurand0710Gopher Bot
authored andcommitted
BUG/MINOR: do not create a user in userlist with empty password for basic authentication
Using Ingress annotations: - haproxy.org/auth-secret: <namespace>/<secret-name> - haproxy.org/auth-type: basic-auth If the secret contains a key with an empty value, Ingress controller was crashing. In this case, we do not create the user with the empty password in the userlist.
1 parent a60dc91 commit 7c9711f

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

.aspell.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@ allowed:
6868
- liveness
6969
- ipv
7070
- CIDR
71+
- auth
72+
- userlist

pkg/annotations/ingress/basicAuth.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,15 @@ func (a ReqAuthAnn) Process(k store.K8s, annotations ...map[string]string) (err
7676
}
7777
a.parent.authRule.Credentials = make(map[string][]byte)
7878
for u, pwd := range secret.Data {
79-
if pwd[len(pwd)-1] == '\n' {
80-
// logger.Warningf("Ingress %s/%s: basic-auth: password for user %s ends with '\\n'. Ignoring last character.", ingress.Namespace, ingress.Name, u)
81-
pwd = pwd[:len(pwd)-1]
79+
// If the pwd length is 0, we do not create the user in the userlist
80+
// This is not a valid setting
81+
if len(pwd) > 0 {
82+
if pwd[len(pwd)-1] == '\n' {
83+
// logger.Warningf("Ingress %s/%s: basic-auth: password for user %s ends with '\\n'. Ignoring last character.", ingress.Namespace, ingress.Name, u)
84+
pwd = pwd[:len(pwd)-1]
85+
}
86+
a.parent.authRule.Credentials[u] = pwd
8287
}
83-
a.parent.authRule.Credentials[u] = pwd
8488
}
8589
default:
8690
err = fmt.Errorf("unknown auth-type annotation '%s'", a.name)

0 commit comments

Comments
 (0)