Revised the documentation of the DigestAuth class and the calc_response function.

This commit is contained in:
依瑪貓 2022-12-06 17:38:58 +08:00
parent e6b4594393
commit b6bfb2eae9
2 changed files with 9 additions and 9 deletions

View File

@ -49,16 +49,16 @@ def calc_response(
:param uri: The request URI.
:param password_hash: The password hash for the HTTP digest authentication.
:param nonce: The nonce.
:param qop: the quality of protection.
:param qop: the quality of protection, either "auth" or "auth-int".
:param algorithm: The algorithm, either "MD5" or "MD5-sess".
:param cnonce: The client nonce, which must exists when qop exists or
algorithm="MD5-sess".
:param nc: The request counter, which must exists when qop exists.
:param body: The request body, which must exists when qop="auth-int".
:return: The response value.
:raise UnauthorizedException: When the cnonce is missing with the MD5-sess
algorithm, when the body is missing with the auth-int qop, or when the
cnonce or nc is missing with the auth or auth-int qop.
:raise UnauthorizedException: When cnonce is missing with the
algorithm="MD5-sess", when body is missing with qop="auth-int", or when
cnonce or nc is missing with qop exits.
"""
def validate_required(field: t.Optional[str], error: str) -> None:
@ -75,8 +75,8 @@ def calc_response(
"""Calculates and returns the first hash.
:return: The first hash.
:raise UnauthorizedException: When the cnonce is missing with the MD5-sess
algorithm.
:raise UnauthorizedException: When the cnonce is missing with
algorithm="MD5-sess".
"""
if algorithm == "MD5-sess":
validate_required(

View File

@ -103,7 +103,7 @@ class DigestAuth:
def login_required(self, view) -> t.Callable:
"""The view decorator for HTTP digest authentication.
:param view:
:param view: The view.
:return: The login-protected view.
"""
@ -217,10 +217,10 @@ class DigestAuth:
raise UnauthorizedException("Invalid nonce")
def make_response_header(self, state: AuthState) -> str:
"""Composes and returns the WWW-Authenticate response header.
"""Composes and returns the ``WWW-Authenticate`` response header.
:param state: The authorization state.
:return: The WWW-Authenticate response header.
:return: The ``WWW-Authenticate`` response header.
"""
def get_opaque() -> t.Optional[str]: