boto3-refresh-session 0.1.19__py3-none-any.whl → 0.1.21__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/session.py +20 -11
- {boto3_refresh_session-0.1.19.dist-info → boto3_refresh_session-0.1.21.dist-info}/METADATA +1 -1
- boto3_refresh_session-0.1.21.dist-info/RECORD +6 -0
- boto3_refresh_session-0.1.19.dist-info/RECORD +0 -6
- {boto3_refresh_session-0.1.19.dist-info → boto3_refresh_session-0.1.21.dist-info}/LICENSE +0 -0
- {boto3_refresh_session-0.1.19.dist-info → boto3_refresh_session-0.1.21.dist-info}/WHEEL +0 -0
boto3_refresh_session/session.py
CHANGED
@@ -105,12 +105,20 @@ class AutoRefreshableSession:
|
|
105
105
|
)
|
106
106
|
session: Type[Session] = field(init=False)
|
107
107
|
_creds_already_fetched: int = field(init=False, default=0)
|
108
|
+
_sts_client: Type["botocore.client.STS"] = field(init=False)
|
108
109
|
|
109
110
|
def __attrs_post_init__(self):
|
110
|
-
|
111
|
+
# initializing session
|
112
|
+
_session = get_session()
|
113
|
+
|
114
|
+
# initializing STS client
|
115
|
+
self._sts_client = client(
|
116
|
+
service_name="sts", region_name=self.region, **self.client_kwargs
|
117
|
+
)
|
111
118
|
|
112
119
|
logger.info("Fetching temporary AWS credentials.")
|
113
120
|
|
121
|
+
# determining how to refresh expired temporary credentials
|
114
122
|
if not self.defer_refresh:
|
115
123
|
__credentials = RefreshableCredentials.create_from_metadata(
|
116
124
|
metadata=self._get_credentials(),
|
@@ -122,9 +130,12 @@ class AutoRefreshableSession:
|
|
122
130
|
refresh_using=self._get_credentials, method="sts-assume-role"
|
123
131
|
)
|
124
132
|
|
125
|
-
|
133
|
+
# mounting temporary credentials to session object
|
134
|
+
_session._credentials = __credentials
|
135
|
+
|
136
|
+
# initializing session using temporary credentials
|
126
137
|
self.session = Session(
|
127
|
-
botocore_session=
|
138
|
+
botocore_session=_session, **self.session_kwargs
|
128
139
|
)
|
129
140
|
|
130
141
|
def _get_credentials(self) -> dict:
|
@@ -144,19 +155,17 @@ class AutoRefreshableSession:
|
|
144
155
|
else:
|
145
156
|
self._creds_already_fetched += 1
|
146
157
|
|
147
|
-
|
148
|
-
|
149
|
-
)
|
150
|
-
__temporary_credentials = __sts_client.assume_role(
|
158
|
+
# fetching temporary credentials
|
159
|
+
_temporary_credentials = self._sts_client.assume_role(
|
151
160
|
RoleArn=self.role_arn,
|
152
161
|
RoleSessionName=self.session_name,
|
153
162
|
DurationSeconds=self.ttl,
|
154
163
|
)["Credentials"]
|
155
164
|
return {
|
156
|
-
"access_key":
|
157
|
-
"secret_key":
|
158
|
-
"token":
|
159
|
-
"expiry_time":
|
165
|
+
"access_key": _temporary_credentials.get("AccessKeyId"),
|
166
|
+
"secret_key": _temporary_credentials.get("SecretAccessKey"),
|
167
|
+
"token": _temporary_credentials.get("SessionToken"),
|
168
|
+
"expiry_time": _temporary_credentials.get(
|
160
169
|
"Expiration"
|
161
170
|
).isoformat(),
|
162
171
|
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
boto3_refresh_session/__init__.py,sha256=OMY8el4qROyEvo0vr1Kv8rtFU7g3xnjHuBss54XRTEA,135
|
2
|
+
boto3_refresh_session/session.py,sha256=xp5MNsNgdQ9LMryPk0JQLt6Ctp0qL9WgoVXMErTv6f0,5895
|
3
|
+
boto3_refresh_session-0.1.21.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
|
4
|
+
boto3_refresh_session-0.1.21.dist-info/METADATA,sha256=f_nI5asPGmKpPCOAvAvW3RSd14Z_PM2n9x4yQvGsFu0,4463
|
5
|
+
boto3_refresh_session-0.1.21.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
6
|
+
boto3_refresh_session-0.1.21.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
boto3_refresh_session/__init__.py,sha256=OMY8el4qROyEvo0vr1Kv8rtFU7g3xnjHuBss54XRTEA,135
|
2
|
-
boto3_refresh_session/session.py,sha256=wxh9ZXgjrXv6ouN2vpa9ow0KrQG8-O_Jc8_6w2Fa8oo,5537
|
3
|
-
boto3_refresh_session-0.1.19.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
|
4
|
-
boto3_refresh_session-0.1.19.dist-info/METADATA,sha256=kt5tDN6mR3zr_lwhCkTlOXg-zxtdX5oUJvh3vyWBz_k,4463
|
5
|
-
boto3_refresh_session-0.1.19.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
6
|
-
boto3_refresh_session-0.1.19.dist-info/RECORD,,
|
File without changes
|
File without changes
|