summaryrefslogtreecommitdiff
path: root/src/auth.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/auth.h')
-rw-r--r--src/auth.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/auth.h b/src/auth.h
new file mode 100644
index 0000000..630d8dc
--- /dev/null
+++ b/src/auth.h
@@ -0,0 +1,19 @@
+#ifndef BOKF_AUTH_H
+#define BOKF_AUTH_H
+
+#include <sqlite3.h>
+#include <stdint.h>
+
+#define AUTH_TOKEN_PREFIX "bokf_"
+
+int auth_hash_password(const char *pw, char **out_phc);
+int auth_verify_password(const char *phc, const char *pw);
+void auth_hash_token(const char *token, unsigned char out[32]);
+char *auth_generate_token(void);
+
+/* Returns user id > 0, -1 if not found, -2 on database error. */
+int64_t auth_user_lookup(sqlite3 *db, const char *username, char **out_pwhash,
+ char **out_display, int *out_is_admin,
+ int *out_disabled);
+
+#endif