Part of bzrlib.transport.http._urllib2_wrappers View In Hierarchy
Known subclasses: bzrlib.transport.http._urllib2_wrappers.BasicAuthHandler, bzrlib.transport.http._urllib2_wrappers.DigestAuthHandler, bzrlib.transport.http._urllib2_wrappers.HTTPAuthHandler, bzrlib.transport.http._urllib2_wrappers.NegotiateAuthHandler, bzrlib.transport.http._urllib2_wrappers.ProxyAuthHandler
A custom abstract authentication handler for all http authentications.
Provides the meat to handle authentication errors and preventively set authentication headers after the first successful authentication.
This can be used for http and proxy, as well as for basic, negotiate and digest authentications.
This provides an unified interface for all authentication handlers (urllib2 provides far too many with different policies).
The interaction between this handler and the urllib2 framework is not obvious, it works as follow:
opener.open(request) is called:
Method | __init__ | Undocumented |
Method | update_auth | Update a value in auth marking the auth as modified if needed |
Method | auth_required | Retry the request if the auth scheme is ours. |
Method | add_auth_header | Add the authentication header to the request |
Method | auth_match | Check that we are able to handle that authentication scheme. |
Method | build_auth_header | Build the value of the header used to authenticate. |
Method | auth_successful | The authentification was successful for the request. |
Method | get_user_password | Ask user for a password if none is already available. |
Method | http_request | Insert an authentication header if information is available |
Method | _parse_auth_header | Parse the authentication header. |
Method | _build_password_prompt | Build a prompt taking the protocol used into account. |
Method | _build_username_prompt | Build a prompt taking the protocol used into account. |
Parameters | server_header | The value of the header sent by the server describing the authenticaion request. |
Returns | A tuple (scheme, remainder) scheme being the first word in the given header (lower cased), remainder may be None. |
Parameters | request | The request needing authentication. |
headers | The headers for the authentication error response. | |
Returns | None or the response for the authenticated request. |
The request authentication parameters may need to be updated with info from the server. Some of these parameters, when combined, are considered to be the authentication key, if one of them change the authentication result may change. 'user' and 'password' are exampls, but some auth schemes may have others (digest's nonce is an example, digest's nonce_count is a counter-example). Such parameters must be updated by using the update_auth() method.
Parameters | header | The authentication header sent by the server. |
auth | The auth parameters already known. They may be updated. | |
Returns | True if we can try to handle the authentication. |
Parameters | auth | The auth parameters needed to build the header. |
request | The request needing authentication. | |
Returns | None or header. |
Additional infos may be available in the response.
Parameters | request | The succesfully authenticated request. |
response | The server response (may contain auth info). |
Parameters | auth | authentication info gathered so far (from the initial url and then during dialog with the server). |
The AuthHandler is used by http and https, we want that information in the prompt, so we build the prompt from the authentication dict which contains all the needed parts.
Also, http and proxy AuthHandlers present different prompts to the user. The daughter classes should implements a public build_password_prompt using this method.
The AuthHandler is used by http and https, we want that information in the prompt, so we build the prompt from the authentication dict which contains all the needed parts.
Also, http and proxy AuthHandlers present different prompts to the user. The daughter classes should implements a public build_username_prompt using this method.