Skip to content
Snippets Groups Projects
Commit b225e39a authored by Francé Wilke's avatar Francé Wilke
Browse files

Use ip_utils.GetRequestSourceIP when getting the source IP

parent a72b2ef1
Branches
Tags v1.283.0
No related merge requests found
...@@ -2,6 +2,7 @@ package api_logs ...@@ -2,6 +2,7 @@ package api_logs
import ( import (
"github.com/thoas/go-funk" "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" "gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/number_utils"
"net/url" "net/url"
"strings" "strings"
...@@ -80,7 +81,7 @@ func GenerateIncomingAPILog(startTime time.Time, requestID *string, claim map[st ...@@ -80,7 +81,7 @@ func GenerateIncomingAPILog(startTime time.Time, requestID *string, claim map[st
RequestID: currentRequestID, RequestID: currentRequestID,
InitialAuthType: authType, InitialAuthType: authType,
InitialAuthUsername: authUsername, InitialAuthUsername: authUsername,
SourceIP: req.RequestContext.Identity.SourceIP, SourceIP: ip_utils.GetRequestSourceIP(&req, nil),
UserAgent: req.RequestContext.Identity.UserAgent, UserAgent: req.RequestContext.Identity.UserAgent,
UserID: userID, UserID: userID,
Username: username, Username: username,
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"github.com/thoas/go-funk" "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/date_utils"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/handler_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" "time"
) )
...@@ -30,7 +31,7 @@ func SignSessionTokenWithKey(secretKey string, sessionTokenString string) string ...@@ -30,7 +31,7 @@ func SignSessionTokenWithKey(secretKey string, sessionTokenString string) string
// GetSessionTokenString creates a unique session token string from the API request. // GetSessionTokenString creates a unique session token string from the API request.
func GetSessionTokenString(request events.APIGatewayProxyRequest) (string, error) { func GetSessionTokenString(request events.APIGatewayProxyRequest) (string, error) {
sessionToken := SessionToken{ sessionToken := SessionToken{
IP: request.RequestContext.Identity.SourceIP, IP: ip_utils.GetRequestSourceIP(&request, nil),
UserAgent: handler_utils.FindHeaderValue(request.Headers, "user-agent"), UserAgent: handler_utils.FindHeaderValue(request.Headers, "user-agent"),
TimeCreated: date_utils.CurrentDate().Round(time.Second), TimeCreated: date_utils.CurrentDate().Round(time.Second),
Token: uuid.New().String(), Token: uuid.New().String(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment