sanic-security 1.16.8__py3-none-any.whl → 1.16.9__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.
- sanic_security/configuration.py +10 -16
- {sanic_security-1.16.8.dist-info → sanic_security-1.16.9.dist-info}/METADATA +3 -2
- {sanic_security-1.16.8.dist-info → sanic_security-1.16.9.dist-info}/RECORD +6 -6
- {sanic_security-1.16.8.dist-info → sanic_security-1.16.9.dist-info}/WHEEL +1 -1
- {sanic_security-1.16.8.dist-info → sanic_security-1.16.9.dist-info/licenses}/LICENSE +0 -0
- {sanic_security-1.16.8.dist-info → sanic_security-1.16.9.dist-info}/top_level.txt +0 -0
sanic_security/configuration.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
from os import environ
|
2
|
+
from types import SimpleNamespace
|
2
3
|
|
3
4
|
from sanic.utils import str_to_bool
|
4
5
|
|
@@ -50,7 +51,7 @@ DEFAULT_CONFIG = {
|
|
50
51
|
}
|
51
52
|
|
52
53
|
|
53
|
-
class Config(
|
54
|
+
class Config(SimpleNamespace):
|
54
55
|
"""
|
55
56
|
Sanic Security configuration.
|
56
57
|
|
@@ -102,30 +103,23 @@ class Config(dict):
|
|
102
103
|
INITIAL_ADMIN_PASSWORD: str
|
103
104
|
TEST_DATABASE_URL: str
|
104
105
|
|
105
|
-
def
|
106
|
-
|
107
|
-
|
106
|
+
def __init__(self, default_config: dict = None):
|
107
|
+
super().__init__(**(default_config or DEFAULT_CONFIG))
|
108
|
+
self.load_environment_variables()
|
108
109
|
|
109
|
-
|
110
|
-
load_env (str): Prefix being used to apply environment variables into the config.
|
111
|
-
"""
|
110
|
+
def load_environment_variables(self, env_prefix: str = "SANIC_SECURITY_"):
|
112
111
|
for key, value in environ.items():
|
113
|
-
if not key.startswith(
|
112
|
+
if not key.startswith(env_prefix):
|
114
113
|
continue
|
115
114
|
|
116
|
-
_, config_key = key.split(
|
115
|
+
_, config_key = key.split(env_prefix, 1)
|
117
116
|
|
118
117
|
for converter in (int, float, str_to_bool, str):
|
119
118
|
try:
|
120
|
-
self
|
119
|
+
setattr(self, config_key, converter(value))
|
121
120
|
break
|
122
121
|
except ValueError:
|
123
122
|
pass
|
124
123
|
|
125
|
-
def __init__(self):
|
126
|
-
super().__init__(DEFAULT_CONFIG)
|
127
|
-
self.__dict__ = self
|
128
|
-
self.load_environment_variables()
|
129
|
-
|
130
124
|
|
131
|
-
config = Config()
|
125
|
+
config = Config(DEFAULT_CONFIG)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: sanic-security
|
3
|
-
Version: 1.16.
|
3
|
+
Version: 1.16.9
|
4
4
|
Summary: An async security library for the Sanic framework.
|
5
5
|
Author-email: Aidan Stewart <me@na-stewart.com>
|
6
6
|
Project-URL: Documentation, https://security.na-stewart.com/
|
@@ -29,6 +29,7 @@ Requires-Dist: pdoc3; extra == "dev"
|
|
29
29
|
Requires-Dist: cryptography; extra == "dev"
|
30
30
|
Provides-Extra: crypto
|
31
31
|
Requires-Dist: cryptography>=3.3.1; extra == "crypto"
|
32
|
+
Dynamic: license-file
|
32
33
|
|
33
34
|
[](https://github.com/psf/black)
|
34
35
|
[](https://pepy.tech/project/sanic-security)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
sanic_security/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
sanic_security/authentication.py,sha256=APs_YkwQCAEKyQo76ukKazQLGcm9fYrve6CUNxK2yKU,13201
|
3
3
|
sanic_security/authorization.py,sha256=Hj1TXWppq7KDH-BQXFNihpZTbaimxnVCbif_Zb5W1bA,8232
|
4
|
-
sanic_security/configuration.py,sha256=
|
4
|
+
sanic_security/configuration.py,sha256=HxlKWe1vrQsxNtpoOx86RuHtkZz7Mjo88hMCMhTDvfo,6162
|
5
5
|
sanic_security/exceptions.py,sha256=b_E6wbbtk9ziFfH3jZstp2E01hTm6V1yjTltANYAuMY,5582
|
6
6
|
sanic_security/models.py,sha256=B6ZLvLqdn7ZWn1VjOylQN4ecGRfdGbtBrScVJmzIg_o,22097
|
7
7
|
sanic_security/oauth.py,sha256=X1fx5KwvtWOa9ABGj7-MZ82ztlVeEuDz55yOh1Vtkes,8405
|
@@ -10,8 +10,8 @@ sanic_security/verification.py,sha256=vr_64HLC7TfOwhki7B4Xn3XQJ0V6OoVgh8fR4DISZ4
|
|
10
10
|
sanic_security/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
sanic_security/test/server.py,sha256=bVltV-AB_CEz9xrnVIft88FU6IYPgOOWuoSHDijeTDs,13717
|
12
12
|
sanic_security/test/tests.py,sha256=YXyn9aJmYg7vCjUuAs8FcI_lGIgzhmMe4AYTzu47_18,22618
|
13
|
-
sanic_security-1.16.
|
14
|
-
sanic_security-1.16.
|
15
|
-
sanic_security-1.16.
|
16
|
-
sanic_security-1.16.
|
17
|
-
sanic_security-1.16.
|
13
|
+
sanic_security-1.16.9.dist-info/licenses/LICENSE,sha256=sXlJs9_mG-dCkPfWsDnuzydJWagS82E2gYtkVH9enHA,1100
|
14
|
+
sanic_security-1.16.9.dist-info/METADATA,sha256=EHHASA7pgC7XgXsj59bzMiqKWJbspLY3Rm1E-d-Bf2g,25645
|
15
|
+
sanic_security-1.16.9.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
16
|
+
sanic_security-1.16.9.dist-info/top_level.txt,sha256=ZybkhHXSjfzhmv8XeqLvnNmLmv21Z0oPX6Ep4DJN8b0,15
|
17
|
+
sanic_security-1.16.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|