1
0
mirror of https://github.com/falk-werner/webfuse synced 2025-06-02 07:24:13 +00:00

adds userdb for authentication purposes

This commit is contained in:
Falk Werner 2019-03-31 21:31:37 +02:00
parent 81fb090537
commit 9c5e56368f
2 changed files with 9 additions and 17 deletions

View File

@ -213,9 +213,9 @@ add_executable(webfused
example/daemon/main.c
)
target_link_libraries(webfused PUBLIC webfuse-adapter ${EXTRA_LIBS})
target_link_libraries(webfused PUBLIC webfuse-adapter userdb ${OPENSSL_LIBRARIES} ${EXTRA_LIBS})
target_include_directories(webfused PUBLIC ${EXTRA_INCLUDE_DIRS})
target_compile_options(webfused PUBLIC ${EXTRA_CFLAGS})
target_compile_options(webfused PUBLIC ${C_WARNINGS} ${OPENSSL_CFLAGS_OTHER} ${EXTRA_CFLAGS})
# provider

View File

@ -7,9 +7,9 @@
#include <unistd.h>
#include <getopt.h>
#include <jansson.h>
#include <webfuse_adapter.h>
#include <userdb.h>
struct args
@ -50,24 +50,16 @@ static bool authenticate(struct wf_credentials * creds, void * user_data)
char const * password = wf_credentials_get(creds, "password");
if ((NULL != username) && (NULL != password))
{
json_t * passwd = json_load_file(args->passwd_path, 0, NULL);
if (NULL != passwd)
struct userdb * db = userdb_create("<pepper>");
result = userdb_load(db, args->passwd_path);
if (result)
{
json_t * user = json_object_get(passwd, username);
if (json_is_object(user))
{
json_t * password_holder = json_object_get(user, "password");
if (json_is_string(password_holder))
{
result = (0 == strcmp(password, json_string_value(password_holder)));
}
}
json_decref(passwd);
result = userdb_check(db, username, password);
userdb_dispose(db);
}
}
return result;
return result;
}
static int parse_arguments(int argc, char * argv[], struct args * args)