Skip to content

Commit e478ccd

Browse files
authored
fix: set authToken in BasicAuth (#115)
1 parent 01eb00f commit e478ccd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internals/proxy/middlewares/auth.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ func authHandler(next http.Handler) http.Handler {
4646
if isValidToken(tokens, authToken) {
4747
success = true
4848
}
49-
5049
case Basic:
5150
basicAuthBody, err := base64.StdEncoding.DecodeString(authToken)
5251

@@ -55,11 +54,12 @@ func authHandler(next http.Handler) http.Handler {
5554
}
5655

5756
basicAuth := string(basicAuthBody)
58-
basicAuthParams := strings.Split(basicAuth, ":")
57+
basicAuthParts := strings.Split(basicAuth, ":")
5958

6059
user := "api"
60+
authToken = basicAuthParts[1]
6161

62-
if basicAuthParams[0] == user && isValidToken(tokens, basicAuthParams[1]) {
62+
if basicAuthParts[0] == user && isValidToken(tokens, authToken) {
6363
success = true
6464
}
6565
}
@@ -108,4 +108,4 @@ func getAuthType(str string) authType {
108108

109109
func isValidToken(tokens []string, match string) bool {
110110
return slices.Contains(tokens, match)
111-
}
111+
}

0 commit comments

Comments
 (0)