mirror of
https://github.com/harness/drone.git
synced 2025-05-03 03:20:40 +08:00
support fowarded for header as well
This commit is contained in:
parent
db3bd3b2cd
commit
77a799a4c9
@ -17,6 +17,7 @@ package account
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/harness/gitness/types"
|
||||
@ -53,7 +54,12 @@ func deleteTokenCookieIfPresent(r *http.Request, w http.ResponseWriter, cookieNa
|
||||
|
||||
func newEmptyTokenCookie(r *http.Request, cookieName string) *http.Cookie {
|
||||
domain := r.URL.Hostname()
|
||||
if headers, ok := r.Header["X-Forwarded-For"]; ok && len(headers) > 0 {
|
||||
if urls, ok := r.Header["X-Forwarded-For"]; ok && len(urls) > 0 {
|
||||
if url, err := url.Parse(urls[0]); err != nil {
|
||||
domain = url.Hostname()
|
||||
}
|
||||
}
|
||||
if headers, ok := r.Header["X-Forwarded-Header"]; ok && len(headers) > 0 {
|
||||
domain = headers[0]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user