Package ganeti :: Package http :: Module auth :: Class HttpServerRequestAuthentication
[hide private]
[frames] | no frames]

Class HttpServerRequestAuthentication

source code


Instance Methods [hide private]
string
GetAuthRealm(self, req)
Returns the authentication realm for a request.
source code
 
AuthenticationRequired(self, req)
Determines whether authentication is required for a request.
source code
 
PreHandleRequest(self, req)
Called before a request is handled.
source code
 
Authenticate(self, req)
Checks the credentiales.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
(str, str)
ExtractUserPassword(req)
Extracts a user and a password from the http authorization header.
source code
(str, str)
_ExtractBasicUserPassword(in_data)
Extracts user and password from the contents of an authorization header.
source code
(str, str)
ExtractSchemePassword(expected_password)
Extracts a scheme and a password from the expected_password.
source code
 
VerifyBasicAuthPassword(username, password, expected, realm)
Checks the password for basic authentication.
source code
Class Variables [hide private]
  AUTH_REALM = "Unspecified"
  _CLEARTEXT_SCHEME = "{CLEARTEXT}"
  _HA1_SCHEME = "{HA1}"
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

GetAuthRealm(self, req)

source code 

Returns the authentication realm for a request.

May be overridden by a subclass, which then can return different realms for different paths.

Parameters:
Returns: string
Authentication realm

AuthenticationRequired(self, req)

source code 

Determines whether authentication is required for a request.

To enable authentication, override this function in a subclass and return True. AUTH_REALM must be set.

Parameters:

PreHandleRequest(self, req)

source code 

Called before a request is handled.

Parameters:

ExtractUserPassword(req)
Static Method

source code 

Extracts a user and a password from the http authorization header.

Parameters:
Returns: (str, str)
A tuple containing a user and a password. One or both values might be None if they are not presented

_ExtractBasicUserPassword(in_data)
Static Method

source code 

Extracts user and password from the contents of an authorization header.

Parameters:
  • in_data (str) - Username and password encoded as Base64
Returns: (str, str)
A tuple containing user and password. One or both values might be None if they are not presented

Authenticate(self, req)

source code 

Checks the credentiales.

This function MUST be overridden by a subclass.

ExtractSchemePassword(expected_password)
Static Method

source code 

Extracts a scheme and a password from the expected_password.

Parameters:
  • expected_password (str) - Username and password encoded as Base64
Returns: (str, str)
A tuple containing a scheme and a password. Both values will be None when an invalid scheme or password encoded

VerifyBasicAuthPassword(username, password, expected, realm)
Static Method

source code 

Checks the password for basic authentication.

As long as they don't start with an opening brace ("{"), old passwords are supported. A new scheme uses H(A1) from RFC2617, where H is MD5 and A1 consists of the username, the authentication realm and the actual password.

Parameters:
  • username (string) - Username from HTTP headers
  • password (string) - Password from HTTP headers
  • expected (string) - Expected password with optional scheme prefix (e.g. from users file)
  • realm (string) - Authentication realm