![]() |
![]() |
![]() |
libsoup Reference Manual | ![]() |
---|---|---|---|---|
struct SoupAuthDomain; void soup_auth_domain_add_path (SoupAuthDomain *domain, const char *path); void soup_auth_domain_remove_path (SoupAuthDomain *domain, const char *path); gboolean (*SoupAuthDomainFilter) (SoupAuthDomain *domain, SoupMessage *msg, gpointer user_data); void soup_auth_domain_set_filter (SoupAuthDomain *domain, SoupAuthDomainFilter filter, gpointer filter_data, GDestroyNotify dnotify); const char* soup_auth_domain_get_realm (SoupAuthDomain *domain); gboolean soup_auth_domain_covers (SoupAuthDomain *domain, SoupMessage *msg); char* soup_auth_domain_accepts (SoupAuthDomain *domain, SoupMessage *msg); void soup_auth_domain_challenge (SoupAuthDomain *domain, SoupMessage *msg); #define SOUP_AUTH_DOMAIN_REALM #define SOUP_AUTH_DOMAIN_PROXY #define SOUP_AUTH_DOMAIN_ADD_PATH #define SOUP_AUTH_DOMAIN_REMOVE_PATH #define SOUP_AUTH_DOMAIN_FILTER #define SOUP_AUTH_DOMAIN_FILTER_DATA
"add-path" gchararray : Write "filter" gpointer : Read / Write "filter-data" gpointer : Read / Write "generic-auth-callback" gpointer : Read / Write "generic-auth-data" gpointer : Read / Write "proxy" gboolean : Read / Write / Construct Only "realm" gchararray : Read / Write / Construct Only "remove-path" gchararray : Write
A SoupAuthDomain manages authentication for all or part of a
SoupServer. To make a server require authentication, first create
an appropriate subclass of SoupAuthDomain, and then add it to the
server with soup_server_add_auth_domain()
.
In order for an auth domain to have any effect, you must add one or
more paths to it (via soup_auth_domain_add_path()
or the
SOUP_AUTH_DOMAIN_ADD_PATH
property). To require authentication for
all requests, add the path "/".
If you need greater control over which requests should and
shouldn't be authenticated, add paths covering everything you
might want authenticated, and then use a
filter (soup_auth_domain_set_filter()
) to bypass authentication for
those requests that don't need it.
void soup_auth_domain_add_path (SoupAuthDomain *domain, const char *path);
Adds path
to domain
, such that requests under path
on domain
's
server will require authentication (unless overridden by
soup_auth_domain_remove_path()
or soup_auth_domain_set_filter()
).
You can also add paths by setting the SOUP_AUTH_DOMAIN_ADD_PATH
property, which can also be used to add one or more paths at
construct time.
|
a SoupAuthDomain |
|
the path to add to domain
|
void soup_auth_domain_remove_path (SoupAuthDomain *domain, const char *path);
Removes path
from domain
, such that requests under path
on
domain
's server will NOT require authentication.
This is not simply an undo-er for soup_auth_domain_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
with soup_auth_domain_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_PATH
property, which can also be used to
remove one or more paths at construct time.
|
a SoupAuthDomain |
|
the path to remove from domain
|
gboolean (*SoupAuthDomainFilter) (SoupAuthDomain *domain, SoupMessage *msg, gpointer user_data);
The prototype for a SoupAuthDomain filter; see
soup_auth_domain_set_filter()
for details.
|
a SoupAuthDomain |
|
a SoupMessage |
|
the data passed to soup_auth_domain_set_filter()
|
Returns : |
TRUE if msg requires authentication, FALSE if not.
|
void soup_auth_domain_set_filter (SoupAuthDomain *domain, SoupAuthDomainFilter filter, gpointer filter_data, GDestroyNotify dnotify);
Adds filter
as an authentication filter to domain
. 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 TRUE
if the request should still
require authentication, or FALSE
if authentication is unnecessary
for this request.
To help prevent security holes, your filter should return TRUE
by
default, and only return FALSE
under 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 return FALSE
in that case, and then
return TRUE
for all other methods (rather than returning TRUE
for
PUT and FALSE
for 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_FILTER
and SOUP_AUTH_DOMAIN_FILTER_DATA
properties, which can also be
used to set the filter at construct time.
|
a SoupAuthDomain |
|
the auth filter for domain
|
|
data to pass to filter
|
|
destroy notifier to free filter_data when domain
is destroyed
|
const char* soup_auth_domain_get_realm (SoupAuthDomain *domain);
Gets the realm name associated with domain
|
a SoupAuthDomain |
Returns : |
domain 's realm
|
gboolean soup_auth_domain_covers (SoupAuthDomain *domain, SoupMessage *msg);
Checks if domain
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 is needs to
be.
This is used by SoupServer internally and is probably of no use to anyone else.
|
a SoupAuthDomain |
|
a SoupMessage |
Returns : |
TRUE if domain requires msg to be authenticated
|
char* soup_auth_domain_accepts (SoupAuthDomain *domain, SoupMessage *msg);
Checks if msg
contains appropriate authorization for domain
to
accept it. Mirroring soup_auth_domain_covers()
, this does not check
whether or not domain
*cares* if msg
is authorized.
This is used by SoupServer internally and is probably of no use to anyone else.
|
a SoupAuthDomain |
|
a SoupMessage |
Returns : |
the username that msg has authenticated as, if in
fact it has authenticated. NULL otherwise.
|
void soup_auth_domain_challenge (SoupAuthDomain *domain, SoupMessage *msg);
Adds a "WWW-Authenticate" or "Proxy-Authenticate" header to msg
,
requesting that the client authenticate, and sets msg
's status
accordingly.
This is used by SoupServer internally and is probably of no use to anyone else.
|
a SoupAuthDomain |
|
a SoupMessage |
add-path
" property"add-path" gchararray : Write
Add a path covered by this auth domain.
Default value: NULL
filter
" property"filter" gpointer : Read / Write
A filter for deciding whether or not to require authentication.
generic-auth-callback
" property"generic-auth-callback" gpointer : Read / Write
An authentication callback that can be used with any SoupAuthDomain subclass.
generic-auth-data
" property"generic-auth-data" gpointer : Read / Write
Data to pass to auth callback.
proxy
" property"proxy" gboolean : Read / Write / Construct Only
Whether or not this is a proxy auth domain.
Default value: FALSE
realm
" property"realm" gchararray : Read / Write / Construct Only
The realm of this auth domain.
Default value: NULL
remove-path
" property"remove-path" gchararray : Write
Remove a path covered by this auth domain.
Default value: NULL