Skip to content

Commit d126996

Browse files
Merge pull request #50 from mdsol/fix/asgi-middleware-scope
Fixe a use-case when scope path is not set yet
2 parents 0f3a90a + 2881f42 commit d126996

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.6.4
2+
- Fix `MAuthASGIMiddleware` when accessing `path` when `path` is not set yet.
3+
This appears to only happen on startup.
4+
- Replace the character `\n` on one-liner private keys.
5+
16
# 1.6.3
27
- Revert change introduced in v1.6.2 now that Starlette has been updated to
38
always include `root_path` in `path`.

mauth_client/lambda_helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ def _get_private_key():
2020
except ModuleNotFoundError:
2121
pass
2222

23-
return private_key.replace(" ", "\n").replace("\nRSA\nPRIVATE\nKEY", " RSA PRIVATE KEY")
23+
return private_key.replace("\\n", "\n").replace(" ", "\n").replace("\nRSA\nPRIVATE\nKEY", " RSA PRIVATE KEY")

mauth_client/middlewares/asgi.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ def __init__(self, app: ASGI3Application, exempt: Optional[set] = None) -> None:
3333
async def __call__(
3434
self, scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable
3535
) -> None:
36-
path = scope["path"]
36+
if scope["type"] != "http":
37+
return await self.app(scope, receive, send)
3738

38-
if scope["type"] != "http" or path in self.exempt:
39+
path = scope["path"]
40+
if path in self.exempt:
3941
return await self.app(scope, receive, send)
4042

4143
query_string = scope["query_string"]

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mauth-client"
3-
version = "1.6.3"
3+
version = "1.6.4"
44
description = "MAuth Client for Python"
55
repository = "https://github.com/mdsol/mauth-client-python"
66
authors = ["Medidata Solutions <[email protected]>"]

0 commit comments

Comments
 (0)