sanic-security 1.12.2__tar.gz → 1.12.3__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.
- {sanic_security-1.12.2/sanic_security.egg-info → sanic_security-1.12.3}/PKG-INFO +5 -13
- {sanic_security-1.12.2 → sanic_security-1.12.3}/README.md +4 -12
- {sanic_security-1.12.2 → sanic_security-1.12.3}/pyproject.toml +1 -1
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security/authentication.py +1 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security/models.py +7 -2
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security/test/server.py +1 -3
- {sanic_security-1.12.2 → sanic_security-1.12.3/sanic_security.egg-info}/PKG-INFO +5 -13
- {sanic_security-1.12.2 → sanic_security-1.12.3}/LICENSE +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security/__init__.py +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security/authorization.py +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security/configuration.py +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security/exceptions.py +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security/test/__init__.py +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security/test/tests.py +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security/utils.py +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security/verification.py +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security.egg-info/SOURCES.txt +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security.egg-info/dependency_links.txt +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security.egg-info/requires.txt +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security.egg-info/top_level.txt +0 -0
- {sanic_security-1.12.2 → sanic_security-1.12.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sanic-security
|
3
|
-
Version: 1.12.
|
3
|
+
Version: 1.12.3
|
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/
|
@@ -295,8 +295,6 @@ async def on_logout(request):
|
|
295
295
|
|
296
296
|
* Authenticate
|
297
297
|
|
298
|
-
New/Refreshed session returned if client's session expired during authentication, requires encoding.
|
299
|
-
|
300
298
|
```python
|
301
299
|
@app.post("api/security/auth")
|
302
300
|
async def on_authenticate(request):
|
@@ -305,15 +303,11 @@ async def on_authenticate(request):
|
|
305
303
|
"You have been authenticated.",
|
306
304
|
authentication_session.json,
|
307
305
|
)
|
308
|
-
if authentication_session.is_refresh:
|
309
|
-
authentication_session.encode(response)
|
310
306
|
return response
|
311
307
|
```
|
312
308
|
|
313
309
|
* Requires Authentication (This method is not called directly and instead used as a decorator)
|
314
310
|
|
315
|
-
New/Refreshed session returned if client's session expired during authentication, requires encoding.
|
316
|
-
|
317
311
|
```python
|
318
312
|
@app.post("api/security/auth")
|
319
313
|
@requires_authentication
|
@@ -323,24 +317,22 @@ async def on_authenticate(request):
|
|
323
317
|
"You have been authenticated.",
|
324
318
|
authentication_session.json,
|
325
319
|
)
|
326
|
-
if authentication_session.is_refresh:
|
327
|
-
authentication_session.encode(response)
|
328
320
|
return response
|
329
321
|
```
|
330
322
|
|
331
323
|
* Authentication Middleware
|
332
324
|
|
333
|
-
Refreshed session
|
325
|
+
New/Refreshed session returned if client's session expired during authentication, requires encoding.
|
326
|
+
|
327
|
+
Middleware is recommended to automatically encode the refreshed session.
|
334
328
|
|
335
329
|
```python
|
336
330
|
@app.on_response
|
337
331
|
async def authentication_refresh_encoder(request, response):
|
338
|
-
|
332
|
+
if hasattr(request.ctx, "authentication_session"):
|
339
333
|
authentication_session = request.ctx.authentication_session
|
340
334
|
if authentication_session.is_refresh:
|
341
335
|
authentication_session.encode(response)
|
342
|
-
except AttributeError:
|
343
|
-
pass
|
344
336
|
```
|
345
337
|
|
346
338
|
## Captcha
|
@@ -264,8 +264,6 @@ async def on_logout(request):
|
|
264
264
|
|
265
265
|
* Authenticate
|
266
266
|
|
267
|
-
New/Refreshed session returned if client's session expired during authentication, requires encoding.
|
268
|
-
|
269
267
|
```python
|
270
268
|
@app.post("api/security/auth")
|
271
269
|
async def on_authenticate(request):
|
@@ -274,15 +272,11 @@ async def on_authenticate(request):
|
|
274
272
|
"You have been authenticated.",
|
275
273
|
authentication_session.json,
|
276
274
|
)
|
277
|
-
if authentication_session.is_refresh:
|
278
|
-
authentication_session.encode(response)
|
279
275
|
return response
|
280
276
|
```
|
281
277
|
|
282
278
|
* Requires Authentication (This method is not called directly and instead used as a decorator)
|
283
279
|
|
284
|
-
New/Refreshed session returned if client's session expired during authentication, requires encoding.
|
285
|
-
|
286
280
|
```python
|
287
281
|
@app.post("api/security/auth")
|
288
282
|
@requires_authentication
|
@@ -292,24 +286,22 @@ async def on_authenticate(request):
|
|
292
286
|
"You have been authenticated.",
|
293
287
|
authentication_session.json,
|
294
288
|
)
|
295
|
-
if authentication_session.is_refresh:
|
296
|
-
authentication_session.encode(response)
|
297
289
|
return response
|
298
290
|
```
|
299
291
|
|
300
292
|
* Authentication Middleware
|
301
293
|
|
302
|
-
Refreshed session
|
294
|
+
New/Refreshed session returned if client's session expired during authentication, requires encoding.
|
295
|
+
|
296
|
+
Middleware is recommended to automatically encode the refreshed session.
|
303
297
|
|
304
298
|
```python
|
305
299
|
@app.on_response
|
306
300
|
async def authentication_refresh_encoder(request, response):
|
307
|
-
|
301
|
+
if hasattr(request.ctx, "authentication_session"):
|
308
302
|
authentication_session = request.ctx.authentication_session
|
309
303
|
if authentication_session.is_refresh:
|
310
304
|
authentication_session.encode(response)
|
311
|
-
except AttributeError:
|
312
|
-
pass
|
313
305
|
```
|
314
306
|
|
315
307
|
## Captcha
|
@@ -223,6 +223,7 @@ async def authenticate(request: Request) -> AuthenticationSession:
|
|
223
223
|
authentication_session.bearer.validate()
|
224
224
|
except ExpiredError:
|
225
225
|
authentication_session = await authentication_session.refresh(request)
|
226
|
+
request.ctx.authentication_session = authentication_session
|
226
227
|
return authentication_session
|
227
228
|
|
228
229
|
|
@@ -296,8 +296,13 @@ class Session(BaseModel):
|
|
296
296
|
samesite=security_config.SESSION_SAMESITE,
|
297
297
|
secure=security_config.SESSION_SECURE,
|
298
298
|
)
|
299
|
-
if self.expiration_date:
|
300
|
-
|
299
|
+
if self.expiration_date: # Overrides refresh expiration.
|
300
|
+
if hasattr(self, "refresh_expiration_date"):
|
301
|
+
response.cookies.get_cookie(cookie).expires = (
|
302
|
+
self.refresh_expiration_date
|
303
|
+
)
|
304
|
+
else:
|
305
|
+
response.cookies.get_cookie(cookie).expires = self.expiration_date
|
301
306
|
if security_config.SESSION_DOMAIN:
|
302
307
|
response.cookies.get_cookie(cookie).domain = security_config.SESSION_DOMAIN
|
303
308
|
|
@@ -175,12 +175,10 @@ async def on_authenticate(request):
|
|
175
175
|
|
176
176
|
@app.on_response
|
177
177
|
async def authentication_refresh_encoder(request, response):
|
178
|
-
|
178
|
+
if hasattr(request.ctx, "authentication_session"):
|
179
179
|
authentication_session = request.ctx.authentication_session
|
180
180
|
if authentication_session.is_refresh:
|
181
181
|
authentication_session.encode(response)
|
182
|
-
except AttributeError:
|
183
|
-
pass
|
184
182
|
|
185
183
|
|
186
184
|
@app.post("api/test/auth/expire")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sanic-security
|
3
|
-
Version: 1.12.
|
3
|
+
Version: 1.12.3
|
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/
|
@@ -295,8 +295,6 @@ async def on_logout(request):
|
|
295
295
|
|
296
296
|
* Authenticate
|
297
297
|
|
298
|
-
New/Refreshed session returned if client's session expired during authentication, requires encoding.
|
299
|
-
|
300
298
|
```python
|
301
299
|
@app.post("api/security/auth")
|
302
300
|
async def on_authenticate(request):
|
@@ -305,15 +303,11 @@ async def on_authenticate(request):
|
|
305
303
|
"You have been authenticated.",
|
306
304
|
authentication_session.json,
|
307
305
|
)
|
308
|
-
if authentication_session.is_refresh:
|
309
|
-
authentication_session.encode(response)
|
310
306
|
return response
|
311
307
|
```
|
312
308
|
|
313
309
|
* Requires Authentication (This method is not called directly and instead used as a decorator)
|
314
310
|
|
315
|
-
New/Refreshed session returned if client's session expired during authentication, requires encoding.
|
316
|
-
|
317
311
|
```python
|
318
312
|
@app.post("api/security/auth")
|
319
313
|
@requires_authentication
|
@@ -323,24 +317,22 @@ async def on_authenticate(request):
|
|
323
317
|
"You have been authenticated.",
|
324
318
|
authentication_session.json,
|
325
319
|
)
|
326
|
-
if authentication_session.is_refresh:
|
327
|
-
authentication_session.encode(response)
|
328
320
|
return response
|
329
321
|
```
|
330
322
|
|
331
323
|
* Authentication Middleware
|
332
324
|
|
333
|
-
Refreshed session
|
325
|
+
New/Refreshed session returned if client's session expired during authentication, requires encoding.
|
326
|
+
|
327
|
+
Middleware is recommended to automatically encode the refreshed session.
|
334
328
|
|
335
329
|
```python
|
336
330
|
@app.on_response
|
337
331
|
async def authentication_refresh_encoder(request, response):
|
338
|
-
|
332
|
+
if hasattr(request.ctx, "authentication_session"):
|
339
333
|
authentication_session = request.ctx.authentication_session
|
340
334
|
if authentication_session.is_refresh:
|
341
335
|
authentication_session.encode(response)
|
342
|
-
except AttributeError:
|
343
|
-
pass
|
344
336
|
```
|
345
337
|
|
346
338
|
## Captcha
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{sanic_security-1.12.2 → sanic_security-1.12.3}/sanic_security.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|