boto3-refresh-session 1.3.16__py3-none-any.whl → 1.3.18__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.16"
7
+ __version__ = "1.3.18"
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"}
@@ -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,6 +19,15 @@ 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
32
  """Abstract base class for implementing refreshable AWS sessions.
23
33
 
@@ -54,7 +64,7 @@ class BaseRefreshableSession(ABC, Session):
54
64
  super().__init__(**kwargs)
55
65
 
56
66
  @abstractmethod
57
- def _get_credentials(self) -> dict[str, str]: ...
67
+ def _get_credentials(self) -> TemporaryCredentials: ...
58
68
 
59
69
  @abstractmethod
60
70
  def get_identity(self) -> dict[str, Any]: ...
@@ -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.16
3
+ Version: 1.3.18
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">
@@ -118,6 +118,8 @@ pip install boto3-refresh-session
118
118
 
119
119
  ## Usage (STS)
120
120
 
121
+ Most users use AWS STS to assume an IAM role and return a set of temporary security credentials. boto3-refresh-session can be used to ensure those temporary credentials refresh automatically.
122
+
121
123
  ```python
122
124
  import boto3_refresh_session as brs
123
125
 
@@ -152,6 +154,8 @@ session = brs.RefreshableSession(
152
154
 
153
155
  ## Usage (ECS)
154
156
 
157
+ You can use boto3-refresh-session in an ECS container to automatically refresh temporary security credentials.
158
+
155
159
  ```python
156
160
  session = RefreshableSession(
157
161
  method="ecs",
@@ -0,0 +1,11 @@
1
+ boto3_refresh_session/__init__.py,sha256=W9zruekrLBvjzIyUaIC3ybJRmsQTdfXr7kS5IAwwPNU,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.18.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
8
+ boto3_refresh_session-1.3.18.dist-info/METADATA,sha256=__Rg3ZoT_HS7GDNaJnZPqKvVAPFjSrOKy2Ehw0lqMOc,8109
9
+ boto3_refresh_session-1.3.18.dist-info/NOTICE,sha256=1s8r33qbl1z0YvPB942iWgvbkP94P_e8AnROr1qXXuw,939
10
+ boto3_refresh_session-1.3.18.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
+ boto3_refresh_session-1.3.18.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- boto3_refresh_session/__init__.py,sha256=zb1pSAs5tu6DDGFJibXDoMxTB0wxFynt2USx0PWKziw,364
2
- boto3_refresh_session/custom.py,sha256=xW_OiAO1D6-uPj-JWMjXmgNy1BpQxvF7nWavrGZtrqA,3795
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=wtaLKf2DOnUpt9wJLP_9j2zJEhhFRcUMBNvKBzWY7-Q,5351
6
- boto3_refresh_session/sts.py,sha256=gJKbslmNl8kR8oAeZfOGmrHtgUUxMm7e9hPgZO678FE,3174
7
- boto3_refresh_session-1.3.16.dist-info/LICENSE,sha256=I3ZYTXAjbIly6bm6J-TvFTuuHwTKws4h89QaY5c5HiY,1067
8
- boto3_refresh_session-1.3.16.dist-info/METADATA,sha256=yoKsAPM28pzClq58vh67pLCVhx_D_ewUHwcj9I9w9WE,7804
9
- boto3_refresh_session-1.3.16.dist-info/NOTICE,sha256=1s8r33qbl1z0YvPB942iWgvbkP94P_e8AnROr1qXXuw,939
10
- boto3_refresh_session-1.3.16.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
11
- boto3_refresh_session-1.3.16.dist-info/RECORD,,