authenticate: add events (#4051)

This commit is contained in:
Denis Mishin 2023-05-01 15:11:30 -04:00 committed by GitHub
parent b936b3653b
commit 0ab2057714
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 145 additions and 3 deletions

14
internal/httputil/ip.go Normal file
View 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]
}