summaryrefslogtreecommitdiff
path: root/src/sessions.h
blob: 9c084e0d8e313a71323b88569151f5dc90b930bb (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
29
30
#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);
/* Ends every session of user_id except keep_id; returns how many. */
int sessions_destroy_user(int64_t user_id, const char *keep_id);
void sessions_free_all(void);

#endif