processcube-etw-library 0.1.0__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.
- processcube_etw_library-0.1.0/PKG-INFO +15 -0
- processcube_etw_library-0.1.0/README.md +0 -0
- processcube_etw_library-0.1.0/pyproject.toml +27 -0
- processcube_etw_library-0.1.0/setup.cfg +4 -0
- processcube_etw_library-0.1.0/src/processcube/__init__.py +0 -0
- processcube_etw_library-0.1.0/src/processcube/identity_provider.py +63 -0
- processcube_etw_library-0.1.0/src/processcube_etw_library.egg-info/PKG-INFO +15 -0
- processcube_etw_library-0.1.0/src/processcube_etw_library.egg-info/SOURCES.txt +9 -0
- processcube_etw_library-0.1.0/src/processcube_etw_library.egg-info/dependency_links.txt +1 -0
- processcube_etw_library-0.1.0/src/processcube_etw_library.egg-info/requires.txt +7 -0
- processcube_etw_library-0.1.0/src/processcube_etw_library.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: processcube_etw_library
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: OAuth Identity Provider für ProcessCube
|
|
5
|
+
Author-email: Tufan Kartal <Tufan.Kartal@persona.de>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: oauth2_client
|
|
10
|
+
Requires-Dist: tenacity
|
|
11
|
+
Requires-Dist: requests
|
|
12
|
+
Requires-Dist: build>=1.3.0
|
|
13
|
+
Requires-Dist: setuptools>=80.9.0
|
|
14
|
+
Requires-Dist: wheel>=0.45.1
|
|
15
|
+
Requires-Dist: twine>=6.1.0
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=42", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "processcube_etw_library"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "OAuth Identity Provider für ProcessCube"
|
|
9
|
+
readme = { file = "README.md", content-type = "text/markdown" }
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [
|
|
12
|
+
{ name="Tufan Kartal", email="Tufan.Kartal@persona.de" }
|
|
13
|
+
]
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
dependencies = [
|
|
16
|
+
"oauth2_client",
|
|
17
|
+
"tenacity",
|
|
18
|
+
"requests",
|
|
19
|
+
"build>=1.3.0",
|
|
20
|
+
"setuptools>=80.9.0",
|
|
21
|
+
"wheel>=0.45.1",
|
|
22
|
+
"twine>=6.1.0",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[tool.setuptools]
|
|
26
|
+
packages = ["processcube"]
|
|
27
|
+
package-dir = {"" = "src"}
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from oauth2_client.credentials_manager import CredentialManager, ServiceInformation
|
|
6
|
+
from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type, after_log
|
|
7
|
+
from requests import exceptions
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger('processcube.oauth')
|
|
10
|
+
|
|
11
|
+
def exit_after_retries(retry_state):
|
|
12
|
+
logger.error(
|
|
13
|
+
f'Failed all {retry_state.attempt_number} retries. Now exitin.')
|
|
14
|
+
sys.exit(1)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class IdentityProvider:
|
|
18
|
+
|
|
19
|
+
def __init__(self,
|
|
20
|
+
authority_url: str,
|
|
21
|
+
client_name: str,
|
|
22
|
+
client_secret: str,
|
|
23
|
+
client_scopes: str,
|
|
24
|
+
max_get_oauth_access_token_retries: int,
|
|
25
|
+
):
|
|
26
|
+
self._authority_url = authority_url
|
|
27
|
+
self._client_name = client_name
|
|
28
|
+
self._client_secret = client_secret
|
|
29
|
+
self._client_scopes = client_scopes
|
|
30
|
+
self._max_get_oauth_access_token_retries = max_get_oauth_access_token_retries
|
|
31
|
+
|
|
32
|
+
self._access_token_caller = self._prepare_get_access_token_caller()
|
|
33
|
+
logger.debug(f"Prepare identity provider with (authority_url={authority_url}, client_name={client_name}, client_secret=***, client_scopes={client_scopes}).")
|
|
34
|
+
|
|
35
|
+
def __call__(self):
|
|
36
|
+
return self._access_token_caller()
|
|
37
|
+
|
|
38
|
+
def _prepare_get_access_token_caller(self):
|
|
39
|
+
|
|
40
|
+
@retry(
|
|
41
|
+
stop=stop_after_attempt(self._max_get_oauth_access_token_retries),
|
|
42
|
+
wait=wait_exponential(multiplier=1, min=2, max=30),
|
|
43
|
+
retry=retry_if_exception_type(exceptions.ConnectionError),
|
|
44
|
+
after=after_log(logger, logging.ERROR),
|
|
45
|
+
retry_error_callback=exit_after_retries,
|
|
46
|
+
)
|
|
47
|
+
def get_access_token(authority_url, client_name, client_secret, client_scopes):
|
|
48
|
+
logger.debug(f"Get access token from ProcessCube (authority_url={authority_url}, client_name={client_name}, client_secret=***, client_scopes={client_scopes}).")
|
|
49
|
+
|
|
50
|
+
client_scopes = client_scopes.split(' ')
|
|
51
|
+
|
|
52
|
+
service_information = ServiceInformation(f'{authority_url}/auth',
|
|
53
|
+
f'{authority_url}/token',
|
|
54
|
+
client_name,
|
|
55
|
+
client_secret,
|
|
56
|
+
client_scopes)
|
|
57
|
+
manager = CredentialManager(service_information)
|
|
58
|
+
|
|
59
|
+
manager.init_with_client_credentials()
|
|
60
|
+
|
|
61
|
+
return {'token': manager._access_token}
|
|
62
|
+
|
|
63
|
+
return lambda: get_access_token(self._authority_url, self._client_name, self._client_secret, self._client_scopes)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: processcube_etw_library
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: OAuth Identity Provider für ProcessCube
|
|
5
|
+
Author-email: Tufan Kartal <Tufan.Kartal@persona.de>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: oauth2_client
|
|
10
|
+
Requires-Dist: tenacity
|
|
11
|
+
Requires-Dist: requests
|
|
12
|
+
Requires-Dist: build>=1.3.0
|
|
13
|
+
Requires-Dist: setuptools>=80.9.0
|
|
14
|
+
Requires-Dist: wheel>=0.45.1
|
|
15
|
+
Requires-Dist: twine>=6.1.0
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/processcube/__init__.py
|
|
4
|
+
src/processcube/identity_provider.py
|
|
5
|
+
src/processcube_etw_library.egg-info/PKG-INFO
|
|
6
|
+
src/processcube_etw_library.egg-info/SOURCES.txt
|
|
7
|
+
src/processcube_etw_library.egg-info/dependency_links.txt
|
|
8
|
+
src/processcube_etw_library.egg-info/requires.txt
|
|
9
|
+
src/processcube_etw_library.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
processcube
|