#ifndef AUTH_H
#define AUTH_H
#include <sys/types.h>
#include <inttypes.h>
#include "../public/auth.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
User user;
char *authdb;
sstr_t *groups;
size_t numgroups;
char *password;
uint32_t ref;
} CachedUser;
typedef struct user_cache_elm UserCacheElm;
struct user_cache_elm {
CachedUser *user;
UserCacheElm *next_user;
UcxKey key;
size_t slot;
UserCacheElm *next_elm;
time_t created;
};
typedef struct {
UserCacheElm **map;
size_t size;
size_t count;
size_t max_users;
UserCacheElm *head;
UserCacheElm *trail;
} UserCache;
void auth_cache_init();
User* auth_cache_get(
char *authdb,
char *user);
void auth_cache_add(
char *authdb,
User *user,
char *password,
char **groups,
size_t numgroups);
void auth_cache_remove_from_map(UserCacheElm *elm);
int cached_user_verify_password(CachedUser *user,
char *password);
int cached_user_check_group(CachedUser *user,
char *group);
void cached_user_unref(CachedUser *user);
void cached_user_delete(CachedUser *user);
#ifdef __cplusplus
}
#endif
#endif