(r *http.Request)
| 562 | } |
| 563 | |
| 564 | func (h *AuthHandler) clientIP(r *http.Request) string { |
| 565 | if h.resolved != nil && !h.resolved.TrustProxy { |
| 566 | host, _, _ := strings.Cut(r.RemoteAddr, ":") |
| 567 | if host != "" { |
| 568 | return host |
| 569 | } |
| 570 | return r.RemoteAddr |
| 571 | } |
| 572 | if xff := r.Header.Get("X-Forwarded-For"); xff != "" { |
| 573 | if idx := strings.Index(xff, ","); idx != -1 { |
| 574 | return strings.TrimSpace(xff[:idx]) |
| 575 | } |
| 576 | return strings.TrimSpace(xff) |
| 577 | } |
| 578 | host, _, _ := strings.Cut(r.RemoteAddr, ":") |
| 579 | if host != "" { |
| 580 | return host |
| 581 | } |
| 582 | return r.RemoteAddr |
| 583 | } |
| 584 | |
| 585 | // authBrowserSessionCookies returns whether to use session-only cookies (env -> DB -> default). |
| 586 | func (h *AuthHandler) authBrowserSessionCookies() bool { |
no test coverage detected