From 89bd1cb350d03bbe312f6a1c94984e45540c5826 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Sat, 19 Jan 2019 19:39:38 -0800 Subject: Authentication now works --- src/auth.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/auth.h (limited to 'src/auth.h') diff --git a/src/auth.h b/src/auth.h new file mode 100644 index 0000000..462e77b --- /dev/null +++ b/src/auth.h @@ -0,0 +1,35 @@ +/* + * auth.h + * + * Handles all authentication events via PAM + * Created by buzzert 2019-01-19 + */ + +#pragma once + +typedef struct { + char *response_buffer; + int response_code; +} auth_prompt_response_t; + +// NOTE: These callbacks are called on a separate thread +typedef void(*ShowInfo)(const char *info_msg, void *context); +typedef void(*ShowError)(const char *error_msg, void *context); +typedef void(*PromptUser)(const char *prompt, void *context); +typedef void(*AuthenticationResult)(int result, void *context); + +typedef struct { + ShowInfo info_handler; + ShowError error_handler; + PromptUser prompt_handler; + AuthenticationResult result_handler; +} auth_callbacks_t; + +struct auth_handle_t; + +// Starts an authentication thread and returns immediately +struct auth_handle_t* auth_begin_authentication(auth_callbacks_t callbacks, void *context); + +// Perform an authentication attempt +void auth_attempt_authentication(struct auth_handle_t *handle, auth_prompt_response_t response); + -- cgit v1.3-2-g11bf