From b6bfb2eae9819a57c0c29be4c8eda9abc0f3fa3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Tue, 6 Dec 2022 17:38:58 +0800 Subject: [PATCH] Revised the documentation of the DigestAuth class and the calc_response function. --- src/flask_digest_auth/algo.py | 12 ++++++------ src/flask_digest_auth/auth.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/flask_digest_auth/algo.py b/src/flask_digest_auth/algo.py index fe15e35..4815989 100644 --- a/src/flask_digest_auth/algo.py +++ b/src/flask_digest_auth/algo.py @@ -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( diff --git a/src/flask_digest_auth/auth.py b/src/flask_digest_auth/auth.py index 6ad2988..f976ba1 100644 --- a/src/flask_digest_auth/auth.py +++ b/src/flask_digest_auth/auth.py @@ -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]: