appmesh 1.6.4__py3-none-any.whl → 1.6.5__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.
- appmesh/client_http.py +9 -8
- appmesh/client_tcp.py +2 -2
- appmesh/server_http.py +3 -3
- {appmesh-1.6.4.dist-info → appmesh-1.6.5.dist-info}/METADATA +1 -1
- {appmesh-1.6.4.dist-info → appmesh-1.6.5.dist-info}/RECORD +7 -7
- {appmesh-1.6.4.dist-info → appmesh-1.6.5.dist-info}/WHEEL +0 -0
- {appmesh-1.6.4.dist-info → appmesh-1.6.5.dist-info}/top_level.txt +0 -0
appmesh/client_http.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# client_http.py
|
2
|
-
# pylint: disable=broad-exception-raised,line-too-long,broad-exception-caught,too-many-lines,
|
2
|
+
# pylint: disable=broad-exception-raised,line-too-long,broad-exception-caught,too-many-lines,import-outside-toplevel
|
3
3
|
import abc
|
4
4
|
import base64
|
5
5
|
import json
|
@@ -17,6 +17,7 @@ from urllib import parse
|
|
17
17
|
import aniso8601
|
18
18
|
import jwt
|
19
19
|
import requests
|
20
|
+
from requests.auth import _basic_auth_str
|
20
21
|
from .app import App
|
21
22
|
from .app_run import AppRun
|
22
23
|
from .app_output import AppOutput
|
@@ -123,6 +124,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
123
124
|
|
124
125
|
JSON_KEY_MESSAGE = "message"
|
125
126
|
HTTP_USER_AGENT = "appmesh/python"
|
127
|
+
HTTP_HEADER_KEY_AUTH = "Authorization"
|
126
128
|
HTTP_HEADER_KEY_USER_AGENT = "User-Agent"
|
127
129
|
HTTP_HEADER_KEY_X_TARGET_HOST = "X-Target-Host"
|
128
130
|
HTTP_HEADER_KEY_X_FILE_PATH = "X-File-Path"
|
@@ -229,7 +231,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
229
231
|
# Token auto-refresh
|
230
232
|
self._token_refresh_timer = None
|
231
233
|
self._auto_refresh_token = auto_refresh_token
|
232
|
-
self.jwt_token = jwt_token # Set property last after all dependencies are initialized
|
234
|
+
self.jwt_token = jwt_token # Set property last after all dependencies are initialized to setup refresh timer
|
233
235
|
|
234
236
|
@staticmethod
|
235
237
|
def _ensure_logging_configured():
|
@@ -306,7 +308,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
306
308
|
check_interval = 1 # Almost immediate refresh
|
307
309
|
else:
|
308
310
|
# Check at earlier of 5 minutes before expiry or regular interval
|
309
|
-
check_interval = min(time_to_expiry - self.TOKEN_REFRESH_OFFSET, self.TOKEN_REFRESH_INTERVAL)
|
311
|
+
check_interval = max(1, min(time_to_expiry - self.TOKEN_REFRESH_OFFSET, self.TOKEN_REFRESH_INTERVAL))
|
310
312
|
|
311
313
|
# Create timer to execute refresh check
|
312
314
|
self._token_refresh_timer = threading.Timer(check_interval, self._check_and_refresh_token)
|
@@ -472,7 +474,7 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
472
474
|
AppMeshClient.Method.POST,
|
473
475
|
path="/appmesh/login",
|
474
476
|
header={
|
475
|
-
|
477
|
+
self.HTTP_HEADER_KEY_AUTH: _basic_auth_str(user_name, user_pwd),
|
476
478
|
"X-Expire-Seconds": str(self._parse_duration(timeout_seconds)),
|
477
479
|
**({"X-Audience": audience} if audience else {}),
|
478
480
|
# **({"X-Totp-Code": totp_code} if totp_code else {}),
|
@@ -1396,9 +1398,8 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
1396
1398
|
|
1397
1399
|
# Prepare headers
|
1398
1400
|
header = {} if header is None else header
|
1399
|
-
if self.
|
1400
|
-
|
1401
|
-
header["Authorization"] = "Bearer " + token
|
1401
|
+
if token := self._get_access_token():
|
1402
|
+
header[self.HTTP_HEADER_KEY_AUTH] = f"Bearer {token}"
|
1402
1403
|
if self.forward_to and len(self.forward_to) > 0:
|
1403
1404
|
if ":" in self.forward_to:
|
1404
1405
|
header[self.HTTP_HEADER_KEY_X_TARGET_HOST] = self.forward_to
|
@@ -1436,4 +1437,4 @@ class AppMeshClient(metaclass=abc.ABCMeta):
|
|
1436
1437
|
# Wrap the response for encoding handling
|
1437
1438
|
return AppMeshClient.EncodingResponse(resp)
|
1438
1439
|
except requests.exceptions.RequestException as e:
|
1439
|
-
raise Exception(f"HTTP request failed: {str(e)}")
|
1440
|
+
raise Exception(f"HTTP request failed: {str(e)}") from e
|
appmesh/client_tcp.py
CHANGED
@@ -116,8 +116,8 @@ class AppMeshClientTCP(AppMeshClient):
|
|
116
116
|
self.tcp_transport.connect()
|
117
117
|
|
118
118
|
appmesh_request = RequestMessage()
|
119
|
-
if
|
120
|
-
appmesh_request.headers[
|
119
|
+
if token := self._get_access_token():
|
120
|
+
appmesh_request.headers[self.HTTP_HEADER_KEY_AUTH] = token
|
121
121
|
if super().forward_to and len(super().forward_to) > 0:
|
122
122
|
raise Exception("Not support forward request in TCP mode")
|
123
123
|
appmesh_request.headers[self.HTTP_HEADER_KEY_USER_AGENT] = self.HTTP_USER_AGENT_TCP
|
appmesh/server_http.py
CHANGED
@@ -17,7 +17,7 @@ class AppMeshServer(metaclass=abc.ABCMeta):
|
|
17
17
|
Server SDK for App Mesh application interacting with the local App Mesh REST service over HTTPS.
|
18
18
|
|
19
19
|
Build-in runtime environment variables required:
|
20
|
-
-
|
20
|
+
- APP_MESH_PROCESS_KEY
|
21
21
|
- APP_MESH_APPLICATION_NAME
|
22
22
|
|
23
23
|
Methods:
|
@@ -58,10 +58,10 @@ class AppMeshServer(metaclass=abc.ABCMeta):
|
|
58
58
|
@staticmethod
|
59
59
|
def _get_runtime_env() -> Tuple[str, str]:
|
60
60
|
"""Read and validate required runtime environment variables."""
|
61
|
-
process_id = os.getenv("
|
61
|
+
process_id = os.getenv("APP_MESH_PROCESS_KEY")
|
62
62
|
app_name = os.getenv("APP_MESH_APPLICATION_NAME")
|
63
63
|
if not process_id:
|
64
|
-
raise Exception("Missing environment variable:
|
64
|
+
raise Exception("Missing environment variable: APP_MESH_PROCESS_KEY. This must be set by App Mesh service.")
|
65
65
|
if not app_name:
|
66
66
|
raise Exception("Missing environment variable: APP_MESH_APPLICATION_NAME. This must be set by App Mesh service.")
|
67
67
|
return process_id, app_name
|
@@ -3,14 +3,14 @@ appmesh/app.py,sha256=crD4DRFZJuHtZMfSsz7C-EwvjPmGZbFXYXvA_wCdvdI,10734
|
|
3
3
|
appmesh/app_output.py,sha256=vfn322AyixblI8DbXds08h6L_ybObiaRSifsA1-Xcoo,1035
|
4
4
|
appmesh/app_run.py,sha256=aYq852a29OThIi32Xtx5s0sTXZ97T0lHD5WXH8yfPoc,2018
|
5
5
|
appmesh/appmesh_client.py,sha256=ywB2222PtJUffdfdxZcBfdhZs1KYyc7JvzMxwuK2qyI,378
|
6
|
-
appmesh/client_http.py,sha256=
|
6
|
+
appmesh/client_http.py,sha256=Clx0Wx8I8Wo8T63f2dco_vDI12mbcqKOMt7d7xBXJFc,57516
|
7
7
|
appmesh/client_http_oauth.py,sha256=1d51o0JX_xtB8d2bEuM7_XJHcwMnhcjkbIq7GE1Zxm8,6120
|
8
|
-
appmesh/client_tcp.py,sha256=
|
9
|
-
appmesh/server_http.py,sha256=
|
8
|
+
appmesh/client_tcp.py,sha256=hQ4s9ab1Drqaqhfx-pmLhqhFL48jbwNbkzOv1fCSUnw,11444
|
9
|
+
appmesh/server_http.py,sha256=H6DfMhU2NxlBqxjmRG2C8NXMaGDxy_5QVyBmaVrelfI,4322
|
10
10
|
appmesh/server_tcp.py,sha256=-CU5tw97WJmDcUNsNPWqpdZ0wxRzRD6kUP3XyNZUTHc,1444
|
11
11
|
appmesh/tcp_messages.py,sha256=H9S_iCy0IuufY2v50_SUgRvcyQmJsySG65tBe_xb3Ko,1878
|
12
12
|
appmesh/tcp_transport.py,sha256=0hRSp5fpL9wKB05JIyIRIuyBC8w1IdokryhMDHqtN4M,8946
|
13
|
-
appmesh-1.6.
|
14
|
-
appmesh-1.6.
|
15
|
-
appmesh-1.6.
|
16
|
-
appmesh-1.6.
|
13
|
+
appmesh-1.6.5.dist-info/METADATA,sha256=vYzVg5U0rZNL8_HaPR3-CPuw2RFoLsUiB8UB7YDNyJI,11828
|
14
|
+
appmesh-1.6.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
15
|
+
appmesh-1.6.5.dist-info/top_level.txt,sha256=-y0MNQOGJxUzLdHZ6E_Rfv5_LNCkV-GTmOBME_b6pg8,8
|
16
|
+
appmesh-1.6.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|