authparser
Used to parse http Authentication headers, and to call handlers per scheme.
Provides
AuthParser
This class does the parsing and dispatches to handler methods per scheme.
add_handler(scheme, user_record_fn, challenge_fn=None, **kwargs)
- Registers an authentication scheme to be handled, and is details
- scheme: (string) the name of the auth scheme, e.g. Basic, Bearer, Digest, etc.
- user_record_fn (callable) the function
get_user_record()calls after parsing the Authorization header.- The function will receive either the token for this scheme, or the params (see RFC 7235).
- The function can return whatever your application needs, eg. True or False whether the Authoriation is valid, or a whole dict of claims.
get_user_record()merely passes what is returned back to your application.
- challenge_fn (callable) [optional] if specified,
get_challenge_header()will call this function while building theWWW-Authenticateheader.- The function receives all kwargs passed to
get_challenge_header(). - The function should return a dict of name-value pairs which will be added to the scheme's challenge params. e.g. a Digest challenge (without qop) will issue a challenge similar to:
WWW-Authenticate: Digest nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", realm="pointw.com", opaque="5ccc069c403ebaf9f0171e9517f40e41"
- The function receives all kwargs passed to
- kwargs - if any, they are passed through to the handler function. For example, you may wish to pass the URL being requested, the method being used, or even the entire request object.
clear_handlers()
- Clears all handlers.
get_user_record(auth_header)
- Parses the Authorization header and passes the results to the handler for the corresponding scheme.
- auth_header (string) the Authorization header from the request (with or without the starting
Authorization:keyword).
- auth_header (string) the Authorization header from the request (with or without the starting
get_challenge_header(**kwargs)
- Returns the challenge header based on the handlers previously added. Call this when forming the response to an unauthorized request.
- kwargs [optional]
- set
multi_line=Trueto have this method return an array of headers, one item in the array per scheme/handler. - all other kwargs are passed to the
challenge_fnfor it to use as it sees fit. For example, if the request had anAuthorization:header that had bad credentials, you could pass that fact to theget_challenge_header()so it can add details to the challenge header params. e.g.WWW-Authenticate: Bearer error="invalid_token"
- set
- kwargs [optional]
Metadata
Release files for authparser 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| authparser-1.1.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| authparser-1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.6 kB
Release files / authparser-1.1.tar.gz
| Download URL | authparser-1.1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
328212eb5f3b4315091f17a0823d00ef0f8584988cbcd6b0ac0842918d48ccda
|
|
BLAKE2b-256 checksum How to use checksums |
99a3eec87a795e7cae40bc1b9b9209d44a7ec893a8af5819e3a8a87b60f06b01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
|
Release files / authparser-1.1-py3-none-any.whl
| Download URL | authparser-1.1-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31cc7f12aa22aa4ac8fdbab59e6ad55a2c8f3b80ad96b8bf84ec5eabe7f8318b
|
|
BLAKE2b-256 checksum How to use checksums |
4670f94ed9841352cf4315d869e11086d3ce4155eda0a1d3d08ba28e673aceb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
|