diff options
| -rw-r--r-- | CHANGES.txt | 4 | ||||
| -rw-r--r-- | docs/api/authentication.rst | 2 | ||||
| -rw-r--r-- | pyramid/authentication.py | 14 |
3 files changed, 10 insertions, 10 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index b485ae59e..8fd6a8a91 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -20,9 +20,9 @@ Features -------- - The `_get_credentials` private method of `BasicAuthAuthenticationPolicy` - has been extracted into standalone function `extract_http_basic_credentials` + has been extracted into standalone function ``extract_http_basic_credentials` in `pyramid.authentication` module, this function extracts HTTP Basic - credentials from `request` object, and returns them as a named tuple. + credentials from a ``request`` object, and returns them as a named tuple. Bug Fixes --------- diff --git a/docs/api/authentication.rst b/docs/api/authentication.rst index de2c73491..57f32327a 100644 --- a/docs/api/authentication.rst +++ b/docs/api/authentication.rst @@ -34,6 +34,8 @@ Helper Classes .. autoclass:: AuthTktCookieHelper :members: + .. autoclass:: HTTPBasicCredentials + :members: Helper Functions ~~~~~~~~~~~~~~~~ diff --git a/pyramid/authentication.py b/pyramid/authentication.py index 7d766fd06..2ee5576d9 100644 --- a/pyramid/authentication.py +++ b/pyramid/authentication.py @@ -1131,19 +1131,17 @@ class _SimpleSerializer(object): return bytes_(appstruct) -http_basic_credentials = namedtuple('http_basic_credentials', - ['username', 'password']) +HTTPBasicCredentials = namedtuple( + 'HTTPBasicCredentials', ['username', 'password']) def extract_http_basic_credentials(request): """ A helper function for extraction of HTTP Basic credentials - from a given :term:`request`. Returned values: + from a given :term:`request`. - - ``None`` - when credentials couldn't be extracted - - ``namedtuple`` with extracted ``username`` and ``password`` attributes + Returns a :class:`.HTTPBasicCredentials` 2-tuple with ``username`` and + ``password`` attributes or ``None`` if no credentials could be found. - ``request`` - The :term:`request` object """ authorization = request.headers.get('Authorization') if not authorization: @@ -1174,4 +1172,4 @@ def extract_http_basic_credentials(request): except ValueError: # not enough values to unpack return None - return http_basic_credentials(username, password) + return HTTPBasicCredentials(username, password) |
