| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.101.0/docs/handbook/_sources/libraries/http_authenticate.rst.txt |
.. _library_http_authenticate:
http_authenticateThis library provides HTTP Basic authentication helpers on top of the normalized HTTP stack.
The library currently provides these public entities:
http_authenticate_verifier_protocol server-side verifier protocol
for checking plaintext credentialshttp_authenticate core Basic parsing, generation, request
protection, and challenge helpershttp_htpasswd_verifier(_) portable Apache .htpasswd subset
verifier supporting {SHA} and $apr1$ entrieshttp_server_core_basic_handler(_, _, _) portable handler wrapper
that applies Basic protection around another object implementing
http_handler_protocolhttp_router_basic_auth(_, _) router companion category that
protects routes declaring basic_auth/1 metadataOpen the `../../apis/library_index.html#http_authenticate <../../apis/library_index.html#http_authenticate>`__ link in a web browser.
To load the library, load the loader.lgt file:
::
| ?- logtalk_load(http_authenticate(loader)).
To test this library, load the tester.lgt file:
::
| ?- logtalk_load(http_authenticate(tester)).
Use http_authenticate directly when you need explicit control over
Basic challenge parsing and request verification:
::
| ?- http_authenticate::protect_request(Request, verifier, Action, [realm('private')]).
Wrap a normal handler with http_server_core_basic_handler(_, _, _)
when you want a portable middleware-style integration point for Basic
verification:
::
| ?- Handler = http_server_core_basic_handler(verifier, app_handler, [realm('private')]).
Use http_router_basic_auth(_, _) in router objects importing
http_router when you want per-route protection driven by normal
route metadata:
::
authorize_routed_request(Request, Action) :-
^^authorize_basic_auth_request(Request, Action).
route_metadata(show_secret, [basic_auth([])]).
Authorization and WWW-Authenticate401 Unauthorized
responses while verifier and configuration errors are rethrownhttp_handler_protocol objectshttp_router_basic_auth(_, _) and
the authorize_routed_request/2 router hook.htpasswd subset verification for {SHA} and
$apr1$ entries using expanded file paths and rejecting malformed
supported hash entriesunauthorized_response/3-4 validate
option values at the call boundary using the shared options
category support401,
but the reason phrase follows the shared HTTP text rules instead
of requiring an atom representation$2a$, $2b$, $2y$) or
traditional crypt() .htpasswd entries