#ifndef KEYFILE_AUTH_H
#define KEYFILE_AUTH_H
#include "../public/auth.h"
#include <ucx/map.h>
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct keyfile Keyfile;
typedef struct keyfile_user KeyfileUser;
enum KeyfileHashType {
KEYFILE_SSHA =
0,
KEYFILE_SSHA256,
KEYFILE_SSHA512
};
struct keyfile {
AuthDB authdb;
UcxMap *users;
uint32_t ref;
};
struct keyfile_user {
User user;
sstr_t *groups;
size_t numgroups;
enum KeyfileHashType hash_type;
char *hash;
size_t hashlen;
};
Keyfile* keyfile_new();
void keyfile_ref(Keyfile *keyfile);
void keyfile_unref(Keyfile *keyfile);
void keyfile_add_user(
Keyfile *keyfile,
sstr_t user,
enum KeyfileHashType hash_type,
sstr_t hash,
sstr_t *groups,
size_t ngroups);
User* keyfile_get_user(AuthDB *db,
char *user);
int keyfile_user_verify_password(User *user,
char *password);
int keyfile_user_check_group(User *user,
char *group);
void keyfile_user_free(User *user);
int ssha_verify(KeyfileUser *user,
char *password);
#ifdef __cplusplus
}
#endif
#endif