mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-04 01:09:36 +02:00
authenticate: add events (#4051)
This commit is contained in:
parent
b936b3653b
commit
0ab2057714
6 changed files with 145 additions and 3 deletions
14
internal/httputil/ip.go
Normal file
14
internal/httputil/ip.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package httputil
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetClientIP returns the client IP address from the request.
|
||||
func GetClientIP(r *http.Request) string {
|
||||
if clientIP := r.Header.Get("X-Forwarded-For"); clientIP != "" {
|
||||
return strings.Split(clientIP, ",")[0]
|
||||
}
|
||||
return strings.Split(r.RemoteAddr, ":")[0]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue