Compare commits

..

No commits in common. "0387abb4f665ecd382a7d347d77111d93ca3f2a1" and "46f05a1022a80b2e18746b3517f037e9f64c320e" have entirely different histories.

5 changed files with 29 additions and 69 deletions

View File

@ -1,37 +1,24 @@
flask\_digest\_auth package flask\_digest\_auth package
=========================== ===========================
Submodules The ``DigestAuth`` Class
---------- ------------------------
.. autoclass:: flask_digest_auth.DigestAuth
:members:
:undoc-members:
:show-inheritance:
flask\_digest\_auth.algo module The ``make_password_hash`` Function
------------------------------- -----------------------------------
.. autofunction:: flask_digest_auth.make_password_hash
.. automodule:: flask_digest_auth.algo The ``calc_response`` Function
:members: ------------------------------
:undoc-members: .. autofunction:: flask_digest_auth.calc_response
:show-inheritance:
flask\_digest\_auth.auth module The ``Client`` Test Class
------------------------------- -------------------------
.. autoclass:: flask_digest_auth.Client
.. automodule:: flask_digest_auth.auth :members:
:members: :undoc-members:
:undoc-members: :show-inheritance:
:show-inheritance:
flask\_digest\_auth.test module
-------------------------------
.. automodule:: flask_digest_auth.test
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: flask_digest_auth
:members:
:undoc-members:
:show-inheritance:

View File

@ -26,7 +26,6 @@ Indices and tables
================== ==================
* :ref:`genindex` * :ref:`genindex`
* :ref:`modindex`
* :ref:`search` * :ref:`search`
.. _HTTP Digest Authentication: https://en.wikipedia.org/wiki/Digest_access_authentication .. _HTTP Digest Authentication: https://en.wikipedia.org/wiki/Digest_access_authentication

View File

@ -63,7 +63,7 @@ The username is part of the hash. If the user changes their username,
you need to ask their password, to generate and store the new password you need to ask their password, to generate and store the new password
hash. hash.
See :func:`flask_digest_auth.algo.make_password_hash`. See :meth:`flask_digest_auth.make_password_hash`.
Flask-Digest-Auth Alone Flask-Digest-Auth Alone
@ -118,7 +118,7 @@ logging the log in event, adding the log in counter, etc.
def on_login(user: User) -> None: def on_login(user: User) -> None:
user.visits = user.visits + 1 user.visits = user.visits + 1
See :meth:`flask_digest_auth.auth.DigestAuth.register_on_login`. See :meth:`flask_digest_auth.DigestAuth.register_on_login`.
Log Out Log Out
@ -127,7 +127,7 @@ Log Out
Flask-Digest-Auth supports log out. The user will be prompted for the Flask-Digest-Auth supports log out. The user will be prompted for the
new username and password. new username and password.
See :meth:`flask_digest_auth.auth.DigestAuth.logout`. See :meth:`flask_digest_auth.DigestAuth.logout`.
Test Client Test Client
@ -136,7 +136,7 @@ Test Client
Flask-Digest-Auth comes with a test client that supports HTTP digest Flask-Digest-Auth comes with a test client that supports HTTP digest
authentication. authentication.
See :class:`flask_digest_auth.test.Client`. See :class:`flask_digest_auth.Client`.
Also see :ref:`example-unittest` and :ref:`example-pytest`. Also see :ref:`example-unittest` and :ref:`example-pytest`.

View File

@ -1,7 +0,0 @@
src
===
.. toctree::
:maxdepth: 4
flask_digest_auth

View File

@ -16,9 +16,8 @@
# limitations under the License. # limitations under the License.
"""The HTTP Digest Authentication. """The HTTP Digest Authentication.
See `RFC 2617`_ HTTP Authentication: Basic and Digest Access Authentication See RFC 2617 HTTP Authentication: Basic and Digest Access Authentication
.. _RFC 2617: https://www.rfc-editor.org/rfc/rfc2617
""" """
from __future__ import annotations from __future__ import annotations
@ -418,30 +417,21 @@ class DigestAuth:
class AuthState: class AuthState:
"""The authentication state. It keeps the status in the earlier """The authorization state."""
authentication stage, so that the latter response stage knows how to
response.
"""
def __init__(self): def __init__(self):
"""Constructs the authorization state.""" """Constructs the authorization state."""
self.opaque: t.Optional[str] = None self.opaque: t.Optional[str] = None
"""The opaque value specified by the client, if valid."""
self.stale: t.Optional[bool] = None self.stale: t.Optional[bool] = None
"""The stale value, if there is a previous log in attempt."""
class UnauthorizedException(Exception): class UnauthorizedException(Exception):
"""The exception thrown when the authentication fails.""" """The exception thrown when the authentication is failed."""
pass
class BasePasswordHashGetter: class BasePasswordHashGetter:
"""The base callback that given the username, returns the password hash, """The base password hash getter."""
or None if the user does not exist. The default is to raise an
:class:`UnboundLocalError` if the callback is not registered yet.
See :meth:`flask_digest_auth.auth.DigestAuth.register_get_password`
"""
@staticmethod @staticmethod
def __call__(username: str) -> t.Optional[str]: def __call__(username: str) -> t.Optional[str]:
@ -457,12 +447,7 @@ class BasePasswordHashGetter:
class BaseUserGetter: class BaseUserGetter:
"""The base callback that given the username, returns the user, or None if """The base user getter."""
the user does not exist. The default is to raise an
:class:`UnboundLocalError` if the callback is not registered yet.
See :meth:`flask_digest_auth.auth.DigestAuth.register_get_user`
"""
@staticmethod @staticmethod
def __call__(username: str) -> t.Optional[t.Any]: def __call__(username: str) -> t.Optional[t.Any]:
@ -478,11 +463,7 @@ class BaseUserGetter:
class BaseOnLogInCallback: class BaseOnLogInCallback:
"""The base callback to run when the user logs in, given the logged-in """The base callback when the user logs in."""
user. The default does nothing.
See :meth:`flask_digest_auth.auth.DigestAuth.register_on_login`
"""
@staticmethod @staticmethod
def __call__(user: t.Any) -> None: def __call__(user: t.Any) -> None: