Easy Publish and Consume Reference Manual | ||||
---|---|---|---|---|
#include <libepc/publish.h> gboolean (*EpcAuthHandler) (EpcAuthContext *context, const gchar *username, gpointer user_data); EpcAuthContext; gboolean epc_auth_context_check_password (EpcAuthContext *context, const gchar *password); const gchar* epc_auth_context_get_key (EpcAuthContext *context); EpcPublisher* epc_auth_context_get_publisher (EpcAuthContext *context);
With each request the EpcPublisher verifies access authorization by calling the EpcAuthHandler registered for the key in question, if any. Information about that process is stored in the EpcAuthContext structure.
To register an authentication handler call ""
Example 4. Register an authentication handler
epc_publisher_set_auth_handler (publisher, "sensitive-key", my_auth_handler, my_object);
To verify that the user password provided password matches the expected one use ""
Example 5. Verify a password
static gboolean my_auth_handler (EpcAuthContext *context, const gchar *username, gpointer user_data) { MyObject *self = user_data; const gchar *expected_password; const gchar *requested_key; requested_key = epc_auth_context_get_key (context); expected_password = lookup_password (self, requested_key); return epc_auth_context_check_password (context, expected_password); }
gboolean (*EpcAuthHandler) (EpcAuthContext *context, const gchar *username, gpointer user_data);
Functions implementing this callback shall return TRUE
when the
credentials provided by the authentication request grant access
to the resource described by context
.
The username
is NULL
when no creditials were passed, and anonymous access
is tried. When a username
was passed call epc_auth_context_check_password
to verify that the password passed in the request matches the known password
for that user.
There is no way to retrieve the password from the EpcAuthContext, as the network protocol transfers just a hash code, not the actual password.
context : |
the EpcAuthContext |
username : |
the username provided for authentication, or NULL
|
user_data : |
user data set when the signal handler was installed |
Returns : | TRUE when access is granted, and FALSE otherwise.
|
typedef struct _EpcAuthContext EpcAuthContext;
This data structure describes a pending authentication request which shall be verified by an EpcAuthHandler installed by epc_publisher_set_auth_handler.
There is no way to retrieve the password from the EpcAuthContext, as the network protocol transfers just a hash code, not the actual password.
gboolean epc_auth_context_check_password (EpcAuthContext *context, const gchar *password);
Verifies that the password supplied with the network request matches
the password
the application expects. There is no way to retrieve the
password from the EpcAuthContext, as the network protocol transfers
just a hash code, not the actual password.
context : |
a EpcAuthContext |
password : |
the expected password |
Returns : | TRUE when the sent password matches, or FALSE otherwise.
|
const gchar* epc_auth_context_get_key (EpcAuthContext *context);
Queries the resource key assosiated with the authentication context
.
context : |
a EpcAuthContext |
Returns : | The resource key. |
EpcPublisher* epc_auth_context_get_publisher (EpcAuthContext *context);
Queries the EpcPublisher owning the authentication context
.
context : |
a EpcAuthContext |
Returns : | The owning EpcPublisher. |