1
0
mirror of https://github.com/falk-werner/webfused synced 2026-03-02 04:09:19 +00:00

refactor: generalize auth_settings

This commit is contained in:
Falk Werner
2020-03-18 10:17:17 +01:00
parent 609fbee24f
commit 1625869696
28 changed files with 272 additions and 315 deletions

View File

@@ -1,24 +1,24 @@
#include "webfused/auth/factory.h"
#include "webfused/auth/settings.h"
#include "webfused/auth/file_authenticator.h"
#include "webfused/config/settings.h"
#include "webfused/log/log.h"
#include <string.h>
bool
wfd_authenticator_create(
struct wfd_auth_settings * settings,
char const * provider,
struct wfd_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))
if (0 == strcmp("file", provider))
{
result = wfd_file_authenticator_create(settings, authenticator);
}
else
{
WFD_ERROR("failed to create authenticator: unknown type \"%s\"", provider_name);
WFD_ERROR("failed to create authenticator: unknown type \"%s\"", provider);
}
return result;

View File

@@ -11,11 +11,12 @@ extern "C"
#endif
struct wfd_authenticator;
struct wfd_auth_settings;
struct wfd_settings;
extern bool
wfd_authenticator_create(
struct wfd_auth_settings * settings,
char const * provider,
struct wfd_settings * settings,
struct wfd_authenticator * authenticator);
#ifdef __cplusplus

View File

@@ -1,11 +1,11 @@
#include "webfused/auth/file_authenticator.h"
#include "webfused/auth/settings.h"
#include "webfused/auth/authenticator.h"
#include "webfuse/adapter/credentials.h"
#include "webfused/config/settings.h"
#include "userdb/userdb.h"
#include "webfused/log/log.h"
#include <webfuse/adapter/credentials.h>
#include <stdlib.h>
#include <string.h>
@@ -71,12 +71,12 @@ wfd_file_authenticator_vtable =
bool
wfd_file_authenticator_create(
struct wfd_auth_settings * settings,
struct wfd_settings * settings,
struct wfd_authenticator * authenticator)
{
bool result = false;
char const * filename = wfd_auth_settings_get(settings, "file");
char const * filename = wfd_settings_get(settings, "file");
if (NULL != filename)
{
struct wfd_file_authenticator * data = malloc(sizeof(struct wfd_file_authenticator));

View File

@@ -12,11 +12,11 @@ extern "C"
#endif
struct wfd_authenticator;
struct wfd_auth_settings;
struct wfd_settings;
extern bool
wfd_file_authenticator_create(
struct wfd_auth_settings * settings,
struct wfd_settings * settings,
struct wfd_authenticator * authenticator);
#ifdef __cplusplus

View File

@@ -1,30 +0,0 @@
#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