aboutsummaryrefslogtreecommitdiff
path: root/src/sessions.h
blob: d573b23889d80031f016750bda48ca84b982e572 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef BOKF_SESSIONS_H
#define BOKF_SESSIONS_H

#include <stdint.h>

struct session {
    char id[64];
    int64_t user_id;
    int is_admin;
    int64_t active_org;
    int64_t bound_org; /* token sessions are bound to one org; 0 = none */
    int64_t token_id;  /* api token used to open the session, 0 for password */
    char scopes[32];
    int64_t created;
    int64_t last_seen;
    int64_t expires;
    struct session *next;
};

void sessions_init(long ttl_seconds);
struct session *sessions_create(int64_t user_id, int is_admin,
                                int64_t active_org, int64_t bound_org,
                                const char *scopes);
struct session *sessions_get(const char *id);
void sessions_destroy(const char *id);
void sessions_free_all(void);

#endif