boto3-refresh-session 1.3.15__py3-none-any.whl → 1.3.17__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.
@@ -4,7 +4,7 @@ from .session import RefreshableSession
4
4
  from .sts import STSRefreshableSession
5
5
 
6
6
  __all__ = ["RefreshableSession"]
7
- __version__ = "1.3.15"
7
+ __version__ = "1.3.17"
8
8
  __title__ = "boto3-refresh-session"
9
9
  __author__ = "Mike Letts"
10
10
  __maintainer__ = "Mike Letts"
@@ -5,7 +5,7 @@ __all__ = ["CustomRefreshableSession"]
5
5
  from typing import Any, Callable
6
6
 
7
7
  from .exceptions import BRSError
8
- from .session import BaseRefreshableSession
8
+ from .session import BaseRefreshableSession, TemporaryCredentials
9
9
 
10
10
 
11
11
  class CustomRefreshableSession(BaseRefreshableSession, method="custom"):
@@ -80,8 +80,8 @@ class CustomRefreshableSession(BaseRefreshableSession, method="custom"):
80
80
  refresh_method="custom",
81
81
  )
82
82
 
83
- def _get_credentials(self) -> dict[str, str]:
84
- credentials = self._custom_get_credentials(
83
+ def _get_credentials(self) -> TemporaryCredentials:
84
+ credentials: TemporaryCredentials = self._custom_get_credentials(
85
85
  **self._custom_get_credentials_args
86
86
  )
87
87
  required_keys = {"access_key", "secret_key", "token", "expiry_time"}
@@ -96,14 +96,12 @@ class CustomRefreshableSession(BaseRefreshableSession, method="custom"):
96
96
  return credentials
97
97
 
98
98
  def get_identity(self) -> dict[str, str]:
99
- """
100
- Returns metadata about the custom credential getter.
99
+ """Returns metadata about the custom credential getter.
101
100
 
102
101
  Returns
103
102
  -------
104
103
  dict[str, str]
105
104
  Dict containing information about the custom credential getter.
106
-
107
105
  """
108
106
 
109
107
  source = getattr(
@@ -7,7 +7,7 @@ import os
7
7
  import requests
8
8
 
9
9
  from .exceptions import BRSError
10
- from .session import BaseRefreshableSession
10
+ from .session import BaseRefreshableSession, TemporaryCredentials
11
11
 
12
12
  _ECS_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"
13
13
  _ECS_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI"
@@ -71,7 +71,7 @@ class ECSRefreshableSession(BaseRefreshableSession, method="ecs"):
71
71
  session.headers.update(self._headers)
72
72
  return session
73
73
 
74
- def _get_credentials(self) -> dict[str, str]:
74
+ def _get_credentials(self) -> TemporaryCredentials:
75
75
  try:
76
76
  response = self._http.get(self._endpoint, timeout=3)
77
77
  response.raise_for_status()
@@ -3,7 +3,8 @@ from __future__ import annotations
3
3
  __all__ = ["RefreshableSession"]
4
4
 
5
5
  from abc import ABC, abstractmethod
6
- from typing import Any, Callable, ClassVar, Literal, get_args
6
+ from datetime import datetime
7
+ from typing import Any, Callable, ClassVar, Literal, TypedDict, get_args
7
8
 
8
9
  from boto3.session import Session
9
10
  from botocore.credentials import (
@@ -18,9 +19,17 @@ Method = Literal["sts", "ecs", "custom"]
18
19
  RefreshMethod = Literal["sts-assume-role", "ecs-container-metadata", "custom"]
19
20
 
20
21
 
22
+ class TemporaryCredentials(TypedDict):
23
+ """Temporary IAM credentials."""
24
+
25
+ access_key: str
26
+ secret_key: str
27
+ token: str
28
+ expiry_time: datetime | str
29
+
30
+
21
31
  class BaseRefreshableSession(ABC, Session):
22
- """
23
- Abstract base class for implementing refreshable AWS sessions.
32
+ """Abstract base class for implementing refreshable AWS sessions.
24
33
 
25
34
  Provides a common interface and factory registration mechanism
26
35
  for subclasses that generate temporary credentials using various
@@ -34,7 +43,6 @@ class BaseRefreshableSession(ABC, Session):
34
43
  ----------
35
44
  registry : dict[str, type[BaseRefreshableSession]]
36
45
  Class-level registry mapping method names to registered session types.
37
-
38
46
  """
39
47
 
40
48
  # adding this and __init_subclass__ to avoid circular imports
@@ -56,7 +64,7 @@ class BaseRefreshableSession(ABC, Session):
56
64
  super().__init__(**kwargs)
57
65
 
58
66
  @abstractmethod
59
- def _get_credentials(self) -> dict[str, str]: ...
67
+ def _get_credentials(self) -> TemporaryCredentials: ...
60
68
 
61
69
  @abstractmethod
62
70
  def get_identity(self) -> dict[str, Any]: ...
@@ -80,8 +88,7 @@ class BaseRefreshableSession(ABC, Session):
80
88
  )
81
89
 
82
90
  def refreshable_credentials(self) -> dict[str, str]:
83
- """
84
- The current temporary AWS security credentials.
91
+ """The current temporary AWS security credentials.
85
92
 
86
93
  Returns
87
94
  -------
@@ -93,7 +100,6 @@ class BaseRefreshableSession(ABC, Session):
93
100
  AWS secret access key.
94
101
  AWS_SESSION_TOKEN : str
95
102
  AWS session token.
96
-
97
103
  """
98
104
 
99
105
  creds = self.get_credentials().get_frozen_credentials()
@@ -140,7 +146,6 @@ class RefreshableSession:
140
146
  boto3_refresh_session.custom.CustomRefreshableSession
141
147
  boto3_refresh_session.sts.STSRefreshableSession
142
148
  boto3_refresh_session.ecs.ECSRefreshableSession
143
-
144
149
  """
145
150
 
146
151
  def __new__(
@@ -5,7 +5,7 @@ __all__ = ["STSRefreshableSession"]
5
5
  from typing import Any
6
6
 
7
7
  from .exceptions import BRSWarning
8
- from .session import BaseRefreshableSession
8
+ from .session import BaseRefreshableSession, TemporaryCredentials
9
9
 
10
10
 
11
11
  class STSRefreshableSession(BaseRefreshableSession, method="sts"):
@@ -66,7 +66,7 @@ class STSRefreshableSession(BaseRefreshableSession, method="sts"):
66
66
  refresh_method="sts-assume-role",
67
67
  )
68
68
 
69
- def _get_credentials(self) -> dict[str, str]:
69
+ def _get_credentials(self) -> TemporaryCredentials:
70
70
  temporary_credentials = self._sts_client.assume_role(
71
71
  **self.assume_role_kwargs
72
72
  )["Credentials"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: boto3-refresh-session
3
- Version: 1.3.15
3
+ Version: 1.3.17
4
4
  Summary: A simple Python package for refreshing the temporary security credentials in a boto3.session.Session object automatically.
5
5
  License: MIT
6
6
  Keywords: boto3,botocore,aws,sts,ecs,credentials,token,refresh
@@ -57,11 +57,11 @@ Description-Content-Type: text/markdown
57
57
  </a>
58
58
 
59
59
  <a href="https://pypistats.org/packages/boto3-refresh-session">
60
- <img src="https://img.shields.io/badge/downloads-67.6K-red?logo=python&color=%23FF0000&label=Downloads%20%28with%20mirrors%29" alt="Downloads with mirrors"/>
60
+ <img src="https://img.shields.io/badge/downloads-72.1K-red?logo=python&color=%23FF0000&label=Downloads%20%28with%20mirrors%29" alt="Downloads with mirrors"/>
61
61
  </a>
62
62
 
63
63
  <a href="https://pypistats.org/packages/boto3-refresh-session">
64
- <img src="https://img.shields.io/badge/downloads-17.3K-red?logo=python&color=%23FF0000&label=Downloads%20%28without%20mirrors%29" alt="Downloads without mirrors"/>
64
+ <img src="https://img.shields.io/badge/downloads-18.1K-red?logo=python&color=%23FF0000&label=Downloads%20%28without%20mirrors%29" alt="Downloads without mirrors"/>
65
65
  </a>
66
66
 
67
67
  <a href="https://michaelthomasletts.github.io/boto3-refresh-session/index.html">
@@ -0,0 +1,11 @@
1
+ boto3_refresh_session/__init__.py,sha256=hh8Wnfs1zfTXzMDJdHdAgRNk49evO3K_a-_SwEPgbas,364
2
+ boto3_refresh_session/custom.py,sha256=wR7122COYuFkmVprORfz-mPRqH4XeTH8Uw8_2QUYWUg,3845
3
+ boto3_refresh_session/ecs.py,sha256=Php_ETJ-4E99ka93nXwpDa7vS3El7UCxfX0ptb6ofA4,3741
4
+ boto3_refresh_session/exceptions.py,sha256=qcFzdIuK5PZirs77H_Kb64S9QFb6cn2OJtirjvaRLiY,972
5
+ boto3_refresh_session/session.py,sha256=TGI3-Zv52kGigw0f-mUNBkB2nqM632gCRZgY6KhZd-A,5564
6
+ boto3_refresh_session/sts.py,sha256=f9dtJMfs5bYWfZAcKuANAe0InjmNjZfKyqt5LpHFDxk,3202
7
+ boto3_refresh_session-1.3.17.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
8
+ boto3_refresh_session-1.3.17.dist-info/METADATA,sha256=htPgP6GardF6_6y6QdRwZNcLNB3YWEiBzj9uMi1_U5c,7804
9
+ boto3_refresh_session-1.3.17.dist-info/NOTICE,sha256=1s8r33qbl1z0YvPB942iWgvbkP94P_e8AnROr1qXXuw,939
10
+ boto3_refresh_session-1.3.17.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
+ boto3_refresh_session-1.3.17.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- boto3_refresh_session/__init__.py,sha256=_4VLYpIvCjuw0X_PUpBwM5vDKWGPpsouzlNkzm0wJKE,364
2
- boto3_refresh_session/custom.py,sha256=YuorVYEzoYxLkzuoMwSqqAmN0n7ZsXKkS2Q8soAyGkc,3805
3
- boto3_refresh_session/ecs.py,sha256=2lLMDWEE_JArBf0sRtcFmrzxiIpo_S6dauHS-TDUn4U,3713
4
- boto3_refresh_session/exceptions.py,sha256=qcFzdIuK5PZirs77H_Kb64S9QFb6cn2OJtirjvaRLiY,972
5
- boto3_refresh_session/session.py,sha256=mxATkH7rDTCiPtEbqxIkhnl_i7xwHJ0wzTH8Zv-xaL8,5368
6
- boto3_refresh_session/sts.py,sha256=gJKbslmNl8kR8oAeZfOGmrHtgUUxMm7e9hPgZO678FE,3174
7
- boto3_refresh_session-1.3.15.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
8
- boto3_refresh_session-1.3.15.dist-info/METADATA,sha256=s6KkLftJRR6xtmntJt8M2Y_QFVZWOdKdrT3BN9BBHhg,7804
9
- boto3_refresh_session-1.3.15.dist-info/NOTICE,sha256=1s8r33qbl1z0YvPB942iWgvbkP94P_e8AnROr1qXXuw,939
10
- boto3_refresh_session-1.3.15.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
- boto3_refresh_session-1.3.15.dist-info/RECORD,,