Skip to content

Commit

Permalink
Merge pull request negz#41 from Miouge1/no-ip-in-state
Browse files Browse the repository at this point in the history
Remove remote IP in state to allow for loadbalancing
  • Loading branch information
negz authored Jun 25, 2018
2 parents 9b437d7 + 2bf8fc4 commit ede4085
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions kuberos.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,9 @@ func defaultStateFn(secret []byte) StateFn {
// Writing to a hash never returns an error.
// nolint: errcheck, gas
return func(r *http.Request) string {
remote := r.RemoteAddr
// Use the forwarded for header instead of the remote address if it is
// supplied.
for h, v := range r.Header {
if h == headerForwardedFor {
for _, host := range v {
remote = host
}
}
}

h := sha256.New()
h.Write(secret)
h.Write([]byte(r.Host))
h.Write([]byte(remote))
h.Write([]byte(r.UserAgent()))
return fmt.Sprintf("%x", h.Sum(nil))
}
Expand Down

0 comments on commit ede4085

Please sign in to comment.