/* webui_store.h — SQLite-backed persistence for all web-UI-owned state: * accounts, the category/tag taxonomy, and RSS feeds/rules/indexers. * * Owned entirely by the webui plugin (the daemon persists none of this). * Account passwords are PBKDF2-HMAC-SHA256 with a per-user random salt. All * calls are thread-safe (the store serializes access to its SQLite handle). */ #ifndef NAUT_WEBUI_STORE_H #define NAUT_WEBUI_STORE_H #include #include #include typedef struct webui_store webui_store; /* Open (creating if needed) the account database at `path`. Returns NULL on * failure. The schema is created/migrated on open. */ webui_store *webui_store_open(const char *path); void webui_store_close(webui_store *s); /* Number of accounts, or -1 on error. */ int webui_store_user_count(webui_store *s); /* Number of admin accounts, or -1 on error. */ int webui_store_admin_count(webui_store *s); bool webui_store_user_exists(webui_store *s, const char *username); /* Verify a username/password pair (constant-time). On success, copies the * account's role ("admin"/"user") into role_out. */ bool webui_store_verify(webui_store *s, const char *username, const char *password, char *role_out, size_t role_sz); /* Create an account. `role` must be "admin" or "user" (defaults to "user" if * NULL/invalid). Returns false if the username already exists or on error. */ bool webui_store_create_user(webui_store *s, const char *username, const char *password, const char *role); bool webui_store_set_password(webui_store *s, const char *username, const char *password); /* Change an account's role ("admin"/"user"). */ bool webui_store_set_role(webui_store *s, const char *username, const char *role); bool webui_store_delete_user(webui_store *s, const char *username); /* Append {username, role, createdAt} objects (sorted by username) to the * json array `out`. Returns false on error. */ bool webui_store_list_users(webui_store *s, json_t *out); #endif /* NAUT_WEBUI_STORE_H */