boto3-refresh-session 1.3.15__tar.gz → 1.3.17__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-1.3.15 → boto3_refresh_session-1.3.17}/PKG-INFO +3 -3
- {boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/README.md +2 -2
- {boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/boto3_refresh_session/__init__.py +1 -1
- {boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/boto3_refresh_session/custom.py +4 -6
- {boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/boto3_refresh_session/ecs.py +2 -2
- {boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/boto3_refresh_session/session.py +14 -9
- {boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/boto3_refresh_session/sts.py +2 -2
- {boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/pyproject.toml +2 -2
- {boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/LICENSE +0 -0
- {boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/NOTICE +0 -0
- {boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/boto3_refresh_session/exceptions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: boto3-refresh-session
|
|
3
|
-
Version: 1.3.
|
|
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-
|
|
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-
|
|
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">
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
</a>
|
|
34
34
|
|
|
35
35
|
<a href="https://pypistats.org/packages/boto3-refresh-session">
|
|
36
|
-
<img src="https://img.shields.io/badge/downloads-
|
|
36
|
+
<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"/>
|
|
37
37
|
</a>
|
|
38
38
|
|
|
39
39
|
<a href="https://pypistats.org/packages/boto3-refresh-session">
|
|
40
|
-
<img src="https://img.shields.io/badge/downloads-
|
|
40
|
+
<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"/>
|
|
41
41
|
</a>
|
|
42
42
|
|
|
43
43
|
<a href="https://michaelthomasletts.github.io/boto3-refresh-session/index.html">
|
{boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/boto3_refresh_session/custom.py
RENAMED
|
@@ -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) ->
|
|
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) ->
|
|
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()
|
{boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/boto3_refresh_session/session.py
RENAMED
|
@@ -3,7 +3,8 @@ from __future__ import annotations
|
|
|
3
3
|
__all__ = ["RefreshableSession"]
|
|
4
4
|
|
|
5
5
|
from abc import ABC, abstractmethod
|
|
6
|
-
from
|
|
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) ->
|
|
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) ->
|
|
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
|
[project]
|
|
2
2
|
name = "boto3-refresh-session"
|
|
3
|
-
version = "1.3.
|
|
3
|
+
version = "1.3.17"
|
|
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"}
|
|
@@ -41,7 +41,7 @@ flask = "^3.1.1"
|
|
|
41
41
|
[tool.black]
|
|
42
42
|
line-length = 79
|
|
43
43
|
target-version = ["py310"]
|
|
44
|
-
|
|
44
|
+
quiet = true
|
|
45
45
|
|
|
46
46
|
[tool.isort]
|
|
47
47
|
line_length = 79
|
|
File without changes
|
|
File without changes
|
{boto3_refresh_session-1.3.15 → boto3_refresh_session-1.3.17}/boto3_refresh_session/exceptions.py
RENAMED
|
File without changes
|