variamos-security 0.0.1__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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from .config.security_config import load_keys, get_private_key, get_public_key
|
|
2
|
+
from .functions.create_jwt import create_jwt
|
|
3
|
+
from .functions.is_authenticated import get_token, is_session_expired, validate_token, validate_session, is_authenticated
|
|
4
|
+
from .functions.has_roles import validate_roles, has_roles
|
|
5
|
+
from .functions.has_permissions import validate_roles_and_permissions, has_permissions
|
|
6
|
+
from .functions.mappers import session_info_to_session_user
|
|
7
|
+
from .model.response_model import ResponseModel
|
|
8
|
+
from .model.session_info import SessionInfo
|
|
9
|
+
from .model.session_user import SessionUser
|
|
10
|
+
from .exceptions.variamos_security_exception import VariamosSecurityException, variamos_security_exception_handler
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import logging
|
|
3
|
+
from jose import jwk
|
|
4
|
+
|
|
5
|
+
# Get the logger for this module
|
|
6
|
+
logger = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
# Define private variables
|
|
9
|
+
_private_key = None
|
|
10
|
+
_public_key = None
|
|
11
|
+
|
|
12
|
+
def load_keys():
|
|
13
|
+
logger.info("Loading security keys")
|
|
14
|
+
global _private_key, _public_key
|
|
15
|
+
|
|
16
|
+
private_key_pem = None
|
|
17
|
+
public_key_pem = None
|
|
18
|
+
|
|
19
|
+
private_key_path = os.getenv('VARIAMOS_PRIVATE_KEY_PATH')
|
|
20
|
+
public_key_path = os.getenv('VARIAMOS_PUBLIC_KEY_PATH')
|
|
21
|
+
|
|
22
|
+
if private_key_path and os.path.exists(private_key_path):
|
|
23
|
+
with open(private_key_path, 'r') as f:
|
|
24
|
+
private_key_pem = f.read()
|
|
25
|
+
logger.info("Private key loaded successfully")
|
|
26
|
+
|
|
27
|
+
if public_key_path and os.path.exists(public_key_path):
|
|
28
|
+
with open(public_key_path, 'r') as f:
|
|
29
|
+
public_key_pem = f.read()
|
|
30
|
+
logger.info("Public key loaded successfully")
|
|
31
|
+
|
|
32
|
+
_private_key = jwk.construct(private_key_pem, algorithm='RS256') if private_key_pem else None
|
|
33
|
+
_public_key = jwk.construct(public_key_pem, algorithm='RS256') if public_key_pem else None
|
|
34
|
+
|
|
35
|
+
if _private_key:
|
|
36
|
+
logger.info("Private key constructed successfully")
|
|
37
|
+
if _public_key:
|
|
38
|
+
logger.info("Public key constructed successfully")
|
|
39
|
+
|
|
40
|
+
def get_private_key():
|
|
41
|
+
return _private_key
|
|
42
|
+
|
|
43
|
+
def get_public_key():
|
|
44
|
+
return _public_key
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: variamos-security
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: VariaMos security commons for Python
|
|
5
|
+
Home-page: UNKNOWN
|
|
6
|
+
Author: VariaMos
|
|
7
|
+
Author-email: variamosple@gmail.com
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Requires-Dist: python-jose
|
|
15
|
+
Provides-Extra: fastapi
|
|
16
|
+
Requires-Dist: fastapi>=0.115.0; extra == "fastapi"
|
|
17
|
+
|
|
18
|
+
UNKNOWN
|
|
19
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
variamos_security/__init__.py,sha256=lBPlciMVMuIB0mvKv6592kEZQ7rallIEZ0yVehyzvq8,713
|
|
2
|
+
variamos_security/security_config.py,sha256=i6oC9OL03rttiWC9HdmcFD4VO24mEKoW5jbI27DEvLU,1355
|
|
3
|
+
variamos_security-0.0.1.dist-info/METADATA,sha256=2meNfrKDkOQVpqyajkqGHqJRJUuu-ixgtcZsHMr2SAk,515
|
|
4
|
+
variamos_security-0.0.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
5
|
+
variamos_security-0.0.1.dist-info/top_level.txt,sha256=D_apaTSDFPRCwdMcoXUFm6j3d6u8_K1Z_reELL78p5Q,18
|
|
6
|
+
variamos_security-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
variamos_security
|