summaryrefslogtreecommitdiff
path: root/src/auth.h
blob: 630d8dc8be7e63d0d5f91856934d97112a735c56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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