diff --git a/api_logs/api-logs.go b/api_logs/api-logs.go index d486db377e2d8b9ffa790f7311be64b6c77d6a47..e648f0c9bfe2fd383d2145b58e84d2247fee6ca3 100644 --- a/api_logs/api-logs.go +++ b/api_logs/api-logs.go @@ -2,6 +2,7 @@ package api_logs import ( "github.com/thoas/go-funk" + "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/ip_utils" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/number_utils" "net/url" "strings" @@ -80,7 +81,7 @@ func GenerateIncomingAPILog(startTime time.Time, requestID *string, claim map[st RequestID: currentRequestID, InitialAuthType: authType, InitialAuthUsername: authUsername, - SourceIP: req.RequestContext.Identity.SourceIP, + SourceIP: ip_utils.GetRequestSourceIP(&req, nil), UserAgent: req.RequestContext.Identity.UserAgent, UserID: userID, Username: username, diff --git a/auth/session.go b/auth/session.go index da9035ee441b41bdec52f9d60339248b6b109a47..6d1d94fe7590e1d78d10fa21c07dbf59b701d469 100644 --- a/auth/session.go +++ b/auth/session.go @@ -10,6 +10,7 @@ import ( "github.com/thoas/go-funk" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/date_utils" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/handler_utils" + "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/ip_utils" "time" ) @@ -30,7 +31,7 @@ func SignSessionTokenWithKey(secretKey string, sessionTokenString string) string // GetSessionTokenString creates a unique session token string from the API request. func GetSessionTokenString(request events.APIGatewayProxyRequest) (string, error) { sessionToken := SessionToken{ - IP: request.RequestContext.Identity.SourceIP, + IP: ip_utils.GetRequestSourceIP(&request, nil), UserAgent: handler_utils.FindHeaderValue(request.Headers, "user-agent"), TimeCreated: date_utils.CurrentDate().Round(time.Second), Token: uuid.New().String(),