sanic-security 1.12.1__py3-none-any.whl → 1.12.2__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/authentication.py +3 -3
- sanic_security/configuration.py +2 -2
- sanic_security/models.py +2 -1
- sanic_security/test/tests.py +2 -1
- {sanic_security-1.12.1.dist-info → sanic_security-1.12.2.dist-info}/METADATA +6 -6
- sanic_security-1.12.2.dist-info/RECORD +16 -0
- {sanic_security-1.12.1.dist-info → sanic_security-1.12.2.dist-info}/WHEEL +1 -1
- sanic_security-1.12.1.dist-info/RECORD +0 -16
- {sanic_security-1.12.1.dist-info → sanic_security-1.12.2.dist-info}/LICENSE +0 -0
- {sanic_security-1.12.1.dist-info → sanic_security-1.12.2.dist-info}/top_level.txt +0 -0
sanic_security/authentication.py
CHANGED
@@ -198,7 +198,7 @@ async def fulfill_second_factor(request: Request) -> AuthenticationSession:
|
|
198
198
|
async def authenticate(request: Request) -> AuthenticationSession:
|
199
199
|
"""
|
200
200
|
Validates client's authentication session and account. New/Refreshed session automatically returned
|
201
|
-
if expired during authentication, requires encoding.
|
201
|
+
if client's session expired during authentication, requires encoding.
|
202
202
|
|
203
203
|
Args:
|
204
204
|
request (Request): Sanic request parameter.
|
@@ -228,8 +228,8 @@ async def authenticate(request: Request) -> AuthenticationSession:
|
|
228
228
|
|
229
229
|
def requires_authentication(arg=None):
|
230
230
|
"""
|
231
|
-
Validates client's authentication session and account. New/Refreshed session automatically returned
|
232
|
-
during authentication, requires encoding.
|
231
|
+
Validates client's authentication session and account. New/Refreshed session automatically returned
|
232
|
+
if client's session expired during authentication, requires encoding.
|
233
233
|
|
234
234
|
Example:
|
235
235
|
This method is not called directly and instead used as a decorator:
|
sanic_security/configuration.py
CHANGED
@@ -39,7 +39,7 @@ DEFAULT_CONFIG = {
|
|
39
39
|
"CAPTCHA_FONT": "captcha-font.ttf",
|
40
40
|
"TWO_STEP_SESSION_EXPIRATION": 300,
|
41
41
|
"AUTHENTICATION_SESSION_EXPIRATION": 86400,
|
42
|
-
"AUTHENTICATION_REFRESH_EXPIRATION":
|
42
|
+
"AUTHENTICATION_REFRESH_EXPIRATION": 604800,
|
43
43
|
"ALLOW_LOGIN_WITH_USERNAME": False,
|
44
44
|
"INITIAL_ADMIN_EMAIL": "admin@example.com",
|
45
45
|
"INITIAL_ADMIN_PASSWORD": "admin123",
|
@@ -65,7 +65,7 @@ class Config(dict):
|
|
65
65
|
CAPTCHA_FONT (str): The file path to the font being used for captcha generation.
|
66
66
|
TWO_STEP_SESSION_EXPIRATION (int): The amount of seconds till two-step session expiration on creation. Setting to 0 will disable expiration.
|
67
67
|
AUTHENTICATION_SESSION_EXPIRATION (int): The amount of seconds till authentication session expiration on creation. Setting to 0 will disable expiration.
|
68
|
-
AUTHENTICATION_REFRESH_EXPIRATION (int): The amount of seconds till authentication session refresh expiration.
|
68
|
+
AUTHENTICATION_REFRESH_EXPIRATION (int): The amount of seconds till authentication session refresh expiration. Setting to 0 will disable refresh mechanism.
|
69
69
|
ALLOW_LOGIN_WITH_USERNAME (bool): Allows login via username and email.
|
70
70
|
INITIAL_ADMIN_EMAIL (str): Email used when creating the initial admin account.
|
71
71
|
INITIAL_ADMIN_PASSWORD (str): Password used when creating the initial admin account.
|
sanic_security/models.py
CHANGED
@@ -566,7 +566,8 @@ class AuthenticationSession(Session):
|
|
566
566
|
raise NotExpiredError()
|
567
567
|
except ExpiredError as e:
|
568
568
|
if (
|
569
|
-
|
569
|
+
self.refresh_expiration_date
|
570
|
+
and datetime.datetime.now(datetime.timezone.utc)
|
570
571
|
<= self.refresh_expiration_date
|
571
572
|
):
|
572
573
|
self.active = False
|
sanic_security/test/tests.py
CHANGED
@@ -570,8 +570,9 @@ class MiscTest(TestCase):
|
|
570
570
|
"http://127.0.0.1:8000/api/test/auth",
|
571
571
|
)
|
572
572
|
assert (
|
573
|
-
|
573
|
+
authenticate_refresh_response.status_code == 200
|
574
574
|
), authenticate_refresh_response.text
|
575
|
+
assert json.loads(authenticate_refresh_response.text)["data"]["refresh"] is True
|
575
576
|
authenticate_response = self.client.post(
|
576
577
|
"http://127.0.0.1:8000/api/test/auth",
|
577
578
|
) # Since session refresh handling is complete, it will be returned as a regular session now.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sanic-security
|
3
|
-
Version: 1.12.
|
3
|
+
Version: 1.12.2
|
4
4
|
Summary: An async security library for the Sanic framework.
|
5
5
|
Author-email: Aidan Stewart <na.stewart365@gmail.com>
|
6
6
|
Project-URL: Documentation, https://security.na-stewart.com/
|
@@ -156,7 +156,7 @@ You can load environment variables with a different prefix via `config.load_envi
|
|
156
156
|
| **CAPTCHA_FONT** | captcha-font.ttf | The file path to the font being used for captcha generation. |
|
157
157
|
| **TWO_STEP_SESSION_EXPIRATION** | 200 | The amount of seconds till two-step session expiration on creation. Setting to 0 will disable expiration. |
|
158
158
|
| **AUTHENTICATION_SESSION_EXPIRATION** | 86400 | The amount of seconds till authentication session expiration on creation. Setting to 0 will disable expiration. |
|
159
|
-
| **AUTHENTICATION_REFRESH_EXPIRATION** |
|
159
|
+
| **AUTHENTICATION_REFRESH_EXPIRATION** | 604800 | The amount of seconds till authentication refresh expiration. Setting to 0 will disable refresh mechanism. |
|
160
160
|
| **ALLOW_LOGIN_WITH_USERNAME** | False | Allows login via username and email. |
|
161
161
|
| **INITIAL_ADMIN_EMAIL** | admin@example.com | Email used when creating the initial admin account. |
|
162
162
|
| **INITIAL_ADMIN_PASSWORD** | admin123 | Password used when creating the initial admin account. |
|
@@ -295,7 +295,7 @@ async def on_logout(request):
|
|
295
295
|
|
296
296
|
* Authenticate
|
297
297
|
|
298
|
-
New/Refreshed session
|
298
|
+
New/Refreshed session returned if client's session expired during authentication, requires encoding.
|
299
299
|
|
300
300
|
```python
|
301
301
|
@app.post("api/security/auth")
|
@@ -312,7 +312,7 @@ async def on_authenticate(request):
|
|
312
312
|
|
313
313
|
* Requires Authentication (This method is not called directly and instead used as a decorator)
|
314
314
|
|
315
|
-
New/Refreshed session
|
315
|
+
New/Refreshed session returned if client's session expired during authentication, requires encoding.
|
316
316
|
|
317
317
|
```python
|
318
318
|
@app.post("api/security/auth")
|
@@ -328,9 +328,9 @@ async def on_authenticate(request):
|
|
328
328
|
return response
|
329
329
|
```
|
330
330
|
|
331
|
-
* Authentication
|
331
|
+
* Authentication Middleware
|
332
332
|
|
333
|
-
|
333
|
+
Refreshed session can be encoded automatically via middleware.
|
334
334
|
|
335
335
|
```python
|
336
336
|
@app.on_response
|
@@ -0,0 +1,16 @@
|
|
1
|
+
sanic_security/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
sanic_security/authentication.py,sha256=j-nFOLuNBcacKH34J04JIbsKSZ2JMH33ZqnS6vipwfQ,12508
|
3
|
+
sanic_security/authorization.py,sha256=aQztMiZG9LDctr_C6QEzO5qScwbxpiLk96XVxwdCChM,6921
|
4
|
+
sanic_security/configuration.py,sha256=p44nTSrBQQSJZYN6qJEod_Ettf90rRNlmPxmNzxqQ9A,5514
|
5
|
+
sanic_security/exceptions.py,sha256=8c3xoQSiIKfSiOQOtw49RG8Qdlc3vZDzqjrEnPad4Ds,5411
|
6
|
+
sanic_security/models.py,sha256=aB1fFCutUHDAg8jG3_VdZijOblXnSYh99gyA5fOm1u4,20528
|
7
|
+
sanic_security/utils.py,sha256=Zgde7W69ixwv_H8eTs7indO5_U2Jvq62YUpG6ipN768,2629
|
8
|
+
sanic_security/verification.py,sha256=vrxYborEOBKEirOHczul9WYub5j6T2ldXE1gsoA8iyY,7503
|
9
|
+
sanic_security/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
+
sanic_security/test/server.py,sha256=qQtbQh8m9QYf4g1SL8QJbOyyJzAXFaNmDyBxU8b6RBc,12627
|
11
|
+
sanic_security/test/tests.py,sha256=Hg40wlZfC-CDZX6lIjeT6uXy-3BJMc4ChJsnCRCBIu8,22459
|
12
|
+
sanic_security-1.12.2.dist-info/LICENSE,sha256=sXlJs9_mG-dCkPfWsDnuzydJWagS82E2gYtkVH9enHA,1100
|
13
|
+
sanic_security-1.12.2.dist-info/METADATA,sha256=YRKIzZgdU5Ka7QXR3Q0DdAj5dnNgHVh4P9vaVi03wV0,23954
|
14
|
+
sanic_security-1.12.2.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
15
|
+
sanic_security-1.12.2.dist-info/top_level.txt,sha256=ZybkhHXSjfzhmv8XeqLvnNmLmv21Z0oPX6Ep4DJN8b0,15
|
16
|
+
sanic_security-1.12.2.dist-info/RECORD,,
|
@@ -1,16 +0,0 @@
|
|
1
|
-
sanic_security/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
sanic_security/authentication.py,sha256=ucOdF-g00BmztFAqFf7gy03PIwVXU0Jp0Y8NNC5OwAw,12474
|
3
|
-
sanic_security/authorization.py,sha256=aQztMiZG9LDctr_C6QEzO5qScwbxpiLk96XVxwdCChM,6921
|
4
|
-
sanic_security/configuration.py,sha256=U-xUgceT5ZRjbxYocrzhxyJYFBkobCrlxLNMVGJNX2k,5470
|
5
|
-
sanic_security/exceptions.py,sha256=8c3xoQSiIKfSiOQOtw49RG8Qdlc3vZDzqjrEnPad4Ds,5411
|
6
|
-
sanic_security/models.py,sha256=Kia53ynvlcw7QzePC7_vzNlFlIK89QTPcIAMpqfi1yo,20478
|
7
|
-
sanic_security/utils.py,sha256=Zgde7W69ixwv_H8eTs7indO5_U2Jvq62YUpG6ipN768,2629
|
8
|
-
sanic_security/verification.py,sha256=vrxYborEOBKEirOHczul9WYub5j6T2ldXE1gsoA8iyY,7503
|
9
|
-
sanic_security/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
-
sanic_security/test/server.py,sha256=qQtbQh8m9QYf4g1SL8QJbOyyJzAXFaNmDyBxU8b6RBc,12627
|
11
|
-
sanic_security/test/tests.py,sha256=e8J_QfX4QPJT0mxkB1tWBrK_2lrPNtGR8RFXYoQ2kOo,22394
|
12
|
-
sanic_security-1.12.1.dist-info/LICENSE,sha256=sXlJs9_mG-dCkPfWsDnuzydJWagS82E2gYtkVH9enHA,1100
|
13
|
-
sanic_security-1.12.1.dist-info/METADATA,sha256=Z2-rbZpVQm_obMP3sqeAoI3Ge3WbhM9EjsPtTPMjYXM,23963
|
14
|
-
sanic_security-1.12.1.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
|
15
|
-
sanic_security-1.12.1.dist-info/top_level.txt,sha256=ZybkhHXSjfzhmv8XeqLvnNmLmv21Z0oPX6Ep4DJN8b0,15
|
16
|
-
sanic_security-1.12.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|