aiohttp-msal 1.0.0__py3-none-any.whl → 1.0.1__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.
@@ -8,7 +8,7 @@ Once you have the OAuth tokens store in the session, you are free to make reques
8
8
  import asyncio
9
9
  import json
10
10
  from collections.abc import Callable
11
- from functools import partial, partialmethod, wraps
11
+ from functools import cached_property, partial, partialmethod, wraps
12
12
  from typing import Any, ClassVar, Literal, Unpack
13
13
 
14
14
  from aiohttp import web
@@ -70,8 +70,6 @@ class AsyncMSAL:
70
70
  Use until such time as MSAL Python gets a true async version.
71
71
  """
72
72
 
73
- _token_cache: SerializableTokenCache
74
- _app: ConfidentialClientApplication
75
73
  client_session: ClassVar[ClientSession | None] = None
76
74
 
77
75
  def __init__(
@@ -89,33 +87,27 @@ class AsyncMSAL:
89
87
  if not isinstance(session, Session | dict):
90
88
  raise ValueError(f"session or dict-like object required {session}")
91
89
 
92
- @property
90
+ @cached_property
93
91
  def token_cache(self) -> SerializableTokenCache:
94
92
  """Get the token_cache."""
95
- if not self._token_cache:
96
- self._token_cache = SerializableTokenCache()
97
- # _load_token_cache
98
- if self.session and self.session.get(TOKEN_CACHE):
99
- self._token_cache.deserialize(self.session[TOKEN_CACHE])
100
-
101
- return self._token_cache
93
+ res = SerializableTokenCache()
94
+ if self.session and self.session.get(TOKEN_CACHE):
95
+ res.deserialize(self.session[TOKEN_CACHE])
96
+ return res
102
97
 
103
- @property
98
+ @cached_property
104
99
  def app(self) -> ConfidentialClientApplication:
105
100
  """Create the application using the cache.
106
101
 
107
102
  Based on: https://github.com/Azure-Samples/ms-identity-python-webapp/blob/master/app.py#L76
108
103
  """
109
- if not self._app:
110
- token_cache = self.token_cache
111
- self._app = ConfidentialClientApplication(
112
- client_id=ENV.SP_APP_ID,
113
- client_credential=ENV.SP_APP_PW,
114
- authority=ENV.SP_AUTHORITY, # common/oauth2/v2.0/token'
115
- validate_authority=False,
116
- token_cache=token_cache,
117
- )
118
- return self._app
104
+ return ConfidentialClientApplication(
105
+ client_id=ENV.SP_APP_ID,
106
+ client_credential=ENV.SP_APP_PW,
107
+ authority=ENV.SP_AUTHORITY, # common/oauth2/v2.0/token'
108
+ validate_authority=False,
109
+ token_cache=self.token_cache,
110
+ )
119
111
 
120
112
  def save_token_cache(self) -> None:
121
113
  """Save the token cache if it changed."""
@@ -227,18 +219,10 @@ class AsyncMSAL:
227
219
  get = partialmethod(request_ctx, HTTP_GET)
228
220
  post = partialmethod(request_ctx, HTTP_POST)
229
221
 
230
- # def get(self, url: str, **kwargs: Any) -> _RequestContextManager:
231
- # """GET Request."""
232
- # return _RequestContextManager(self.request(HTTP_GET, url, **kwargs))
233
-
234
- # def post(self, url: str, **kwargs: Any) -> _RequestContextManager:
235
- # """POST request."""
236
- # return _RequestContextManager(self.request(HTTP_POST, url, **kwargs))
237
-
238
222
  @property
239
223
  def mail(self) -> str:
240
224
  """User email."""
241
- return self.session.get("mail", "")
225
+ return self.session.get(USER_EMAIL, "")
242
226
 
243
227
  @property
244
228
  def manager_mail(self) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aiohttp-msal
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: Helper Library to use the Microsoft Authentication Library (MSAL) with aiohttp
5
5
  Keywords: aiohttp,asyncio,msal,oauth
6
6
  Author: Johann Kellerman
@@ -23,7 +23,7 @@ Project-URL: Homepage, https://github.com/kellerza/aiohttp_msal
23
23
  Provides-Extra: aioredis
24
24
  Description-Content-Type: text/markdown
25
25
 
26
- # aiohttp_msal Python library
26
+ # Async based MSAL helper for aiohttp - aiohttp_msal Python library
27
27
 
28
28
  Authorization Code Flow Helper. Learn more about auth-code-flow at
29
29
  <https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow>
@@ -124,8 +124,8 @@ from aiohttp_msal.redis_tools import get_session
124
124
  def main()
125
125
  # Uses the redis.asyncio driver to retrieve the current token
126
126
  # Will update the token_cache if a RefreshToken was used
127
- ases = asyncio.run(get_session(MYEMAIL))
128
- client = GraphClient(ases.get_token)
127
+ ses = asyncio.run(get_session(MYEMAIL))
128
+ client = GraphClient(ses.get_token)
129
129
  # ...
130
130
  # use the Graphclient
131
131
  ```
@@ -0,0 +1,10 @@
1
+ aiohttp_msal/__init__.py,sha256=hnyifyJykI7NMvM93KrHIsTlrrfCVUrpKdbRKL6Gubw,4027
2
+ aiohttp_msal/msal_async.py,sha256=p0OkF48ZDmCAUYN4qjn3UdMyH1oS4iBQSB5Z_C3yIBU,8816
3
+ aiohttp_msal/redis_tools.py,sha256=6kCw0_zDQcvIcsJaPfG-zHUvT3vzkrNySNTV5y1tckE,6539
4
+ aiohttp_msal/routes.py,sha256=8wU2jU9qSlqH5fq9kvkBZHAgrxQdmB-DvtQC-WlXbh0,8135
5
+ aiohttp_msal/settings.py,sha256=ttbqGb2X1r7DsLvKb1AlDDKBYZWjIwHLHI-Sa-8K-lI,1562
6
+ aiohttp_msal/settings_base.py,sha256=tRbjgphR1tvHCrFCcfOUhoFAyUnq_XnJBVO4NNiPdNg,3150
7
+ aiohttp_msal/user_info.py,sha256=tO-vA_kxPseHseWxNlhGc_NlDfgJGdf1OMCaGmvDf8Q,1875
8
+ aiohttp_msal-1.0.1.dist-info/WHEEL,sha256=4n27za1eEkOnA7dNjN6C5-O2rUiw6iapszm14Uj-Qmk,79
9
+ aiohttp_msal-1.0.1.dist-info/METADATA,sha256=NJEzFuQyWHai3QcqvyTfeAWWfjq98nucwoYFt3qIOvc,4514
10
+ aiohttp_msal-1.0.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: uv 0.8.12
2
+ Generator: uv 0.8.13
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,10 +0,0 @@
1
- aiohttp_msal/__init__.py,sha256=867ca27f2272908ecd32f33ddcaac722c4e5aeb7c2554ae929d6d128be86b9bc,4027
2
- aiohttp_msal/msal_async.py,sha256=8efdf9608c55e41f99ed66294a18303192e921739f49986cf90a015b07a50c55,9470
3
- aiohttp_msal/redis_tools.py,sha256=ea40b0d3fcc341cbc872c25a3df1becc752f4f7bf392b37248d4d5e72d6d7241,6539
4
- aiohttp_msal/routes.py,sha256=f305368d4f6a4a5a87e5fabd92f901647020af141d981f83bed402f969576e1d,8135
5
- aiohttp_msal/settings.py,sha256=b6d6ea19bd97d6bec3b0bbca6f50250c32816195a32301cb1c8f926bef0afa52,1562
6
- aiohttp_msal/settings_base.py,sha256=b516e3829851d6dbc70ab14271f394868140c949eafd79c90553b834d88f74d8,3150
7
- aiohttp_msal/user_info.py,sha256=b4efaf03f9313ec787b1e5b136584673f3650df80919d7f538c09a1a6bc37fc4,1875
8
- aiohttp_msal-1.0.0.dist-info/WHEEL,sha256=76443c98c0efcfdd1191eac5fa1d8223dba1c474dbd47676674a255e7ca48770,79
9
- aiohttp_msal-1.0.0.dist-info/METADATA,sha256=dd4a69bc47da5e6c559fda12c41505fdc047c8edde36d498d25a93fc0b7b4ec8,4478
10
- aiohttp_msal-1.0.0.dist-info/RECORD,,