Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
Abort middleware execution if no token header is present
Browse files Browse the repository at this point in the history
  • Loading branch information
IljaN committed Jul 10, 2020
1 parent 7c3e39c commit 9097fcd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/middleware/create_home.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ func CreateHome(opts ...Option) func(next http.Handler) http.Handler {
"secret": opt.TokenManagerConfig.JWTSecret,
})
if err != nil {
opt.Logger.Err(err).Msg("error creating tokenManager")
w.WriteHeader(http.StatusInternalServerError)
return
}

token := r.Header.Get("x-access-token")
if token == "" {
next.ServeHTTP(w, r)
return
}

user, err := tokenManager.DismantleToken(r.Context(), token)
if err != nil {
opt.Logger.Err(err).Msg("error getting user from access token")
Expand Down

0 comments on commit 9097fcd

Please sign in to comment.