Skip to content

Commit d813796

Browse files
author
Florian
committed
CheckAuth should return validation fails
1 parent 60bfa4f commit d813796

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

router/middleware.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,18 @@ func CheckAuth(secret string) Middleware {
3838
authHeader := r.Header.Get("Authorization")
3939
if authHeader == "" {
4040
HandleError(UnauthorizedError("This endpoint requires a Bearer token"), w, r)
41+
return
4142
}
4243

4344
matches := bearerRegexp.FindStringSubmatch(authHeader)
4445
if len(matches) != 2 {
4546
HandleError(UnauthorizedError("This endpoint requires a Bearer token"), w, r)
47+
return
4648
}
4749

4850
if secret != matches[1] {
4951
HandleError(UnauthorizedError("This endpoint requires a Bearer token"), w, r)
52+
return
5053
}
5154
}
5255

0 commit comments

Comments
 (0)