sanic-security 1.14.0__tar.gz → 1.14.1__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.
Files changed (21) hide show
  1. {sanic_security-1.14.0/sanic_security.egg-info → sanic_security-1.14.1}/PKG-INFO +3 -4
  2. {sanic_security-1.14.0 → sanic_security-1.14.1}/README.md +2 -3
  3. {sanic_security-1.14.0 → sanic_security-1.14.1}/pyproject.toml +1 -1
  4. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security/authentication.py +10 -7
  5. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security/test/server.py +0 -1
  6. {sanic_security-1.14.0 → sanic_security-1.14.1/sanic_security.egg-info}/PKG-INFO +3 -4
  7. {sanic_security-1.14.0 → sanic_security-1.14.1}/LICENSE +0 -0
  8. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security/__init__.py +0 -0
  9. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security/authorization.py +0 -0
  10. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security/configuration.py +0 -0
  11. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security/exceptions.py +0 -0
  12. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security/models.py +0 -0
  13. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security/test/__init__.py +0 -0
  14. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security/test/tests.py +0 -0
  15. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security/utils.py +0 -0
  16. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security/verification.py +0 -0
  17. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security.egg-info/SOURCES.txt +0 -0
  18. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security.egg-info/dependency_links.txt +0 -0
  19. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security.egg-info/requires.txt +0 -0
  20. {sanic_security-1.14.0 → sanic_security-1.14.1}/sanic_security.egg-info/top_level.txt +0 -0
  21. {sanic_security-1.14.0 → sanic_security-1.14.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sanic-security
3
- Version: 1.14.0
3
+ Version: 1.14.1
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/
@@ -212,7 +212,7 @@ Verifies the client's account via two-step session code.
212
212
  | **code** | 24KF19 |
213
213
 
214
214
  ```python
215
- @app.post("api/security/verify")
215
+ @app.put("api/security/verify")
216
216
  async def on_verify(request):
217
217
  two_step_session = await verify_account(request)
218
218
  return json("You have verified your account and may login!", two_step_session.json)
@@ -255,14 +255,13 @@ Fulfills client authentication session's second factor requirement via two-step
255
255
  | **code** | XGED2U |
256
256
 
257
257
  ```python
258
- @app.post("api/security/fulfill-2fa")
258
+ @app.put("api/security/fulfill-2fa")
259
259
  async def on_two_factor_authentication(request):
260
260
  authentication_session = await fulfill_second_factor(request)
261
261
  response = json(
262
262
  "Authentication session second-factor fulfilled! You are now authenticated.",
263
263
  authentication_session.json,
264
264
  )
265
- authentication_session.encode(response)
266
265
  return response
267
266
  ```
268
267
 
@@ -180,7 +180,7 @@ Verifies the client's account via two-step session code.
180
180
  | **code** | 24KF19 |
181
181
 
182
182
  ```python
183
- @app.post("api/security/verify")
183
+ @app.put("api/security/verify")
184
184
  async def on_verify(request):
185
185
  two_step_session = await verify_account(request)
186
186
  return json("You have verified your account and may login!", two_step_session.json)
@@ -223,14 +223,13 @@ Fulfills client authentication session's second factor requirement via two-step
223
223
  | **code** | XGED2U |
224
224
 
225
225
  ```python
226
- @app.post("api/security/fulfill-2fa")
226
+ @app.put("api/security/fulfill-2fa")
227
227
  async def on_two_factor_authentication(request):
228
228
  authentication_session = await fulfill_second_factor(request)
229
229
  response = json(
230
230
  "Authentication session second-factor fulfilled! You are now authenticated.",
231
231
  authentication_session.json,
232
232
  )
233
- authentication_session.encode(response)
234
233
  return response
235
234
  ```
236
235
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sanic-security"
7
- version = "1.14.0"
7
+ version = "1.14.1"
8
8
  requires-python = ">=3.8"
9
9
  dependencies = [
10
10
  "tortoise-orm>=0.17.0",
@@ -291,13 +291,6 @@ def initialize_security(app: Sanic, create_root=True) -> None:
291
291
  create_root (bool): Determines root account creation on initialization.
292
292
  """
293
293
 
294
- @app.on_response
295
- async def response_handler_middleware(request, response):
296
- if hasattr(request.ctx, "session"):
297
- secure_headers.set_headers(response)
298
- if request.ctx.session.is_refresh:
299
- request.ctx.session.encode(response)
300
-
301
294
  @app.listener("before_server_start")
302
295
  async def audit_configuration(app, loop):
303
296
  if security_config.SECRET == DEFAULT_CONFIG["SECRET"]:
@@ -361,3 +354,13 @@ def initialize_security(app: Sanic, create_root=True) -> None:
361
354
  )
362
355
  await account.roles.add(role)
363
356
  logger.info("Initial admin account created.")
357
+
358
+ @app.on_response
359
+ async def response_handler_middleware(request, response):
360
+ if hasattr(request.ctx, "session"):
361
+ secure_headers.set_headers(response)
362
+ if (
363
+ hasattr(request.ctx.session, "is_refresh")
364
+ and request.ctx.session.is_refresh
365
+ ):
366
+ request.ctx.session.encode(response)
@@ -128,7 +128,6 @@ async def on_two_factor_authentication(request):
128
128
  "Authentication session second-factor fulfilled! You are now authenticated.",
129
129
  authentication_session.bearer.json,
130
130
  )
131
- authentication_session.encode(response)
132
131
  return response
133
132
 
134
133
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sanic-security
3
- Version: 1.14.0
3
+ Version: 1.14.1
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/
@@ -212,7 +212,7 @@ Verifies the client's account via two-step session code.
212
212
  | **code** | 24KF19 |
213
213
 
214
214
  ```python
215
- @app.post("api/security/verify")
215
+ @app.put("api/security/verify")
216
216
  async def on_verify(request):
217
217
  two_step_session = await verify_account(request)
218
218
  return json("You have verified your account and may login!", two_step_session.json)
@@ -255,14 +255,13 @@ Fulfills client authentication session's second factor requirement via two-step
255
255
  | **code** | XGED2U |
256
256
 
257
257
  ```python
258
- @app.post("api/security/fulfill-2fa")
258
+ @app.put("api/security/fulfill-2fa")
259
259
  async def on_two_factor_authentication(request):
260
260
  authentication_session = await fulfill_second_factor(request)
261
261
  response = json(
262
262
  "Authentication session second-factor fulfilled! You are now authenticated.",
263
263
  authentication_session.json,
264
264
  )
265
- authentication_session.encode(response)
266
265
  return response
267
266
  ```
268
267
 
File without changes