stac-fastapi.api 6.1.4__tar.gz → 6.1.5__tar.gz
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.
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/PKG-INFO +1 -1
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/stac_fastapi/api/middleware.py +37 -18
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/stac_fastapi/api/version.py +1 -1
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/.gitignore +0 -0
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/README.md +0 -0
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/pyproject.toml +0 -0
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/stac_fastapi/api/__init__.py +0 -0
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/stac_fastapi/api/app.py +0 -0
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/stac_fastapi/api/config.py +0 -0
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/stac_fastapi/api/errors.py +0 -0
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/stac_fastapi/api/models.py +0 -0
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/stac_fastapi/api/openapi.py +0 -0
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/stac_fastapi/api/py.typed +0 -0
- {stac_fastapi_api-6.1.4 → stac_fastapi_api-6.1.5}/stac_fastapi/api/routes.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stac-fastapi-api
|
|
3
|
-
Version: 6.1.
|
|
3
|
+
Version: 6.1.5
|
|
4
4
|
Summary: An implementation of STAC API based on the FastAPI framework.
|
|
5
5
|
Project-URL: Homepage, https://github.com/stac-utils/stac-fastapi
|
|
6
6
|
Author-email: ArturoAI <engineering@arturo.ai>
|
|
@@ -82,20 +82,33 @@ class ProxyHeaderMiddleware:
|
|
|
82
82
|
|
|
83
83
|
await self.app(scope, receive, send)
|
|
84
84
|
|
|
85
|
-
def _get_forwarded_url_parts(self, scope: Scope) -> Tuple[str, str,
|
|
85
|
+
def _get_forwarded_url_parts(self, scope: Scope) -> Tuple[str, str, int]:
|
|
86
86
|
proto = scope.get("scheme", "http")
|
|
87
|
-
|
|
88
|
-
if
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
# Assume default port based on protocol, can be overridden later
|
|
88
|
+
port = 443 if proto == "https" else 80
|
|
89
|
+
|
|
90
|
+
if header_host := self._get_header_value_by_name(scope, "host"):
|
|
91
91
|
header_host_parts = header_host.split(":")
|
|
92
|
+
domain = header_host_parts[0]
|
|
92
93
|
if len(header_host_parts) == 2:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
with contextlib.suppress(ValueError):
|
|
95
|
+
port = int(header_host_parts[1])
|
|
96
|
+
else:
|
|
97
|
+
# Not sure when we would not have a host header, but fallback to server info
|
|
98
|
+
domain, port = scope["server"]
|
|
99
|
+
port = int(port)
|
|
100
|
+
|
|
101
|
+
forwarded_port: Optional[str] = None
|
|
102
|
+
forwarding_occurred = any(
|
|
103
|
+
key
|
|
104
|
+
in [
|
|
105
|
+
b"forwarded",
|
|
106
|
+
b"x-forwarded-proto",
|
|
107
|
+
b"x-forwarded-host",
|
|
108
|
+
b"x-forwarded-port",
|
|
109
|
+
]
|
|
110
|
+
for key, _ in scope["headers"]
|
|
111
|
+
)
|
|
99
112
|
|
|
100
113
|
if forwarded := self._get_header_value_by_name(scope, "forwarded"):
|
|
101
114
|
for proxy in forwarded.split(","):
|
|
@@ -103,15 +116,21 @@ class ProxyHeaderMiddleware:
|
|
|
103
116
|
proto = proto_expr.group("proto")
|
|
104
117
|
if host_expr := _HOST_HEADER_REGEX.search(proxy):
|
|
105
118
|
domain = host_expr.group("host")
|
|
106
|
-
|
|
119
|
+
forwarded_port = host_expr.group("port") # None if not present
|
|
107
120
|
|
|
108
121
|
else:
|
|
109
|
-
domain = self._get_header_value_by_name(scope, "x-forwarded-host"
|
|
110
|
-
proto = self._get_header_value_by_name(scope, "x-forwarded-proto"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
domain = self._get_header_value_by_name(scope, "x-forwarded-host") or domain
|
|
123
|
+
proto = self._get_header_value_by_name(scope, "x-forwarded-proto") or proto
|
|
124
|
+
forwarded_port = self._get_header_value_by_name(scope, "x-forwarded-port")
|
|
125
|
+
|
|
126
|
+
if forwarding_occurred and not forwarded_port:
|
|
127
|
+
# If forwarding occurred but no port was specified, use protocol default
|
|
128
|
+
forwarded_port = "443" if proto == "https" else "80"
|
|
129
|
+
|
|
130
|
+
if forwarded_port:
|
|
131
|
+
# ignore ports that are not valid integers
|
|
132
|
+
with contextlib.suppress(ValueError):
|
|
133
|
+
port = int(forwarded_port)
|
|
115
134
|
|
|
116
135
|
return (proto, domain, port)
|
|
117
136
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|