Liberator Auth API  7.1.17.30459-c265fec
exampleauth.c

This is a simple example of a Liberator Auth Module. This module permits access to any user, and permits them access to any object.

#include <string.h>
#include "rttpd.h"
#ifndef WIN32
#include <unistd.h>
#else
#include <stdio.h>
#include <windows.h>
#endif
#ifndef WIN32
#define DLLEXPORT
#else
#define DLLEXPORT _declspec(dllexport)
#endif
int DLLEXPORT example_auth_new_user(session_t *session, char *user, char *pass);
int DLLEXPORT example_auth_free_user(session_t *session);
int DLLEXPORT example_auth_new_object(object_t *obj, object_t *parent);
int DLLEXPORT example_auth_free_object(object_t *obj);
int DLLEXPORT example_auth_check_read(session_t *session, object_t *obj, char *requested_name);
int DLLEXPORT example_auth_check_write(session_t *session, object_t *obj, char *requested_name);
int DLLEXPORT example_auth_map_object(session_t *session,char *requested_name, char *name, char *mapped, int *len);
int DLLEXPORT example_auth_request_object(session_t *session, object_t *obj);
int DLLEXPORT example_auth_discard_object(session_t *session, object_t *obj);
int DLLEXPORT example_auth_http_request(char *user, char *pass, http_method_t method, char *path);
int DLLEXPORT example_auth_check_update(session_t *session, object_t *obj, char *data);
void DLLEXPORT example_auth_exit();
static eventcallback_t eventcallback;
void DLLEXPORT
auth_mod_init(nodeinfo_t *nodeinfo, authfuncs_t *funcs, eventcallback_t callback)
{
eventcallback = callback;
funcs->auth_new_user = example_auth_new_user;
funcs->auth_free_user = example_auth_free_user;
funcs->auth_new_object = example_auth_new_object;
funcs->auth_free_object = example_auth_free_object;
funcs->auth_check_read = example_auth_check_read;
funcs->auth_check_write = example_auth_check_write;
funcs->auth_map_object = example_auth_map_object;
funcs->auth_request_object = example_auth_request_object;
funcs->auth_discard_object = example_auth_discard_object;
funcs->auth_http_request = example_auth_http_request;
funcs->auth_check_update = example_auth_check_update;
funcs->auth_exit = example_auth_exit;
}
void DLLEXPORT
example_auth_exit()
{
return;
}
int DLLEXPORT
example_auth_new_user(session_t *session, char *user, char *pass)
{
return AUTH_OK;
}
int DLLEXPORT
example_auth_free_user(session_t *session)
{
return AUTH_OK;
}
int DLLEXPORT
example_auth_new_object(object_t *obj, object_t *parent)
{
return AUTH_OK;
}
int DLLEXPORT
example_auth_free_object(object_t *obj)
{
return AUTH_OK;
}
int DLLEXPORT
example_auth_check_read(session_t *session, object_t *obj, char *requested_name)
{
return AUTH_OK;
}
int DLLEXPORT
example_auth_check_write(session_t *session, object_t *obj, char *requested_name)
{
return AUTH_OK;
}
int DLLEXPORT
example_auth_map_object(session_t *session,char *requested_name, char *name, char *mapped, int *len)
{
return AUTH_FALSE;
}
int DLLEXPORT
example_auth_request_object(session_t *session, object_t *obj)
{
return AUTH_OK;
}
int DLLEXPORT
example_auth_discard_object(session_t *session, object_t *obj)
{
return AUTH_OK;
}
int DLLEXPORT
example_auth_http_request(char *user, char *pass, http_method_t method, char *path)
{
return AUTH_OK;
}
int DLLEXPORT
example_auth_check_update(session_t *session, object_t *obj, char *data)
{
return AUTH_OK;
}
#ifdef WIN32
int __stdcall
DllMain()
{
return 1;
}
#endif /* WIN32 */

Generated on Thu Jan 14 2021 15:35:00 for Liberator Auth API