#ifndef KEYFILE_AUTH_H
#define KEYFILE_AUTH_H
#include "../public/auth.h"
#include <cx/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;
CxMap *users;
};
struct keyfile_user {
User user;
cxmutstr *groups;
size_t numgroups;
enum KeyfileHashType hash_type;
char *hash;
size_t hashlen;
};
Keyfile* keyfile_new(CxAllocator *a);
int keyfile_add_user(
Keyfile *keyfile,
cxmutstr user,
enum KeyfileHashType hash_type,
cxmutstr hash,
cxmutstr *groups,
size_t ngroups);
User* keyfile_get_user(AuthDB *db, Session *sn, Request *rq,
const char *user);
int keyfile_user_verify_password(User *user,
const char *password);
int keyfile_user_check_group(User *user,
const char *group);
void keyfile_user_free(User *user);
int ssha_verify(KeyfileUser *user,
const char *password);
#ifdef __cplusplus
}
#endif
#endif