sanic-security 1.15.2__py3-none-any.whl → 1.15.3__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.
@@ -247,6 +247,7 @@ def requires_authentication(arg=None):
247
247
  DeactivatedError
248
248
  UnverifiedError
249
249
  DisabledError
250
+ SecondFactorRequiredError
250
251
  ExpiredError
251
252
  """
252
253
 
@@ -287,7 +288,7 @@ def initialize_security(app: Sanic, create_root=True) -> None:
287
288
  Audits configuration, creates root administrator account, and attaches refresh encoder middleware.
288
289
 
289
290
  Args:
290
- app (Sanic): The main Sanic application instance.
291
+ app (Sanic): Sanic application instance.
291
292
  create_root (bool): Determines root account creation on initialization.
292
293
  """
293
294
 
sanic_security/models.py CHANGED
@@ -52,7 +52,7 @@ class BaseModel(Model):
52
52
  Base Sanic Security model that all other models derive from.
53
53
 
54
54
  Attributes:
55
- id (int): Primary key of model.
55
+ id (str): Primary key of model.
56
56
  date_created (datetime): Time this model was created in the database.
57
57
  date_updated (datetime): Time this model was updated in the database.
58
58
  deleted (bool): Renders the model filterable without removing from the database.
@@ -67,7 +67,7 @@ class BaseModel(Model):
67
67
 
68
68
  def validate(self) -> None:
69
69
  """
70
- Raises an error with respect to state.
70
+ Raises an error with respect to model's state.
71
71
 
72
72
  Raises:
73
73
  SecurityError
@@ -77,7 +77,7 @@ class BaseModel(Model):
77
77
  @property
78
78
  def json(self) -> dict:
79
79
  """
80
- A JSON serializable dict to be used in an HTTP request or response.
80
+ A JSON serializable dict to be used in a request or response.
81
81
 
82
82
  Example:
83
83
  Below is an example of this method returning a dict to be used for JSON serialization.
@@ -108,7 +108,7 @@ class Account(BaseModel):
108
108
  username (str): Public identifier.
109
109
  email (str): Private identifier and can be used for verification.
110
110
  phone (str): Mobile phone number with country code included and can be used for verification. Can be null or empty.
111
- password (str): Password of account for protection. Must be hashed via Argon2.
111
+ password (str): Password of account for user protection. must be hashed via Argon2.
112
112
  disabled (bool): Renders the account unusable but available.
113
113
  verified (bool): Renders the account unusable until verified via two-step verification or other method.
114
114
  roles (ManyToManyRelation[Role]): Roles associated with this account.
@@ -247,7 +247,7 @@ class Account(BaseModel):
247
247
  @staticmethod
248
248
  async def get_via_header(request: Request):
249
249
  """
250
- Retrieve the account the client is logging into and client's password attempt via the basic authorization header.
250
+ Retrieve an account via the basic authorization header.
251
251
 
252
252
  Args:
253
253
  request (Request): Sanic request parameter.
@@ -276,7 +276,7 @@ class Account(BaseModel):
276
276
  @staticmethod
277
277
  async def get_via_phone(phone: str):
278
278
  """
279
- Retrieve an account with a phone number.
279
+ Retrieve an account via a phone number.
280
280
 
281
281
  Args:
282
282
  phone (str): Phone number associated to account being retrieved.
@@ -332,7 +332,7 @@ class Session(BaseModel):
332
332
 
333
333
  async def deactivate(self):
334
334
  """
335
- Renders session deactivated and unusable.
335
+ Renders session deactivated and therefor unusable.
336
336
 
337
337
  Raises:
338
338
  DeactivatedError
@@ -426,7 +426,7 @@ class Session(BaseModel):
426
426
  Retrieves sessions associated to an account.
427
427
 
428
428
  Args:
429
- account (Request): Account associated with sessions being retrieved.
429
+ account (Account): Account associated with sessions being retrieved.
430
430
 
431
431
  Returns:
432
432
  sessions
@@ -442,7 +442,7 @@ class Session(BaseModel):
442
442
  @classmethod
443
443
  def decode_raw(cls, request: Request) -> dict:
444
444
  """
445
- Decodes JWT token from client cookie into a python dict.
445
+ Decodes session JWT token from client cookie into a python dict.
446
446
 
447
447
  Args:
448
448
  request (Request): Sanic request parameter.
@@ -471,7 +471,7 @@ class Session(BaseModel):
471
471
  @classmethod
472
472
  async def decode(cls, request: Request):
473
473
  """
474
- Decodes session JWT from client cookie to a Sanic Security session.
474
+ Decodes session JWT token from client cookie into a session model.
475
475
 
476
476
  Args:
477
477
  request (Request): Sanic request parameter.
@@ -498,11 +498,11 @@ class Session(BaseModel):
498
498
 
499
499
  class VerificationSession(Session):
500
500
  """
501
- Used for a client verification method that requires some form of code, challenge, or key.
501
+ Used for client verification challenges that require some form of code or key.
502
502
 
503
503
  Attributes:
504
- attempts (int): The amount of incorrect times a user entered a code not equal to this verification sessions code.
505
- code (str): Used as a secret key that would be sent via email, text, etc to complete the verification challenge.
504
+ attempts (int): The amount of times a user entered a code not equal to this verification sessions code.
505
+ code (str): A secret key that would be sent via email, text, etc.
506
506
  """
507
507
 
508
508
  attempts: int = fields.IntField(default=0)
@@ -540,7 +540,7 @@ class VerificationSession(Session):
540
540
 
541
541
 
542
542
  class TwoStepSession(VerificationSession):
543
- """Validates a client using a code sent via email or text."""
543
+ """Validates client using a code sent via email or text."""
544
544
 
545
545
  @classmethod
546
546
  async def new(cls, request: Request, account: Account, **kwargs):
@@ -559,7 +559,7 @@ class TwoStepSession(VerificationSession):
559
559
 
560
560
 
561
561
  class CaptchaSession(VerificationSession):
562
- """Validates a client with a captcha challenge."""
562
+ """Validates client with a captcha challenge via image or audio."""
563
563
 
564
564
  @classmethod
565
565
  async def new(cls, request: Request, **kwargs):
@@ -574,7 +574,7 @@ class CaptchaSession(VerificationSession):
574
574
 
575
575
  def get_image(self) -> HTTPResponse:
576
576
  """
577
- Retrieves captcha image file.
577
+ Retrieves captcha image data.
578
578
 
579
579
  Returns:
580
580
  captcha_image
@@ -586,7 +586,7 @@ class CaptchaSession(VerificationSession):
586
586
 
587
587
  def get_audio(self) -> HTTPResponse:
588
588
  """
589
- Retrieves captcha audio file.
589
+ Retrieves captcha audio data.
590
590
 
591
591
  Returns:
592
592
  captcha_audio
@@ -604,9 +604,9 @@ class AuthenticationSession(Session):
604
604
  Used to authenticate and identify a client.
605
605
 
606
606
  Attributes:
607
- refresh_expiration_date (bool): Date and time the session can no longer be refreshed.
607
+ refresh_expiration_date (datetime): Date and time the session can no longer be refreshed.
608
608
  requires_second_factor (bool): Determines if session requires a second factor.
609
- is_refresh (bool): Will only be true once when instantiated during refresh of expired session.
609
+ is_refresh (bool): Will only be true once when instantiated during the refresh of expired session.
610
610
  """
611
611
 
612
612
  refresh_expiration_date: datetime.datetime = fields.DatetimeField(null=True)
@@ -679,7 +679,7 @@ class Role(BaseModel):
679
679
  Attributes:
680
680
  name (str): Name of the role.
681
681
  description (str): Description of the role.
682
- permissions (str): Permissions of the role. Must be separated via comma + space and in wildcard format (printer:query, dashboard:info,delete).
682
+ permissions (str): Permissions of the role. Must be separated via comma & space and in wildcard format (printer:query, dashboard:info,delete).
683
683
  """
684
684
 
685
685
  name: str = fields.CharField(unique=True, max_length=255)
sanic_security/utils.py CHANGED
@@ -98,14 +98,12 @@ def get_expiration_date(seconds: int) -> datetime.datetime:
98
98
  )
99
99
 
100
100
 
101
- def json(
102
- message: str, data, status_code: int = 200
103
- ) -> HTTPResponse: # May be causing fixture error bc of json property
101
+ def json(message: str, data, status_code: int = 200) -> HTTPResponse:
104
102
  """
105
103
  A preformatted Sanic json response.
106
104
 
107
105
  Args:
108
- message (int): Message describing data or relaying human-readable information.
106
+ message (str): Message describing data or relaying human-readable information.
109
107
  data (Any): Raw information to be used by client.
110
108
  status_code (int): HTTP response code.
111
109
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sanic-security
3
- Version: 1.15.2
3
+ Version: 1.15.3
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/
@@ -366,7 +366,7 @@ async def on_captcha(request):
366
366
 
367
367
  ## Two-step Verification
368
368
 
369
- Two-step verification should be integrated with other custom functionalities, such as account verification during registration.
369
+ Two-step verification should be integrated with other custom functionalities, such as forgot password recovery.
370
370
 
371
371
  * Request Two-step Verification
372
372
 
@@ -1,16 +1,16 @@
1
1
  sanic_security/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- sanic_security/authentication.py,sha256=3Pit1B4PN_MRvwAlhYPHl_6DGD9JVpdPjgjiyKQJanM,13145
2
+ sanic_security/authentication.py,sha256=Ud2iOAyBFgLp3KPs2z5J31FgyzgVX85KfmyMYfwykyY,13171
3
3
  sanic_security/authorization.py,sha256=jAxfDT9cHN_zpMKcA3oYFZ5Eu2KItnMJZ7oPcqmMwrw,7537
4
4
  sanic_security/configuration.py,sha256=_E66ts5g9t_XHW9ZAnr48rWVcZmGNu_DWGDxm_AVVWE,5681
5
5
  sanic_security/exceptions.py,sha256=9zISLyAvP6qN8sNR8e5qxKP__FA4NLIXCun_fEKndOw,5297
6
- sanic_security/models.py,sha256=1gMoPnzA9cpJaZXJ1GtgAzsXxGO-rts-f3YyVgcd7lY,22475
7
- sanic_security/utils.py,sha256=Il5MjFzVe975yx_CV2HV_LVQYl2W3XYDRGtCG5CQA8Q,3531
6
+ sanic_security/models.py,sha256=hBteGfKRkufkbxUY-BJ31pEXO4BfyJtNPnU0QsGWUdA,22395
7
+ sanic_security/utils.py,sha256=7693xKQdQVcU2m9V93zQOSCB_42PJs9bUvobXYmkH_w,3471
8
8
  sanic_security/verification.py,sha256=9bi8-NZ8GE3rcuELZ63yh18zDg8RxvxGPkhAu5SzLn0,8692
9
9
  sanic_security/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  sanic_security/test/server.py,sha256=RjL9Kfvkfqpm5TXWwFQKKa0J4hfTKgwI6U0s_TAKO8w,11984
11
11
  sanic_security/test/tests.py,sha256=bW5fHJfsCrg8eBmcSqVMLm0R5XRL1ou-XJJRgz09GOE,21993
12
- sanic_security-1.15.2.dist-info/LICENSE,sha256=sXlJs9_mG-dCkPfWsDnuzydJWagS82E2gYtkVH9enHA,1100
13
- sanic_security-1.15.2.dist-info/METADATA,sha256=PNjYIu36zcUqehxfO0Zg7X98CwHSzGbPc1FYXsXo7qs,23247
14
- sanic_security-1.15.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
15
- sanic_security-1.15.2.dist-info/top_level.txt,sha256=ZybkhHXSjfzhmv8XeqLvnNmLmv21Z0oPX6Ep4DJN8b0,15
16
- sanic_security-1.15.2.dist-info/RECORD,,
12
+ sanic_security-1.15.3.dist-info/LICENSE,sha256=sXlJs9_mG-dCkPfWsDnuzydJWagS82E2gYtkVH9enHA,1100
13
+ sanic_security-1.15.3.dist-info/METADATA,sha256=93NCYuMXEoL13wTy0YTB-Fh7JGe1tb8eFD324KpJOx8,23231
14
+ sanic_security-1.15.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
15
+ sanic_security-1.15.3.dist-info/top_level.txt,sha256=ZybkhHXSjfzhmv8XeqLvnNmLmv21Z0oPX6Ep4DJN8b0,15
16
+ sanic_security-1.15.3.dist-info/RECORD,,