From 8234ba216de7b9631a1c8c10841857b833f790ad Mon Sep 17 00:00:00 2001 From: Inbal Tako Date: Mon, 27 Jul 2020 16:43:05 +0300 Subject: [PATCH 1/2] Update readme fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d309bc1..8787b41 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ from securenative.models.user_traits import UserTraits securenative = SecureNative.get_instance() -context = SecureNative.context_builder().with_ip("127.0.0.1").with_client_token("SECURED_CLIENT_TOKEN").with_headers({"user-agent", "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405"}).build() +context = SecureNative.context_builder().with_ip("127.0.0.1").with_client_token("SECURED_CLIENT_TOKEN").with_headers({"user-agent": "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405"}).build() event_options = EventOptionsBuilder(EventTypes.LOG_IN).with_user_id("1234").with_user_traits(UserTraits("Your Name", "name@gmail.com", "+1234567890")).with_context(context).with_properties({"prop1": "CUSTOM_PARAM_VALUE", "prop2": True, "prop3": 3}).build() securenative.track(event_options) From aca452689d210db746b5e56d40fac899d4a5f61a Mon Sep 17 00:00:00 2001 From: Inbal Tako Date: Mon, 27 Jul 2020 17:25:56 +0300 Subject: [PATCH 2/2] Fix ip extraction --- VERSION | 2 +- securenative/utils/request_utils.py | 2 +- securenative/utils/version_utils.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 08456a4..d81f1c3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.8 \ No newline at end of file +0.2.9 \ No newline at end of file diff --git a/securenative/utils/request_utils.py b/securenative/utils/request_utils.py index 52e0f0f..0b42ebd 100644 --- a/securenative/utils/request_utils.py +++ b/securenative/utils/request_utils.py @@ -19,7 +19,7 @@ def get_client_ip_from_request(request): ip = request.META.get('REMOTE_ADDR') return ip except Exception: - return "" + return request.environ.get('HTTP_X_FORWARDED_FOR', request.environ.get('REMOTE_ADDR', "")) @staticmethod def get_remote_ip_from_request(request): diff --git a/securenative/utils/version_utils.py b/securenative/utils/version_utils.py index 24ef37c..14e7f8b 100644 --- a/securenative/utils/version_utils.py +++ b/securenative/utils/version_utils.py @@ -2,4 +2,4 @@ class VersionUtils(object): @staticmethod def get_version(): - return "0.2.8" + return "0.2.9"