boto3-refresh-session 2.0.10__py3-none-any.whl → 3.0.0__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.
- boto3_refresh_session/__init__.py +11 -6
- boto3_refresh_session/exceptions.py +3 -0
- boto3_refresh_session/methods/__init__.py +12 -0
- boto3_refresh_session/methods/custom.py +3 -5
- boto3_refresh_session/methods/ecs.py +6 -4
- boto3_refresh_session/methods/iot/certificate.typed +3 -1
- boto3_refresh_session/methods/iot/core.typed +3 -3
- boto3_refresh_session/methods/sts.py +1 -5
- boto3_refresh_session/session.py +1 -27
- boto3_refresh_session/utils/__init__.py +8 -0
- boto3_refresh_session/{utils.py → utils/internal.py} +72 -157
- boto3_refresh_session/utils/typing.py +145 -0
- {boto3_refresh_session-2.0.10.dist-info → boto3_refresh_session-3.0.0.dist-info}/METADATA +19 -15
- boto3_refresh_session-3.0.0.dist-info/RECORD +19 -0
- boto3_refresh_session-2.0.10.dist-info/RECORD +0 -17
- {boto3_refresh_session-2.0.10.dist-info → boto3_refresh_session-3.0.0.dist-info}/LICENSE +0 -0
- {boto3_refresh_session-2.0.10.dist-info → boto3_refresh_session-3.0.0.dist-info}/NOTICE +0 -0
- {boto3_refresh_session-2.0.10.dist-info → boto3_refresh_session-3.0.0.dist-info}/WHEEL +0 -0
@@ -1,10 +1,15 @@
|
|
1
|
-
|
2
|
-
from .methods.ecs import ECSRefreshableSession
|
3
|
-
from .methods.sts import STSRefreshableSession
|
4
|
-
from .session import RefreshableSession
|
1
|
+
__all__ = []
|
5
2
|
|
6
|
-
|
7
|
-
|
3
|
+
from . import exceptions, session
|
4
|
+
from .exceptions import *
|
5
|
+
from .methods.custom import *
|
6
|
+
from .methods.ecs import *
|
7
|
+
from .methods.sts import *
|
8
|
+
from .session import *
|
9
|
+
|
10
|
+
__all__.extend(session.__all__)
|
11
|
+
__all__.extend(exceptions.__all__)
|
12
|
+
__version__ = "3.0.0"
|
8
13
|
__title__ = "boto3-refresh-session"
|
9
14
|
__author__ = "Mike Letts"
|
10
15
|
__maintainer__ = "Mike Letts"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
__all__ = []
|
2
|
+
|
3
|
+
# TODO: import iot submodules when finished
|
4
|
+
from . import custom, ecs, sts
|
5
|
+
from .custom import CustomRefreshableSession
|
6
|
+
from .ecs import ECSRefreshableSession
|
7
|
+
from .sts import STSRefreshableSession
|
8
|
+
|
9
|
+
# TODO: add iot submodules to __all__ when finished
|
10
|
+
__all__.extend(custom.__all__)
|
11
|
+
__all__.extend(ecs.__all__)
|
12
|
+
__all__.extend(sts.__all__)
|
@@ -1,12 +1,8 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
1
|
__all__ = ["CustomRefreshableSession"]
|
4
2
|
|
5
|
-
from typing import Any, Callable
|
6
|
-
|
7
3
|
from ..exceptions import BRSError, BRSWarning
|
8
|
-
from ..session import BaseRefreshableSession
|
9
4
|
from ..utils import (
|
5
|
+
BaseRefreshableSession,
|
10
6
|
CustomCredentialsMethod,
|
11
7
|
CustomCredentialsMethodArgs,
|
12
8
|
Identity,
|
@@ -83,6 +79,8 @@ class CustomRefreshableSession(BaseRefreshableSession, registry_key="custom"):
|
|
83
79
|
|
84
80
|
# initializing BRSSession
|
85
81
|
super().__init__(refresh_method="custom", **kwargs)
|
82
|
+
|
83
|
+
# initializing various other attributes
|
86
84
|
self._custom_get_credentials: CustomCredentialsMethod = (
|
87
85
|
custom_credentials_method
|
88
86
|
)
|
@@ -1,5 +1,3 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
1
|
__all__ = ["ECSRefreshableSession"]
|
4
2
|
|
5
3
|
import os
|
@@ -7,8 +5,12 @@ import os
|
|
7
5
|
import requests
|
8
6
|
|
9
7
|
from ..exceptions import BRSError, BRSWarning
|
10
|
-
from ..
|
11
|
-
|
8
|
+
from ..utils import (
|
9
|
+
BaseRefreshableSession,
|
10
|
+
Identity,
|
11
|
+
TemporaryCredentials,
|
12
|
+
refreshable_session,
|
13
|
+
)
|
12
14
|
|
13
15
|
_ECS_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"
|
14
16
|
_ECS_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI"
|
@@ -4,7 +4,9 @@ from pathlib import Path
|
|
4
4
|
from typing import Any
|
5
5
|
|
6
6
|
from ...exceptions import BRSError
|
7
|
-
from ...utils import
|
7
|
+
from ...utils import (
|
8
|
+
Identity, PKCS11, TemporaryCredentials, refreshable_session
|
9
|
+
)
|
8
10
|
from .core import BaseIoTRefreshableSession
|
9
11
|
|
10
12
|
|
@@ -5,11 +5,11 @@ __all__ = ["IoTRefreshableSession"]
|
|
5
5
|
from typing import get_args
|
6
6
|
|
7
7
|
from ...exceptions import BRSError
|
8
|
-
from ...session import BaseRefreshableSession
|
9
8
|
from ...utils import (
|
10
|
-
|
9
|
+
BaseRefreshableSession,
|
11
10
|
BRSSession,
|
12
|
-
CredentialProvider,
|
11
|
+
CredentialProvider,
|
12
|
+
IoTAuthenticationMethod,
|
13
13
|
Registry,
|
14
14
|
)
|
15
15
|
|
@@ -1,13 +1,9 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
1
|
__all__ = ["STSRefreshableSession"]
|
4
2
|
|
5
|
-
from typing import Any
|
6
|
-
|
7
3
|
from ..exceptions import BRSWarning
|
8
|
-
from ..session import BaseRefreshableSession
|
9
4
|
from ..utils import (
|
10
5
|
AssumeRoleParams,
|
6
|
+
BaseRefreshableSession,
|
11
7
|
Identity,
|
12
8
|
STSClientParams,
|
13
9
|
TemporaryCredentials,
|
boto3_refresh_session/session.py
CHANGED
@@ -5,33 +5,7 @@ __all__ = ["RefreshableSession"]
|
|
5
5
|
from typing import get_args
|
6
6
|
|
7
7
|
from .exceptions import BRSError
|
8
|
-
from .utils import
|
9
|
-
|
10
|
-
|
11
|
-
class BaseRefreshableSession(
|
12
|
-
Registry[Method],
|
13
|
-
CredentialProvider,
|
14
|
-
BRSSession,
|
15
|
-
registry_key="__sentinel__",
|
16
|
-
):
|
17
|
-
"""Abstract base class for implementing refreshable AWS sessions.
|
18
|
-
|
19
|
-
Provides a common interface and factory registration mechanism
|
20
|
-
for subclasses that generate temporary credentials using various
|
21
|
-
AWS authentication methods (e.g., STS).
|
22
|
-
|
23
|
-
Subclasses must implement ``_get_credentials()`` and ``get_identity()``.
|
24
|
-
They should also register themselves using the ``method=...`` argument
|
25
|
-
to ``__init_subclass__``.
|
26
|
-
|
27
|
-
Parameters
|
28
|
-
----------
|
29
|
-
registry : dict[str, type[BaseRefreshableSession]]
|
30
|
-
Class-level registry mapping method names to registered session types.
|
31
|
-
"""
|
32
|
-
|
33
|
-
def __init__(self, **kwargs):
|
34
|
-
super().__init__(**kwargs)
|
8
|
+
from .utils import BaseRefreshableSession, Method
|
35
9
|
|
36
10
|
|
37
11
|
class RefreshableSession:
|
@@ -1,22 +1,14 @@
|
|
1
|
-
|
1
|
+
__all__ = [
|
2
|
+
"BaseRefreshableSession",
|
3
|
+
"BRSSession",
|
4
|
+
"CredentialProvider",
|
5
|
+
"Registry",
|
6
|
+
"refreshable_session",
|
7
|
+
]
|
2
8
|
|
3
9
|
from abc import ABC, abstractmethod
|
4
|
-
from datetime import datetime
|
5
10
|
from functools import wraps
|
6
|
-
from typing import
|
7
|
-
Any,
|
8
|
-
Callable,
|
9
|
-
ClassVar,
|
10
|
-
Generic,
|
11
|
-
List,
|
12
|
-
Literal,
|
13
|
-
Mapping,
|
14
|
-
Protocol,
|
15
|
-
TypeAlias,
|
16
|
-
TypedDict,
|
17
|
-
TypeVar,
|
18
|
-
cast,
|
19
|
-
)
|
11
|
+
from typing import Any, Callable, ClassVar, Generic, TypeVar, cast
|
20
12
|
|
21
13
|
from boto3.session import Session
|
22
14
|
from botocore.credentials import (
|
@@ -24,46 +16,62 @@ from botocore.credentials import (
|
|
24
16
|
RefreshableCredentials,
|
25
17
|
)
|
26
18
|
|
27
|
-
from
|
19
|
+
from ..exceptions import BRSWarning
|
20
|
+
from .typing import (
|
21
|
+
Identity,
|
22
|
+
Method,
|
23
|
+
RefreshableTemporaryCredentials,
|
24
|
+
RefreshMethod,
|
25
|
+
RegistryKey,
|
26
|
+
TemporaryCredentials,
|
27
|
+
)
|
28
28
|
|
29
|
-
try:
|
30
|
-
from typing import NotRequired # type: ignore[import]
|
31
|
-
except ImportError:
|
32
|
-
from typing_extensions import NotRequired
|
33
29
|
|
34
|
-
|
35
|
-
|
30
|
+
class CredentialProvider(ABC):
|
31
|
+
"""Defines the abstract surface every refreshable session must expose."""
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
"sts",
|
40
|
-
"ecs",
|
41
|
-
"custom",
|
42
|
-
"__sentinel__",
|
43
|
-
] # TODO: Add iot when implemented
|
33
|
+
@abstractmethod
|
34
|
+
def _get_credentials(self) -> TemporaryCredentials: ...
|
44
35
|
|
45
|
-
|
46
|
-
|
47
|
-
"sts-assume-role",
|
48
|
-
"ecs-container-metadata",
|
49
|
-
"custom",
|
50
|
-
] # Add iot-certificate and iot-cognito when iot implemented
|
36
|
+
@abstractmethod
|
37
|
+
def get_identity(self) -> Identity: ...
|
51
38
|
|
52
|
-
#: Type alias for all currently registered credential refresh methods.
|
53
|
-
RegistryKey = TypeVar("RegistryKey", bound=str)
|
54
39
|
|
55
|
-
|
56
|
-
|
40
|
+
class Registry(Generic[RegistryKey]):
|
41
|
+
"""Gives any hierarchy a class-level registry."""
|
42
|
+
|
43
|
+
registry: ClassVar[dict[str, type]] = {}
|
57
44
|
|
58
|
-
|
59
|
-
|
45
|
+
def __init_subclass__(cls, *, registry_key: RegistryKey, **kwargs: Any):
|
46
|
+
super().__init_subclass__(**kwargs)
|
47
|
+
|
48
|
+
if registry_key in cls.registry:
|
49
|
+
BRSWarning(f"{registry_key!r} already registered. Overwriting.")
|
50
|
+
|
51
|
+
if "sentinel" not in registry_key:
|
52
|
+
cls.registry[registry_key] = cls
|
53
|
+
|
54
|
+
@classmethod
|
55
|
+
def items(cls) -> dict[str, type]:
|
56
|
+
"""Typed accessor for introspection / debugging."""
|
57
|
+
|
58
|
+
return dict(cls.registry)
|
59
|
+
|
60
|
+
|
61
|
+
# defining this here instead of utils to avoid circular imports lol
|
62
|
+
T_BRSSession = TypeVar("T_BRSSession", bound="BRSSession")
|
63
|
+
|
64
|
+
#: Type alias for a generic refreshable session type.
|
65
|
+
BRSSessionType = type[T_BRSSession]
|
60
66
|
|
61
67
|
|
62
68
|
def refreshable_session(
|
63
|
-
cls:
|
64
|
-
) ->
|
69
|
+
cls: BRSSessionType,
|
70
|
+
) -> BRSSessionType:
|
65
71
|
"""Wraps cls.__init__ so self.__post_init__ runs after init (if present).
|
66
72
|
|
73
|
+
In plain English: this is essentially a post-initialization hook.
|
74
|
+
|
67
75
|
Returns
|
68
76
|
-------
|
69
77
|
BRSSessionType
|
@@ -102,75 +110,6 @@ def refreshable_session(
|
|
102
110
|
return cls
|
103
111
|
|
104
112
|
|
105
|
-
class Registry(Generic[RegistryKey]):
|
106
|
-
"""Gives any hierarchy a class-level registry."""
|
107
|
-
|
108
|
-
registry: ClassVar[dict[str, type]] = {}
|
109
|
-
|
110
|
-
def __init_subclass__(cls, *, registry_key: RegistryKey, **kwargs: Any):
|
111
|
-
super().__init_subclass__(**kwargs)
|
112
|
-
|
113
|
-
if registry_key in cls.registry:
|
114
|
-
BRSWarning(f"{registry_key!r} already registered. Overwriting.")
|
115
|
-
|
116
|
-
if "sentinel" not in registry_key:
|
117
|
-
cls.registry[registry_key] = cls
|
118
|
-
|
119
|
-
@classmethod
|
120
|
-
def items(cls) -> dict[str, type]:
|
121
|
-
"""Typed accessor for introspection / debugging."""
|
122
|
-
|
123
|
-
return dict(cls.registry)
|
124
|
-
|
125
|
-
|
126
|
-
class TemporaryCredentials(TypedDict):
|
127
|
-
"""Temporary IAM credentials."""
|
128
|
-
|
129
|
-
access_key: str
|
130
|
-
secret_key: str
|
131
|
-
token: str
|
132
|
-
expiry_time: datetime | str
|
133
|
-
|
134
|
-
|
135
|
-
class _CustomCredentialsMethod(Protocol):
|
136
|
-
def __call__(self, **kwargs: Any) -> TemporaryCredentials: ...
|
137
|
-
|
138
|
-
|
139
|
-
#: Type alias for custom credential retrieval methods.
|
140
|
-
CustomCredentialsMethod: TypeAlias = _CustomCredentialsMethod
|
141
|
-
|
142
|
-
#: Type alias for custom credential method arguments.
|
143
|
-
CustomCredentialsMethodArgs: TypeAlias = Mapping[str, Any]
|
144
|
-
|
145
|
-
|
146
|
-
class RefreshableTemporaryCredentials(TypedDict):
|
147
|
-
"""Refreshable IAM credentials.
|
148
|
-
|
149
|
-
Parameters
|
150
|
-
----------
|
151
|
-
AWS_ACCESS_KEY_ID : str
|
152
|
-
AWS access key identifier.
|
153
|
-
AWS_SECRET_ACCESS_KEY : str
|
154
|
-
AWS secret access key.
|
155
|
-
AWS_SESSION_TOKEN : str
|
156
|
-
AWS session token.
|
157
|
-
"""
|
158
|
-
|
159
|
-
AWS_ACCESS_KEY_ID: str
|
160
|
-
AWS_SECRET_ACCESS_KEY: str
|
161
|
-
AWS_SESSION_TOKEN: str
|
162
|
-
|
163
|
-
|
164
|
-
class CredentialProvider(ABC):
|
165
|
-
"""Defines the abstract surface every refreshable session must expose."""
|
166
|
-
|
167
|
-
@abstractmethod
|
168
|
-
def _get_credentials(self) -> TemporaryCredentials: ...
|
169
|
-
|
170
|
-
@abstractmethod
|
171
|
-
def get_identity(self) -> dict[str, Any]: ...
|
172
|
-
|
173
|
-
|
174
113
|
class BRSSession(Session):
|
175
114
|
"""Wrapper for boto3.session.Session.
|
176
115
|
|
@@ -239,51 +178,27 @@ class BRSSession(Session):
|
|
239
178
|
return self.refreshable_credentials()
|
240
179
|
|
241
180
|
|
242
|
-
class
|
243
|
-
|
244
|
-
|
181
|
+
class BaseRefreshableSession(
|
182
|
+
Registry[Method],
|
183
|
+
CredentialProvider,
|
184
|
+
BRSSession,
|
185
|
+
registry_key="__sentinel__",
|
186
|
+
):
|
187
|
+
"""Abstract base class for implementing refreshable AWS sessions.
|
245
188
|
|
189
|
+
Provides a common interface and factory registration mechanism
|
190
|
+
for subclasses that generate temporary credentials using various
|
191
|
+
AWS authentication methods (e.g., STS).
|
246
192
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
class ProvidedContext(TypedDict):
|
252
|
-
ProviderArn: str
|
253
|
-
ContextAssertion: str
|
254
|
-
|
255
|
-
|
256
|
-
class AssumeRoleParams(TypedDict):
|
257
|
-
RoleArn: str
|
258
|
-
RoleSessionName: str
|
259
|
-
PolicyArns: NotRequired[List[PolicyDescriptorType]]
|
260
|
-
Policy: NotRequired[str]
|
261
|
-
DurationSeconds: NotRequired[int]
|
262
|
-
ExternalId: NotRequired[str]
|
263
|
-
SerialNumber: NotRequired[str]
|
264
|
-
TokenCode: NotRequired[str]
|
265
|
-
Tags: NotRequired[List[Tag]]
|
266
|
-
TransitiveTagKeys: NotRequired[List[str]]
|
267
|
-
SourceIdentity: NotRequired[str]
|
268
|
-
ProvidedContexts: NotRequired[List[ProvidedContext]]
|
269
|
-
|
270
|
-
|
271
|
-
class STSClientParams(TypedDict):
|
272
|
-
region_name: NotRequired[str]
|
273
|
-
api_version: NotRequired[str]
|
274
|
-
use_ssl: NotRequired[bool]
|
275
|
-
verify: NotRequired[bool | str]
|
276
|
-
endpoint_url: NotRequired[str]
|
277
|
-
aws_access_key_id: NotRequired[str]
|
278
|
-
aws_secret_access_key: NotRequired[str]
|
279
|
-
aws_session_token: NotRequired[str]
|
280
|
-
config: NotRequired[Any]
|
281
|
-
aws_account_id: NotRequired[str]
|
193
|
+
Subclasses must implement ``_get_credentials()`` and ``get_identity()``.
|
194
|
+
They should also register themselves using the ``method=...`` argument
|
195
|
+
to ``__init_subclass__``.
|
282
196
|
|
197
|
+
Parameters
|
198
|
+
----------
|
199
|
+
registry : dict[str, type[BaseRefreshableSession]]
|
200
|
+
Class-level registry mapping method names to registered session types.
|
201
|
+
"""
|
283
202
|
|
284
|
-
|
285
|
-
|
286
|
-
user_pin: NotRequired[str]
|
287
|
-
slot_id: NotRequired[int]
|
288
|
-
token_label: NotRequired[str | None]
|
289
|
-
private_key_label: NotRequired[str | None]
|
203
|
+
def __init__(self, **kwargs):
|
204
|
+
super().__init__(**kwargs)
|
@@ -0,0 +1,145 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
__all__ = [
|
4
|
+
"AssumeRoleParams",
|
5
|
+
"CustomCredentialsMethod",
|
6
|
+
"CustomCredentialsMethodArgs",
|
7
|
+
"Identity",
|
8
|
+
"IoTAuthenticationMethod",
|
9
|
+
"Method",
|
10
|
+
"PKCS11",
|
11
|
+
"RefreshMethod",
|
12
|
+
"RegistryKey",
|
13
|
+
"STSClientParams",
|
14
|
+
"TemporaryCredentials",
|
15
|
+
"RefreshableTemporaryCredentials",
|
16
|
+
]
|
17
|
+
|
18
|
+
from datetime import datetime
|
19
|
+
from typing import (
|
20
|
+
Any,
|
21
|
+
List,
|
22
|
+
Literal,
|
23
|
+
Mapping,
|
24
|
+
Protocol,
|
25
|
+
TypeAlias,
|
26
|
+
TypedDict,
|
27
|
+
TypeVar,
|
28
|
+
)
|
29
|
+
|
30
|
+
try:
|
31
|
+
from typing import NotRequired # type: ignore[import]
|
32
|
+
except ImportError:
|
33
|
+
from typing_extensions import NotRequired
|
34
|
+
|
35
|
+
#: Type alias for all currently available IoT authentication methods.
|
36
|
+
IoTAuthenticationMethod = Literal["certificate", "cognito", "__iot_sentinel__"]
|
37
|
+
|
38
|
+
#: Type alias for all currently available credential refresh methods.
|
39
|
+
Method = Literal[
|
40
|
+
"sts",
|
41
|
+
"ecs",
|
42
|
+
"custom",
|
43
|
+
"__sentinel__",
|
44
|
+
] # TODO: Add iot when implemented
|
45
|
+
|
46
|
+
#: Type alias for all refresh method names.
|
47
|
+
RefreshMethod = Literal[
|
48
|
+
"sts-assume-role",
|
49
|
+
"ecs-container-metadata",
|
50
|
+
"custom",
|
51
|
+
] # TODO: Add iot-certificate and iot-cognito when iot implemented
|
52
|
+
|
53
|
+
#: Type alias for all currently registered credential refresh methods.
|
54
|
+
RegistryKey = TypeVar("RegistryKey", bound=str)
|
55
|
+
|
56
|
+
#: Type alias for values returned by get_identity
|
57
|
+
Identity: TypeAlias = dict[str, Any]
|
58
|
+
|
59
|
+
|
60
|
+
class TemporaryCredentials(TypedDict):
|
61
|
+
"""Temporary IAM credentials."""
|
62
|
+
|
63
|
+
access_key: str
|
64
|
+
secret_key: str
|
65
|
+
token: str
|
66
|
+
expiry_time: datetime | str
|
67
|
+
|
68
|
+
|
69
|
+
class _CustomCredentialsMethod(Protocol):
|
70
|
+
def __call__(self, **kwargs: Any) -> TemporaryCredentials: ...
|
71
|
+
|
72
|
+
|
73
|
+
#: Type alias for custom credential retrieval methods.
|
74
|
+
CustomCredentialsMethod: TypeAlias = _CustomCredentialsMethod
|
75
|
+
|
76
|
+
#: Type alias for custom credential method arguments.
|
77
|
+
CustomCredentialsMethodArgs: TypeAlias = Mapping[str, Any]
|
78
|
+
|
79
|
+
|
80
|
+
class RefreshableTemporaryCredentials(TypedDict):
|
81
|
+
"""Refreshable IAM credentials.
|
82
|
+
|
83
|
+
Parameters
|
84
|
+
----------
|
85
|
+
AWS_ACCESS_KEY_ID : str
|
86
|
+
AWS access key identifier.
|
87
|
+
AWS_SECRET_ACCESS_KEY : str
|
88
|
+
AWS secret access key.
|
89
|
+
AWS_SESSION_TOKEN : str
|
90
|
+
AWS session token.
|
91
|
+
"""
|
92
|
+
|
93
|
+
AWS_ACCESS_KEY_ID: str
|
94
|
+
AWS_SECRET_ACCESS_KEY: str
|
95
|
+
AWS_SESSION_TOKEN: str
|
96
|
+
|
97
|
+
|
98
|
+
class Tag(TypedDict):
|
99
|
+
Key: str
|
100
|
+
Value: str
|
101
|
+
|
102
|
+
|
103
|
+
class PolicyDescriptorType(TypedDict):
|
104
|
+
arn: str
|
105
|
+
|
106
|
+
|
107
|
+
class ProvidedContext(TypedDict):
|
108
|
+
ProviderArn: str
|
109
|
+
ContextAssertion: str
|
110
|
+
|
111
|
+
|
112
|
+
class AssumeRoleParams(TypedDict):
|
113
|
+
RoleArn: str
|
114
|
+
RoleSessionName: str
|
115
|
+
PolicyArns: NotRequired[List[PolicyDescriptorType]]
|
116
|
+
Policy: NotRequired[str]
|
117
|
+
DurationSeconds: NotRequired[int]
|
118
|
+
ExternalId: NotRequired[str]
|
119
|
+
SerialNumber: NotRequired[str]
|
120
|
+
TokenCode: NotRequired[str]
|
121
|
+
Tags: NotRequired[List[Tag]]
|
122
|
+
TransitiveTagKeys: NotRequired[List[str]]
|
123
|
+
SourceIdentity: NotRequired[str]
|
124
|
+
ProvidedContexts: NotRequired[List[ProvidedContext]]
|
125
|
+
|
126
|
+
|
127
|
+
class STSClientParams(TypedDict):
|
128
|
+
region_name: NotRequired[str]
|
129
|
+
api_version: NotRequired[str]
|
130
|
+
use_ssl: NotRequired[bool]
|
131
|
+
verify: NotRequired[bool | str]
|
132
|
+
endpoint_url: NotRequired[str]
|
133
|
+
aws_access_key_id: NotRequired[str]
|
134
|
+
aws_secret_access_key: NotRequired[str]
|
135
|
+
aws_session_token: NotRequired[str]
|
136
|
+
config: NotRequired[Any]
|
137
|
+
aws_account_id: NotRequired[str]
|
138
|
+
|
139
|
+
|
140
|
+
class PKCS11(TypedDict):
|
141
|
+
pkcs11_loc: str
|
142
|
+
user_pin: NotRequired[str]
|
143
|
+
slot_id: NotRequired[int]
|
144
|
+
token_label: NotRequired[str | None]
|
145
|
+
private_key_label: NotRequired[str | None]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: boto3-refresh-session
|
3
|
-
Version:
|
3
|
+
Version: 3.0.0
|
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
|
@@ -117,17 +117,7 @@ Description-Content-Type: text/markdown
|
|
117
117
|
|
118
118
|
</div>
|
119
119
|
|
120
|
-
|
121
|
-
|
122
|
-
## ⚠️ Important Update
|
123
|
-
|
124
|
-
I am currently grappling with a serious medical condition that negatively impacts my vision. Accordingly, development of the `iot` and `ec2` modules has been delayed. Expect delayed responses to issues and pull requests until my health stabilizes.
|
125
|
-
|
126
|
-
Thank you for supporting this project.
|
127
|
-
|
128
|
-
---
|
129
|
-
|
130
|
-
## Features
|
120
|
+
## :stuck_out_tongue: Features
|
131
121
|
|
132
122
|
- Drop-in replacement for `boto3.session.Session`
|
133
123
|
- Supports automatic credential refresh methods for various AWS services:
|
@@ -138,7 +128,21 @@ Thank you for supporting this project.
|
|
138
128
|
- [Tested](https://github.com/michaelthomasletts/boto3-refresh-session/tree/main/tests), [documented](https://michaelthomasletts.github.io/boto3-refresh-session/index.html), and [published to PyPI](https://pypi.org/project/boto3-refresh-session/)
|
139
129
|
- Future releases will include support for IoT (coming soon), EC2, and SSO
|
140
130
|
|
141
|
-
##
|
131
|
+
## ⚠️ Important Updates
|
132
|
+
|
133
|
+
#### v3.0.0
|
134
|
+
|
135
|
+
**The changes introdcued by v3.0.0 will not impact ~99% of users** who generally interact with `boto3-refresh-session` by only `RefreshableSession`, which is the intended usage for this package after all.
|
136
|
+
|
137
|
+
Advanced users, however, particularly those using low-level objects such as `BaseRefreshableSession | refreshable_session | BRSSession | utils.py`, may experience breaking changes.
|
138
|
+
|
139
|
+
Please review [this PR](https://github.com/michaelthomasletts/boto3-refresh-session/pull/75) for additional details.
|
140
|
+
|
141
|
+
#### Delayed Responses
|
142
|
+
|
143
|
+
I am currently grappling with a very serious medical condition. Accordingly, expect delayed responses to issues and requests until my health stabilizes.
|
144
|
+
|
145
|
+
## :relieved: Recognition and Testimonials
|
142
146
|
|
143
147
|
[Featured in TL;DR Sec.](https://tldrsec.com/p/tldr-sec-282)
|
144
148
|
|
@@ -150,13 +154,13 @@ A testimonial from a Cyber Security Engineer at a FAANG company:
|
|
150
154
|
|
151
155
|
> _Most of my work is on tooling related to AWS security, so I'm pretty choosy about boto3 credentials-adjacent code. I often opt to just write this sort of thing myself so I at least know that I can reason about it. But I found boto3-refresh-session to be very clean and intuitive [...] We're using the RefreshableSession class as part of a client cache construct [...] We're using AWS Lambda to perform lots of operations across several regions in hundreds of accounts, over and over again, all day every day. And it turns out that there's a surprising amount of overhead to creating boto3 clients (mostly deserializing service definition json), so we can run MUCH more efficiently if we keep a cache of clients, all equipped with automatically refreshing sessions._
|
152
156
|
|
153
|
-
## Installation
|
157
|
+
## :computer: Installation
|
154
158
|
|
155
159
|
```bash
|
156
160
|
pip install boto3-refresh-session
|
157
161
|
```
|
158
162
|
|
159
|
-
## Usage
|
163
|
+
## :pencil: Usage
|
160
164
|
|
161
165
|
<details>
|
162
166
|
<summary><strong>STS (click to expand)</strong></summary>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
boto3_refresh_session/__init__.py,sha256=ifSHrbYVmh9SuNx1zrhU8krs9T1G7CxRY-EdQ6bJIdE,415
|
2
|
+
boto3_refresh_session/exceptions.py,sha256=DumBh6cDVU46eelSNt1CsG2uMSBekSbmhqWEaAWw130,1003
|
3
|
+
boto3_refresh_session/methods/__init__.py,sha256=zpVBJIR4P-l4pjE9kMnLGffehPVawY1vLiX2CPcpV7w,352
|
4
|
+
boto3_refresh_session/methods/custom.py,sha256=j90Iv1DKdGgP1JNwQfpEhaJDBrB2AtDe8kqI2Mktwlg,4173
|
5
|
+
boto3_refresh_session/methods/ecs.py,sha256=dxDrNOu8xTFHciuwL7jLh5nB2QXWwQRRA1CoY7AuO5g,3893
|
6
|
+
boto3_refresh_session/methods/iot/__init__.typed,sha256=Z33nIB6oCsz9TZwikHfNHgY1SKxkSCdB5rwdPSUl3C4,135
|
7
|
+
boto3_refresh_session/methods/iot/certificate.typed,sha256=sFTa1rF7tebr48Bjw_YtVeOdVvazAHBJGGiM33tsFXI,1828
|
8
|
+
boto3_refresh_session/methods/iot/cognito.typed,sha256=wyBMWUkuhLt27JsKZIwtfylDdCavNexcEy16ZaDFjUY,435
|
9
|
+
boto3_refresh_session/methods/iot/core.typed,sha256=Q5WshxgIIOgAaqoU7n8wBKMe9eSzZ6H8db-q1gThHzk,1407
|
10
|
+
boto3_refresh_session/methods/sts.py,sha256=dzf68BE0f1nFsITOKOnygh-mTvBqThKkrW2eEc-wFKA,3326
|
11
|
+
boto3_refresh_session/session.py,sha256=8YAdanwnJUG622Cv9MNKg25uj9ZmMYzRL4xiqH1i0nk,2089
|
12
|
+
boto3_refresh_session/utils/__init__.py,sha256=6F2ErbgBT2ZmZwFF3OzvQEd1Vh4XM3kaL6YGMTrcrkQ,156
|
13
|
+
boto3_refresh_session/utils/internal.py,sha256=bpKTAF_xdBw1wJPHIG8aGRMiXkSkp7CI9et0U5o3qEI,6103
|
14
|
+
boto3_refresh_session/utils/typing.py,sha256=I4VJS1vkRwIRdJF08dZF1YgUed_anviz3hq4hLvPnLw,3537
|
15
|
+
boto3_refresh_session-3.0.0.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
|
16
|
+
boto3_refresh_session-3.0.0.dist-info/METADATA,sha256=a22Flwsf_dYvR7G6-HFJDaaaXZsnRplAZV4iKGgTTN8,9244
|
17
|
+
boto3_refresh_session-3.0.0.dist-info/NOTICE,sha256=1s8r33qbl1z0YvPB942iWgvbkP94P_e8AnROr1qXXuw,939
|
18
|
+
boto3_refresh_session-3.0.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
19
|
+
boto3_refresh_session-3.0.0.dist-info/RECORD,,
|
@@ -1,17 +0,0 @@
|
|
1
|
-
boto3_refresh_session/__init__.py,sha256=cv1nXmKo_tIuI-y-JFDK7Q20VCtc0pBX-edmEUGCn_8,388
|
2
|
-
boto3_refresh_session/exceptions.py,sha256=cP5d9S8QnUEwXIU3pzMGr6jMOz447kddNJ_UIRERMrk,964
|
3
|
-
boto3_refresh_session/methods/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
boto3_refresh_session/methods/custom.py,sha256=FBVkcnT0-VPDbgcjl2iMDvl16miRGXFr-fSNs2g4vkI,4211
|
5
|
-
boto3_refresh_session/methods/ecs.py,sha256=HN3dJUGeso0q6YC0S8m40jCfkf3l1lSfxKIP7kKADhM,3929
|
6
|
-
boto3_refresh_session/methods/iot/__init__.typed,sha256=Z33nIB6oCsz9TZwikHfNHgY1SKxkSCdB5rwdPSUl3C4,135
|
7
|
-
boto3_refresh_session/methods/iot/certificate.typed,sha256=dRVP_Rsob9nQmap9GeKZL3I0kM-pc2hzxnep7kBFhqY,1820
|
8
|
-
boto3_refresh_session/methods/iot/cognito.typed,sha256=wyBMWUkuhLt27JsKZIwtfylDdCavNexcEy16ZaDFjUY,435
|
9
|
-
boto3_refresh_session/methods/iot/core.typed,sha256=tL-ngB2XYq0XtxhS9mbggCJYdX3eEE0u1Gvcq8sEYGE,1422
|
10
|
-
boto3_refresh_session/methods/sts.py,sha256=Iv4FlLvn7dc45uAxJp-DkLxg3ZqnngK4XvjbItq44Uo,3403
|
11
|
-
boto3_refresh_session/session.py,sha256=_Z3uB5Xq3S-dFqOFmWhMQbcd__NPGThjULLPStHI6E4,2914
|
12
|
-
boto3_refresh_session/utils.py,sha256=fhtWLTHmERPx_3F-dDGrLxG37m2AdLRrhHq8R6ImCfc,8064
|
13
|
-
boto3_refresh_session-2.0.10.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
|
14
|
-
boto3_refresh_session-2.0.10.dist-info/METADATA,sha256=RXVVp0ZjG2jZE9I7bAZ-IKBJjNPthtl5rzYZTQanQko,8796
|
15
|
-
boto3_refresh_session-2.0.10.dist-info/NOTICE,sha256=1s8r33qbl1z0YvPB942iWgvbkP94P_e8AnROr1qXXuw,939
|
16
|
-
boto3_refresh_session-2.0.10.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
17
|
-
boto3_refresh_session-2.0.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|