mirror of
https://github.com/falk-werner/webfused
synced 2026-03-02 04:09:19 +00:00
parse authentication settings
This commit is contained in:
8
src/webfused/auth/authenticator.c
Normal file
8
src/webfused/auth/authenticator.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "webfused/auth/authenticator.h"
|
||||
|
||||
void
|
||||
wfd_authenticator_dispose(
|
||||
struct wfd_authenticator authenticator)
|
||||
{
|
||||
authenticator.vtable->dispose(authenticator.data);
|
||||
}
|
||||
36
src/webfused/auth/authenticator.h
Normal file
36
src/webfused/auth/authenticator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef WFD_AUTH_AUTHENTICATOR_H
|
||||
#define WFD_AUTH_AUTHENTICATOR_H
|
||||
|
||||
#include "webfuse/adapter/authenticate.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef void
|
||||
wfd_authenticator_dispose_fn(
|
||||
void * data);
|
||||
|
||||
struct wfd_authenticator_vtable
|
||||
{
|
||||
wfd_authenticator_dispose_fn * dispose;
|
||||
wf_authenticate_fn * authenticate;
|
||||
};
|
||||
|
||||
struct wfd_authenticator
|
||||
{
|
||||
struct wfd_authenticator_vtable const * vtable;
|
||||
void * data;
|
||||
};
|
||||
|
||||
extern void
|
||||
wfd_authenticator_dispose(
|
||||
struct wfd_authenticator authenticator);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
25
src/webfused/auth/factory.c
Normal file
25
src/webfused/auth/factory.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "webfused/auth/factory.h"
|
||||
#include "webfused/auth/settings.h"
|
||||
#include "webfused/auth/file_authenticator.h"
|
||||
#include "webfused/log/log.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
bool
|
||||
wfd_authenticator_create(
|
||||
struct wfd_auth_settings * settings,
|
||||
struct wfd_authenticator * authenticator)
|
||||
{
|
||||
bool result = false;
|
||||
char const * provider_name = wfd_auth_settings_get_provider(settings);
|
||||
if (0 == strcmp("file", provider_name))
|
||||
{
|
||||
result = wfd_file_authenticator_create(settings, authenticator);
|
||||
}
|
||||
else
|
||||
{
|
||||
WFD_ERROR("failed to create authenticator: unknown type \"%s\"", provider_name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
25
src/webfused/auth/factory.h
Normal file
25
src/webfused/auth/factory.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef WFD_AUTHENTICATION_FACTORY_H
|
||||
#define WFD_AUTHENTICATION_FACTORY_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct wfd_authenticator;
|
||||
struct wfd_auth_settings;
|
||||
|
||||
extern bool
|
||||
wfd_authenticator_create(
|
||||
struct wfd_auth_settings * settings,
|
||||
struct wfd_authenticator * authenticator);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
9
src/webfused/auth/file_authenticator.c
Normal file
9
src/webfused/auth/file_authenticator.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "webfused/auth/file_authenticator.h"
|
||||
|
||||
bool
|
||||
wfd_file_authenticator_create(
|
||||
struct wfd_auth_settings * settings,
|
||||
struct wfd_authenticator * authenticator)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
26
src/webfused/auth/file_authenticator.h
Normal file
26
src/webfused/auth/file_authenticator.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef WFD_AUTH_FILE_AUTHENTICATOR_H
|
||||
#define WFD_AUTH_FILE_AUTHENTICATOR_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct wfd_authenticator;
|
||||
struct wfd_auth_settings;
|
||||
|
||||
extern bool
|
||||
wfd_file_authenticator_create(
|
||||
struct wfd_auth_settings * settings,
|
||||
struct wfd_authenticator * authenticator);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
30
src/webfused/auth/settings.h
Normal file
30
src/webfused/auth/settings.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef WFD_AUTH_SETTINGS_H
|
||||
#define WFD_AUTH_SETTINGS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct wfd_auth_settings;
|
||||
|
||||
|
||||
extern char const *
|
||||
wfd_auth_settings_get_provider(
|
||||
struct wfd_auth_settings * settings);
|
||||
|
||||
extern char const *
|
||||
wfd_auth_settings_get(
|
||||
struct wfd_auth_settings * settings,
|
||||
char const * key);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user