@@ -111,7 +111,6 @@ You can also create request context from requests:
111111
112112``` python
113113from securenative.securenative import SecureNative
114- from securenative.context.securenative_context import SecureNativeContext
115114from securenative.models.event_options import EventOptions
116115from securenative.enums.event_types import EventTypes
117116from securenative.models.user_traits import UserTraits
@@ -120,7 +119,7 @@ from securenative.models.user_traits import UserTraits
120119def track (request ):
121120 securenative = SecureNative.get_instance()
122121
123- context = SecureNativeContext .from_http_request(request)
122+ context = securenative .from_http_request(request)
124123 event_options = EventOptions(event = EventTypes.LOG_IN ,
125124 user_id = " 1234" ,
126125 user_traits = UserTraits(
" Your Name" ,
" [email protected] " ,
" +1234567890" ),
@@ -137,15 +136,14 @@ def track(request):
137136``` python
138137from securenative.securenative import SecureNative
139138from securenative.models.event_options import EventOptions
140- from securenative.context.securenative_context import SecureNativeContext
141139from securenative.enums.event_types import EventTypes
142140from securenative.models.user_traits import UserTraits
143141
144142
145143def verify (request ):
146144 securenative = SecureNative.get_instance()
147145
148- context = SecureNativeContext .from_http_request(request)
146+ context = securenative .from_http_request(request)
149147 event_options = EventOptions(event = EventTypes.LOG_IN ,
150148 user_id = " 1234" ,
151149 user_traits = UserTraits(
" Your Name" ,
" [email protected] " ,
" +1234567890" ),
@@ -173,3 +171,26 @@ def webhook_endpoint(request):
173171 is_verified = securenative.verify_request_payload(request)
174172 ```
175173
174+ ## Extract proxy headers from Cloudflare
175+
176+ You can specify custom header keys to allow extraction of client ip from different providers.
177+ This example demonstrates the usage of proxy headers for ip extraction from Cloudflare.
178+
179+ ### Option 1: Using config file
180+ ``` ini
181+ SECURENATIVE_API_KEY: dsbe27fh3437r2yd326fg3fdg36f43
182+ SECURENATIVE_PROXY_HEADERS: [" CF-Connecting-IP" ]
183+ ```
184+
185+ Initialize sdk as shown above.
186+
187+ ### Options 2: Using ConfigurationBuilder
188+
189+ ``` python
190+ from securenative.securenative import SecureNative
191+ from securenative.config.securenative_options import SecureNativeOptions
192+
193+
194+ options = SecureNativeOptions(api_key = " YOUR_API_KEY" , max_events = 10 , log_level = " ERROR" , proxy_headers = [' CF-Connecting-IP' ])
195+ securenative = SecureNative.init_with_options(options)
196+ ```
0 commit comments