Skip to content

Commit

Permalink
Move header user copy & remove only when ip filter not match
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreh2ag committed Oct 26, 2022
1 parent ca26f8e commit 1b72403
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ func (m *Middleware) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
fmt.Println("IP is not authorize and basic auth is not valid")
return
}
}
req.URL.User = url.User(user)
if m.headerField != "" {
req.Header[m.headerField] = []string{user}
}

if m.removeHeader {
req.Header.Del(authorizationHeader)
req.URL.User = url.User(user)
if m.headerField != "" {
req.Header[m.headerField] = []string{user}
}

if m.removeHeader {
req.Header.Del(authorizationHeader)
}
}

fmt.Println("Request authorized")
Expand Down

0 comments on commit 1b72403

Please sign in to comment.