boto3-refresh-session 2.0.5__tar.gz → 2.0.6__tar.gz
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-2.0.5 → boto3_refresh_session-2.0.6}/PKG-INFO +1 -1
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/__init__.py +4 -1
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/methods/custom.py +3 -7
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/methods/ecs.py +4 -8
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/methods/sts.py +10 -9
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/utils.py +6 -12
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/pyproject.toml +1 -1
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/LICENSE +0 -0
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/NOTICE +0 -0
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/README.md +0 -0
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/exceptions.py +0 -0
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/methods/__init__.py +0 -0
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/methods/iot/__init__.typed +0 -0
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/methods/iot/certificate.typed +0 -0
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/methods/iot/cognito.typed +0 -0
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/methods/iot/core.typed +0 -0
- {boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/session.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: boto3-refresh-session
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.6
|
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
|
{boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/__init__.py
RENAMED
@@ -1,7 +1,10 @@
|
|
1
|
+
from .methods.custom import CustomRefreshableSession
|
2
|
+
from .methods.ecs import ECSRefreshableSession
|
3
|
+
from .methods.sts import STSRefreshableSession
|
1
4
|
from .session import RefreshableSession
|
2
5
|
|
3
6
|
__all__ = ["RefreshableSession"]
|
4
|
-
__version__ = "2.0.
|
7
|
+
__version__ = "2.0.6"
|
5
8
|
__title__ = "boto3-refresh-session"
|
6
9
|
__author__ = "Mike Letts"
|
7
10
|
__maintainer__ = "Mike Letts"
|
{boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/methods/custom.py
RENAMED
@@ -6,7 +6,7 @@ from typing import Any, Callable
|
|
6
6
|
|
7
7
|
from ..exceptions import BRSError
|
8
8
|
from ..session import BaseRefreshableSession
|
9
|
-
from ..utils import TemporaryCredentials
|
9
|
+
from ..utils import RefreshMethod, TemporaryCredentials
|
10
10
|
|
11
11
|
|
12
12
|
class CustomRefreshableSession(BaseRefreshableSession, registry_key="custom"):
|
@@ -66,6 +66,8 @@ class CustomRefreshableSession(BaseRefreshableSession, registry_key="custom"):
|
|
66
66
|
defer_refresh: bool | None = None,
|
67
67
|
**kwargs,
|
68
68
|
):
|
69
|
+
self.defer_refresh = defer_refresh is not False
|
70
|
+
self.refresh_method: RefreshMethod = "custom"
|
69
71
|
super().__init__(**kwargs)
|
70
72
|
|
71
73
|
self._custom_get_credentials = custom_credentials_method
|
@@ -75,12 +77,6 @@ class CustomRefreshableSession(BaseRefreshableSession, registry_key="custom"):
|
|
75
77
|
else {}
|
76
78
|
)
|
77
79
|
|
78
|
-
self.initialize(
|
79
|
-
credentials_method=self._get_credentials,
|
80
|
-
defer_refresh=defer_refresh is not False,
|
81
|
-
refresh_method="custom",
|
82
|
-
)
|
83
|
-
|
84
80
|
def _get_credentials(self) -> TemporaryCredentials:
|
85
81
|
credentials: TemporaryCredentials = self._custom_get_credentials(
|
86
82
|
**self._custom_get_credentials_args
|
{boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/methods/ecs.py
RENAMED
@@ -8,7 +8,7 @@ import requests
|
|
8
8
|
|
9
9
|
from ..exceptions import BRSError
|
10
10
|
from ..session import BaseRefreshableSession
|
11
|
-
from ..utils import TemporaryCredentials
|
11
|
+
from ..utils import RefreshMethod, TemporaryCredentials
|
12
12
|
|
13
13
|
_ECS_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"
|
14
14
|
_ECS_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI"
|
@@ -35,18 +35,14 @@ class ECSRefreshableSession(BaseRefreshableSession, registry_key="ecs"):
|
|
35
35
|
"""
|
36
36
|
|
37
37
|
def __init__(self, defer_refresh: bool | None = None, **kwargs):
|
38
|
-
|
38
|
+
self.defer_refresh: bool = defer_refresh is not False
|
39
|
+
self.refresh_method: RefreshMethod = "ecs-container-metadata"
|
40
|
+
super().__init__(**kwargs) # mounting refreshable credentials
|
39
41
|
|
40
42
|
self._endpoint = self._resolve_endpoint()
|
41
43
|
self._headers = self._build_headers()
|
42
44
|
self._http = self._init_http_session()
|
43
45
|
|
44
|
-
self.initialize(
|
45
|
-
credentials_method=self._get_credentials,
|
46
|
-
defer_refresh=defer_refresh is not False,
|
47
|
-
refresh_method="ecs-container-metadata",
|
48
|
-
)
|
49
|
-
|
50
46
|
def _resolve_endpoint(self) -> str:
|
51
47
|
uri = os.environ.get(_ECS_CREDENTIALS_FULL_URI) or os.environ.get(
|
52
48
|
_ECS_CREDENTIALS_RELATIVE_URI
|
{boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/methods/sts.py
RENAMED
@@ -6,7 +6,12 @@ from typing import Any
|
|
6
6
|
|
7
7
|
from ..exceptions import BRSWarning
|
8
8
|
from ..session import BaseRefreshableSession
|
9
|
-
from ..utils import
|
9
|
+
from ..utils import (
|
10
|
+
AssumeRoleParams,
|
11
|
+
RefreshMethod,
|
12
|
+
STSClientParams,
|
13
|
+
TemporaryCredentials,
|
14
|
+
)
|
10
15
|
|
11
16
|
|
12
17
|
class STSRefreshableSession(BaseRefreshableSession, registry_key="sts"):
|
@@ -42,7 +47,10 @@ class STSRefreshableSession(BaseRefreshableSession, registry_key="sts"):
|
|
42
47
|
sts_client_kwargs: STSClientParams | None = None,
|
43
48
|
**kwargs,
|
44
49
|
):
|
45
|
-
|
50
|
+
self.defer_refresh: bool = defer_refresh is not False
|
51
|
+
self.refresh_method: RefreshMethod = "sts-assume-role"
|
52
|
+
super().__init__(**kwargs) # mounting refreshable credentials
|
53
|
+
|
46
54
|
self.assume_role_kwargs = assume_role_kwargs
|
47
55
|
|
48
56
|
if sts_client_kwargs is not None:
|
@@ -59,13 +67,6 @@ class STSRefreshableSession(BaseRefreshableSession, registry_key="sts"):
|
|
59
67
|
else:
|
60
68
|
self._sts_client = self.client(service_name="sts")
|
61
69
|
|
62
|
-
# mounting refreshable credentials
|
63
|
-
self.initialize(
|
64
|
-
credentials_method=self._get_credentials,
|
65
|
-
defer_refresh=defer_refresh is not False,
|
66
|
-
refresh_method="sts-assume-role",
|
67
|
-
)
|
68
|
-
|
69
70
|
def _get_credentials(self) -> TemporaryCredentials:
|
70
71
|
temporary_credentials = self._sts_client.assume_role(
|
71
72
|
**self.assume_role_kwargs
|
@@ -115,22 +115,16 @@ class BRSSession(Session):
|
|
115
115
|
def __init__(self, **kwargs):
|
116
116
|
super().__init__(**kwargs)
|
117
117
|
|
118
|
-
def
|
119
|
-
self
|
120
|
-
credentials_method: Callable,
|
121
|
-
defer_refresh: bool,
|
122
|
-
refresh_method: RefreshMethod,
|
123
|
-
):
|
124
|
-
# determining how exactly to refresh expired temporary credentials
|
125
|
-
if not defer_refresh:
|
118
|
+
def __post_init__(self):
|
119
|
+
if not self.defer_refresh:
|
126
120
|
self._credentials = RefreshableCredentials.create_from_metadata(
|
127
|
-
metadata=
|
128
|
-
refresh_using=
|
129
|
-
method=refresh_method,
|
121
|
+
metadata=self._get_credentials(),
|
122
|
+
refresh_using=self._get_credentials,
|
123
|
+
method=self.refresh_method,
|
130
124
|
)
|
131
125
|
else:
|
132
126
|
self._credentials = DeferredRefreshableCredentials(
|
133
|
-
refresh_using=
|
127
|
+
refresh_using=self._get_credentials, method=self.refresh_method
|
134
128
|
)
|
135
129
|
|
136
130
|
def refreshable_credentials(self) -> RefreshableTemporaryCredentials:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "boto3-refresh-session"
|
3
|
-
version = "2.0.
|
3
|
+
version = "2.0.6"
|
4
4
|
description = "A simple Python package for refreshing the temporary security credentials in a boto3.session.Session object automatically."
|
5
5
|
authors = [
|
6
6
|
{name = "Mike Letts",email = "lettsmt@gmail.com"}
|
File without changes
|
File without changes
|
File without changes
|
{boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/exceptions.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{boto3_refresh_session-2.0.5 → boto3_refresh_session-2.0.6}/boto3_refresh_session/session.py
RENAMED
File without changes
|