1
0
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:
Falk Werner
2020-03-16 21:50:31 +01:00
parent fab2545df1
commit 2e81b8c23d
20 changed files with 464 additions and 39 deletions

View File

@@ -0,0 +1,8 @@
#include "webfused/auth/authenticator.h"
void
wfd_authenticator_dispose(
struct wfd_authenticator authenticator)
{
authenticator.vtable->dispose(authenticator.data);
}

View 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

View 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;
}

View 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

View 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;
}

View 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

View 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