sanic-security 1.16.9__tar.gz → 1.16.11__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 (22) hide show
  1. {sanic_security-1.16.9/sanic_security.egg-info → sanic_security-1.16.11}/PKG-INFO +9 -12
  2. {sanic_security-1.16.9 → sanic_security-1.16.11}/README.md +8 -11
  3. {sanic_security-1.16.9 → sanic_security-1.16.11}/pyproject.toml +1 -1
  4. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/models.py +1 -2
  5. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/oauth.py +1 -0
  6. {sanic_security-1.16.9 → sanic_security-1.16.11/sanic_security.egg-info}/PKG-INFO +9 -12
  7. {sanic_security-1.16.9 → sanic_security-1.16.11}/LICENSE +0 -0
  8. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/__init__.py +0 -0
  9. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/authentication.py +0 -0
  10. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/authorization.py +0 -0
  11. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/configuration.py +0 -0
  12. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/exceptions.py +0 -0
  13. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/test/__init__.py +0 -0
  14. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/test/server.py +0 -0
  15. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/test/tests.py +0 -0
  16. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/utils.py +0 -0
  17. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security/verification.py +0 -0
  18. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security.egg-info/SOURCES.txt +0 -0
  19. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security.egg-info/dependency_links.txt +0 -0
  20. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security.egg-info/requires.txt +0 -0
  21. {sanic_security-1.16.9 → sanic_security-1.16.11}/sanic_security.egg-info/top_level.txt +0 -0
  22. {sanic_security-1.16.9 → sanic_security-1.16.11}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sanic-security
3
- Version: 1.16.9
3
+ Version: 1.16.11
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/
@@ -122,19 +122,16 @@ pip3 install sanic-security --upgrade
122
122
 
123
123
  ### Configuration
124
124
 
125
- Sanic Security configuration is merely an object that can be modified either using dot-notation or like a dictionary.
126
-
125
+ Sanic Security configuration is merely a `SimpleNamespace` that can be modified using dot-notation.
127
126
  For example:
128
127
 
129
128
  ```python
130
129
  from sanic_security.configuration import config as security_config
131
130
 
132
131
  security_config.SECRET = "This is a big secret. Shhhhh"
133
- security_config["CAPTCHA_FONT"] = "resources/captcha-font.ttf"
132
+ security_config.CAPTCHA_FONT = "resources/captcha-font.ttf"
134
133
  ```
135
134
 
136
- You can also use the update() method like on regular dictionaries.
137
-
138
135
  Any environment variables defined with the SANIC_SECURITY_ prefix will be applied to the config. For example, setting
139
136
  SANIC_SECURITY_SECRET will be loaded by the application automatically and fed into the SECRET config variable.
140
137
 
@@ -295,9 +292,7 @@ Verifies the client's account via two-step session code.
295
292
  @app.put("api/security/verify")
296
293
  async def on_verify(request):
297
294
  two_step_session = await verify_account(request)
298
- return json(
299
- "You have verified your account and may login!", two_step_session.bearer.json
300
- )
295
+ return json("You have verified your account and may login!", two_step_session.json)
301
296
  ```
302
297
 
303
298
  * Login (with two-factor authentication)
@@ -319,7 +314,7 @@ async def on_login(request):
319
314
  ) # Custom method for emailing verification code.
320
315
  response = json(
321
316
  "Login successful! Two-factor authentication required.",
322
- authentication_session.bearer.json,
317
+ authentication_session.json,
323
318
  )
324
319
  authentication_session.encode(response)
325
320
  two_step_session.encode(response)
@@ -342,7 +337,7 @@ async def on_two_factor_authentication(request):
342
337
  authentication_session = await fulfill_second_factor(request)
343
338
  response = json(
344
339
  "Authentication session second-factor fulfilled! You are now authenticated.",
345
- authentication_session.bearer.json,
340
+ authentication_session.json,
346
341
  )
347
342
  return response
348
343
  ```
@@ -368,7 +363,9 @@ async def on_anonymous_login(request):
368
363
  @app.post("api/security/logout")
369
364
  async def on_logout(request):
370
365
  authentication_session = await logout(request)
371
- token_info = await oauth_revoke(request, google_oauth) # Remove if not utilizing OAuth
366
+ token_info = await oauth_revoke(
367
+ request, google_oauth
368
+ ) # Remove if not utilizing OAuth
372
369
  response = json(
373
370
  "Logout successful!",
374
371
  {"token_info": token_info, "auth_session": authentication_session.json},
@@ -89,19 +89,16 @@ pip3 install sanic-security --upgrade
89
89
 
90
90
  ### Configuration
91
91
 
92
- Sanic Security configuration is merely an object that can be modified either using dot-notation or like a dictionary.
93
-
92
+ Sanic Security configuration is merely a `SimpleNamespace` that can be modified using dot-notation.
94
93
  For example:
95
94
 
96
95
  ```python
97
96
  from sanic_security.configuration import config as security_config
98
97
 
99
98
  security_config.SECRET = "This is a big secret. Shhhhh"
100
- security_config["CAPTCHA_FONT"] = "resources/captcha-font.ttf"
99
+ security_config.CAPTCHA_FONT = "resources/captcha-font.ttf"
101
100
  ```
102
101
 
103
- You can also use the update() method like on regular dictionaries.
104
-
105
102
  Any environment variables defined with the SANIC_SECURITY_ prefix will be applied to the config. For example, setting
106
103
  SANIC_SECURITY_SECRET will be loaded by the application automatically and fed into the SECRET config variable.
107
104
 
@@ -262,9 +259,7 @@ Verifies the client's account via two-step session code.
262
259
  @app.put("api/security/verify")
263
260
  async def on_verify(request):
264
261
  two_step_session = await verify_account(request)
265
- return json(
266
- "You have verified your account and may login!", two_step_session.bearer.json
267
- )
262
+ return json("You have verified your account and may login!", two_step_session.json)
268
263
  ```
269
264
 
270
265
  * Login (with two-factor authentication)
@@ -286,7 +281,7 @@ async def on_login(request):
286
281
  ) # Custom method for emailing verification code.
287
282
  response = json(
288
283
  "Login successful! Two-factor authentication required.",
289
- authentication_session.bearer.json,
284
+ authentication_session.json,
290
285
  )
291
286
  authentication_session.encode(response)
292
287
  two_step_session.encode(response)
@@ -309,7 +304,7 @@ async def on_two_factor_authentication(request):
309
304
  authentication_session = await fulfill_second_factor(request)
310
305
  response = json(
311
306
  "Authentication session second-factor fulfilled! You are now authenticated.",
312
- authentication_session.bearer.json,
307
+ authentication_session.json,
313
308
  )
314
309
  return response
315
310
  ```
@@ -335,7 +330,9 @@ async def on_anonymous_login(request):
335
330
  @app.post("api/security/logout")
336
331
  async def on_logout(request):
337
332
  authentication_session = await logout(request)
338
- token_info = await oauth_revoke(request, google_oauth) # Remove if not utilizing OAuth
333
+ token_info = await oauth_revoke(
334
+ request, google_oauth
335
+ ) # Remove if not utilizing OAuth
339
336
  response = json(
340
337
  "Logout successful!",
341
338
  {"token_info": token_info, "auth_session": authentication_session.json},
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sanic-security"
7
- version = "1.16.9"
7
+ version = "1.16.11"
8
8
  requires-python = ">=3.8"
9
9
  dependencies = [
10
10
  "tortoise-orm>=0.17.0",
@@ -369,8 +369,7 @@ class Session(BaseModel):
369
369
  samesite=config.SESSION_SAMESITE,
370
370
  secure=config.SESSION_SECURE,
371
371
  domain=config.SESSION_DOMAIN,
372
- expires=getattr(self, "refresh_expiration_date", None)
373
- or self.expiration_date,
372
+ expires=getattr(self, "refresh_expiration_date", self.expiration_date),
374
373
  )
375
374
 
376
375
  @property
@@ -235,6 +235,7 @@ def initialize_oauth(app: Sanic) -> None:
235
235
  async def session_middleware(request, response):
236
236
  if hasattr(request.ctx, "oauth"):
237
237
  if request.ctx.oauth.get("is_refresh"):
238
+ del request.ctx.oauth["is_refresh"]
238
239
  oauth_encode(response, request.ctx.oauth)
239
240
  elif request.ctx.oauth.get("revoked"):
240
241
  response.delete_cookie(f"{config.SESSION_PREFIX}_oauth")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sanic-security
3
- Version: 1.16.9
3
+ Version: 1.16.11
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/
@@ -122,19 +122,16 @@ pip3 install sanic-security --upgrade
122
122
 
123
123
  ### Configuration
124
124
 
125
- Sanic Security configuration is merely an object that can be modified either using dot-notation or like a dictionary.
126
-
125
+ Sanic Security configuration is merely a `SimpleNamespace` that can be modified using dot-notation.
127
126
  For example:
128
127
 
129
128
  ```python
130
129
  from sanic_security.configuration import config as security_config
131
130
 
132
131
  security_config.SECRET = "This is a big secret. Shhhhh"
133
- security_config["CAPTCHA_FONT"] = "resources/captcha-font.ttf"
132
+ security_config.CAPTCHA_FONT = "resources/captcha-font.ttf"
134
133
  ```
135
134
 
136
- You can also use the update() method like on regular dictionaries.
137
-
138
135
  Any environment variables defined with the SANIC_SECURITY_ prefix will be applied to the config. For example, setting
139
136
  SANIC_SECURITY_SECRET will be loaded by the application automatically and fed into the SECRET config variable.
140
137
 
@@ -295,9 +292,7 @@ Verifies the client's account via two-step session code.
295
292
  @app.put("api/security/verify")
296
293
  async def on_verify(request):
297
294
  two_step_session = await verify_account(request)
298
- return json(
299
- "You have verified your account and may login!", two_step_session.bearer.json
300
- )
295
+ return json("You have verified your account and may login!", two_step_session.json)
301
296
  ```
302
297
 
303
298
  * Login (with two-factor authentication)
@@ -319,7 +314,7 @@ async def on_login(request):
319
314
  ) # Custom method for emailing verification code.
320
315
  response = json(
321
316
  "Login successful! Two-factor authentication required.",
322
- authentication_session.bearer.json,
317
+ authentication_session.json,
323
318
  )
324
319
  authentication_session.encode(response)
325
320
  two_step_session.encode(response)
@@ -342,7 +337,7 @@ async def on_two_factor_authentication(request):
342
337
  authentication_session = await fulfill_second_factor(request)
343
338
  response = json(
344
339
  "Authentication session second-factor fulfilled! You are now authenticated.",
345
- authentication_session.bearer.json,
340
+ authentication_session.json,
346
341
  )
347
342
  return response
348
343
  ```
@@ -368,7 +363,9 @@ async def on_anonymous_login(request):
368
363
  @app.post("api/security/logout")
369
364
  async def on_logout(request):
370
365
  authentication_session = await logout(request)
371
- token_info = await oauth_revoke(request, google_oauth) # Remove if not utilizing OAuth
366
+ token_info = await oauth_revoke(
367
+ request, google_oauth
368
+ ) # Remove if not utilizing OAuth
372
369
  response = json(
373
370
  "Logout successful!",
374
371
  {"token_info": token_info, "auth_session": authentication_session.json},