karrio-server-core 2025.5rc22__py3-none-any.whl → 2025.5rc23__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of karrio-server-core might be problematic. Click here for more details.

@@ -1,4 +1,4 @@
1
- import typing
1
+ import logging
2
2
  from constance import config
3
3
  from django.urls import reverse
4
4
  from rest_framework.request import Request
@@ -31,18 +31,29 @@ NON_HUBS_CARRIERS = [
31
31
  carrier_name for carrier_name in CARRIER_NAMES if carrier_name not in CARRIER_HUBS
32
32
  ]
33
33
 
34
+ LOGGER = logging.getLogger(__name__)
35
+
34
36
 
35
37
  def contextual_metadata(request: Request):
36
- _host: str = typing.cast(
37
- str,
38
- (
39
- request.build_absolute_uri(
40
- reverse("karrio.server.core:metadata", kwargs={})
41
- )
42
- if hasattr(request, "build_absolute_uri")
43
- else "/"
44
- ),
45
- )
38
+ # Detect HTTPS from headers (for proxied environments like Caddy/ALB)
39
+ is_https = False
40
+ if hasattr(request, 'META'):
41
+ # Check X-Forwarded-Proto header (set by load balancers/proxies)
42
+ forwarded_proto = request.META.get('HTTP_X_FORWARDED_PROTO', '').lower()
43
+ # Check if request is secure (Django's built-in HTTPS detection)
44
+ is_secure = getattr(request, 'is_secure', lambda: False)()
45
+ is_https = forwarded_proto == 'https' or is_secure
46
+
47
+ if hasattr(request, "build_absolute_uri"):
48
+ _host: str = request.build_absolute_uri(
49
+ reverse("karrio.server.core:metadata", kwargs={})
50
+ )
51
+ # Override protocol if we detected HTTPS but build_absolute_uri returned HTTP
52
+ if is_https and _host.startswith('http://'):
53
+ _host = _host.replace('http://', 'https://', 1)
54
+ else:
55
+ _host = "/"
56
+
46
57
  host = _host[:-1] if _host[-1] == "/" else _host
47
58
  name = lib.identity(
48
59
  getattr(conf.settings.tenant, "name", conf.settings.APP_NAME)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: karrio_server_core
3
- Version: 2025.5rc22
3
+ Version: 2025.5rc23
4
4
  Summary: Multi-carrier shipping API Core module
5
5
  Author-email: karrio <hello@karrio.io>
6
6
  License-Expression: Apache-2.0
@@ -7,7 +7,7 @@ karrio/server/core/apps.py,sha256=VKRPRoB2YY1JlEpCe2AE6k57M1qkPADfq5RYZuLjEOw,21
7
7
  karrio/server/core/authentication.py,sha256=NiXbfcz3SJjYSKBGLT9-HRYATZXfPRuyALS5bzpNT9U,10555
8
8
  karrio/server/core/context_processors.py,sha256=B80cJ_7-uviNRYyrfsCcOaUQFBf_eAgQ0hHZPtM5Olw,323
9
9
  karrio/server/core/datatypes.py,sha256=lM0kKKcEoULrEvpJajbBfiz0xAU4OgOQoiAvalKllNg,10085
10
- karrio/server/core/dataunits.py,sha256=Mbmh6Bi9CwlxdAYLIfLlQjxCSZd_uWN0Dux-GIYTrko,5019
10
+ karrio/server/core/dataunits.py,sha256=8yXrsxhGYN-Q7pondiuitcFbnJeTTG2IJmVskzm-SGs,5673
11
11
  karrio/server/core/exceptions.py,sha256=AR4FNT_1wkMkuv_ZELB9pVRL3RRWsSJ7hrNgBP7H3EU,6038
12
12
  karrio/server/core/fields.py,sha256=5i5eetbxFkIQ9uoFk8k2xPl1mXXnaVKlPV4xwlF3inY,345
13
13
  karrio/server/core/filters.py,sha256=nHj742vPWE3Xs_tpwRRVUh00OwxnF22xKfIK7rx-sw4,27434
@@ -198,7 +198,7 @@ karrio/server/user/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
198
198
  karrio/server/user/templates/registration/login.html,sha256=3_tj-0rKfwkCk-fp_GT8xFQhLqjGcJs3uZzOAaI40Sw,3690
199
199
  karrio/server/user/templates/registration/registration_confirm_email.html,sha256=zFDkNN_BHMQyrBv_mU8aoqXxYxG91TGuf6pKwRa5jxE,247
200
200
  karrio/server/user/templates/registration/registration_confirm_email.txt,sha256=I_zN_pJTRigfyiYbyQK0wFfrI5Zq1JG8lf0TyLA9fN0,94
201
- karrio_server_core-2025.5rc22.dist-info/METADATA,sha256=1PXNF5RMu-VkjkTnX4niEJDASgApbpHqRS54XEXt71E,797
202
- karrio_server_core-2025.5rc22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
203
- karrio_server_core-2025.5rc22.dist-info/top_level.txt,sha256=D1D7x8R3cTfjF_15mfiO7wCQ5QMtuM4x8GaPr7z5i78,12
204
- karrio_server_core-2025.5rc22.dist-info/RECORD,,
201
+ karrio_server_core-2025.5rc23.dist-info/METADATA,sha256=iIUF-AuabCvKSwNy8qfRHnQNqH0b-3HBej1THemt33M,797
202
+ karrio_server_core-2025.5rc23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
203
+ karrio_server_core-2025.5rc23.dist-info/top_level.txt,sha256=D1D7x8R3cTfjF_15mfiO7wCQ5QMtuM4x8GaPr7z5i78,12
204
+ karrio_server_core-2025.5rc23.dist-info/RECORD,,