Skip to content

Commit

Permalink
refactor: auth bearer check
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis committed Apr 18, 2024
1 parent 54c7440 commit 708320d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions server/http_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ func updatePasswordHandler(auth auth.Auth) http.HandlerFunc {
func jwtFromRequest(r *http.Request) string {
// read from header
authHeader := r.Header.Get("Authorization")
splitToken := strings.Split(authHeader, "Bearer ")
if len(splitToken) == 2 {
return splitToken[1]
if token, ok := strings.CutPrefix(authHeader, "Bearer "); ok {
return token
}

// read from cookie
Expand Down

0 comments on commit 708320d

Please sign in to comment.