Soup.AuthDomain¶
| Subclasses: | Soup.AuthDomainBasic, Soup.AuthDomainDigest |
|---|
Methods¶
| Inherited: | GObject.Object (37) |
|---|---|
| Structs: | GObject.ObjectClass (5) |
accepts (msg) |
|
add_path (path) |
|
challenge (msg) |
|
check_password (msg, username, password) |
|
covers (msg) |
|
get_realm () |
|
remove_path (path) |
|
set_filter (filter, *filter_data) |
|
set_generic_auth_callback (auth_callback, *auth_data) |
|
try_generic_auth_callback (msg, username) |
Virtual Methods¶
| Inherited: | GObject.Object (7) |
|---|
do_accepts (msg, header) |
|
do_challenge (msg) |
|
do_check_password (msg, username, password) |
Properties¶
| Name | Type | Flags | Short Description |
|---|---|---|---|
add-path |
str |
w | Add a path covered by this auth domain |
filter |
int |
r/w | A filter for deciding whether or not to require authentication |
filter-data |
int |
r/w | Data to pass to filter |
generic-auth-callback |
int |
r/w | An authentication callback that can be used with any Soup.AuthDomain subclass |
generic-auth-data |
int |
r/w | Data to pass to auth callback |
proxy |
bool |
r/w/co | Whether or not this is a proxy auth domain |
realm |
str |
r/w/co | The realm of this auth domain |
remove-path |
str |
w | Remove a path covered by this auth domain |
Signals¶
| Inherited: | GObject.Object (1) |
|---|
Class Details¶
-
class
Soup.AuthDomain(**kwargs)¶ Bases: GObject.ObjectAbstract: Yes Structure: Soup.AuthDomainClass-
accepts(msg)¶ Parameters: msg ( Soup.Message) – aSoup.MessageReturns: the username that msg has authenticated as, if in fact it has authenticated. Noneotherwise.Return type: strorNoneChecks if msg contains appropriate authorization for self to accept it. Mirroring
Soup.AuthDomain.covers(), this does not check whether or not self cares if msg is authorized.This is used by
Soup.Serverinternally and is probably of no use to anyone else.
-
add_path(path)¶ Parameters: path ( str) – the path to add to selfAdds path to self, such that requests under path on self’s server will require authentication (unless overridden by
Soup.AuthDomain.remove_path() orSoup.AuthDomain.set_filter()).You can also add paths by setting the
Soup.AUTH_DOMAIN_ADD_PATHproperty, which can also be used to add one or more paths at construct time.
-
challenge(msg)¶ Parameters: msg ( Soup.Message) – aSoup.MessageAdds a “WWW-Authenticate” or “Proxy-Authenticate” header to msg, requesting that the client authenticate, and sets msg’s status accordingly.
This is used by
Soup.Serverinternally and is probably of no use to anyone else.
-
check_password(msg, username, password)¶ Parameters: - msg (
Soup.Message) – aSoup.Message - username (
str) – a username - password (
str) – a password
Returns: whether or not the message is authenticated
Return type: Checks if msg authenticates to self via username and password. This would normally be called from a
Soup.AuthDomainGenericAuthCallback.- msg (
-
covers(msg)¶ Parameters: msg ( Soup.Message) – aSoup.MessageReturns: Trueif self requires msg to be authenticatedReturn type: boolChecks if self requires msg to be authenticated (according to its paths and filter function). This does not actually look at whether msg is authenticated, merely whether or not it needs to be.
This is used by
Soup.Serverinternally and is probably of no use to anyone else.
-
remove_path(path)¶ Parameters: path ( str) – the path to remove from selfRemoves path from self, such that requests under path on self’s server will NOT require authentication.
This is not simply an undo-er for
Soup.AuthDomain.add_path(); it can be used to “carve out” a subtree that does not require authentication inside a hierarchy that does. Note also that unlike withSoup.AuthDomain.add_path(), this cannot be overridden by adding a filter, as filters can only bypass authentication that would otherwise be required, not require it where it would otherwise be unnecessary.You can also remove paths by setting the
Soup.AUTH_DOMAIN_REMOVE_PATHproperty, which can also be used to remove one or more paths at construct time.
-
set_filter(filter, *filter_data)¶ Parameters: - filter (
Soup.AuthDomainFilter) – the auth filter for self - filter_data (
objectorNone) – data to pass to filter
Adds filter as an authentication filter to self. The filter gets a chance to bypass authentication for certain requests that would otherwise require it. Eg, it might check the message’s path in some way that is too complicated to do via the other methods, or it might check the message’s method, and allow GETs but not PUTs.
The filter function returns
Trueif the request should still require authentication, orFalseif authentication is unnecessary for this request.To help prevent security holes, your filter should return
Trueby default, and only returnFalseunder specifically-tested circumstances, rather than the other way around. Eg, in the example above, where you want to authenticate PUTs but not GETs, you should check if the method is GET and returnFalsein that case, and then returnTruefor all other methods (rather than returningTruefor PUT andFalsefor all other methods). This way if it turned out (now or later) that some paths supported additional methods besides GET and PUT, those methods would default to being NOT allowed for unauthenticated users.You can also set the filter by setting the
Soup.AUTH_DOMAIN_FILTERandSoup.AUTH_DOMAIN_FILTER_DATAproperties, which can also be used to set the filter at construct time.- filter (
-
set_generic_auth_callback(auth_callback, *auth_data)¶ Parameters: - auth_callback (
Soup.AuthDomainGenericAuthCallback) – the auth callback - auth_data (
objectorNone) – data to pass to auth_callback
Sets auth_callback as an authentication-handling callback for self. Whenever a request comes in to self which cannot be authenticated via a domain-specific auth callback (eg,
Soup.AuthDomainDigestAuthCallback), the generic auth callback will be invoked. SeeSoup.AuthDomainGenericAuthCallbackfor information on what the callback should do.- auth_callback (
-
try_generic_auth_callback(msg, username)¶ Parameters: - msg (
Soup.Message) – - username (
str) –
Return type: - msg (
-
do_accepts(msg, header) virtual¶ Parameters: - msg (
Soup.Message) – - header (
str) –
Return type: - msg (
-
do_challenge(msg) virtual¶ Parameters: msg ( Soup.Message) – aSoup.MessageReturn type: strAdds a “WWW-Authenticate” or “Proxy-Authenticate” header to msg, requesting that the client authenticate, and sets msg’s status accordingly.
This is used by
Soup.Serverinternally and is probably of no use to anyone else.
-
do_check_password(msg, username, password) virtual¶ Parameters: - msg (
Soup.Message) – aSoup.Message - username (
str) – a username - password (
str) – a password
Returns: whether or not the message is authenticated
Return type: Checks if msg authenticates to domain via username and password. This would normally be called from a
Soup.AuthDomainGenericAuthCallback.- msg (
-
Property Details¶
-
Soup.AuthDomain.props.add_path¶ Name: add-pathType: strDefault Value: NoneFlags: WRITABLEAdd a path covered by this auth domain
-
Soup.AuthDomain.props.filter¶ Name: filterType: intDefault Value: NoneFlags: READABLE,WRITABLEThe
Soup.AuthDomainFilterfor the domain
-
Soup.AuthDomain.props.filter_data¶ Name: filter-dataType: intDefault Value: NoneFlags: READABLE,WRITABLEData to pass to filter
-
Soup.AuthDomain.props.generic_auth_callback¶ Name: generic-auth-callbackType: intDefault Value: NoneFlags: READABLE,WRITABLEThe
Soup.AuthDomainGenericAuthCallbackfor the domain
-
Soup.AuthDomain.props.generic_auth_data¶ Name: generic-auth-dataType: intDefault Value: NoneFlags: READABLE,WRITABLEData to pass to auth callback
-
Soup.AuthDomain.props.proxy¶ Name: proxyType: boolDefault Value: FalseFlags: READABLE,WRITABLE,CONSTRUCT_ONLYWhether or not this is a proxy auth domain