2 * Sub-authentication Daemon
4 * (c) 2017 Martin Mares <mj@ucw.cz>
11 #include <ucw/clists.h>
12 #include <ucw/mainloop.h>
13 #include <ucw-json/json.h>
15 #define SOCKET_TIMEOUT 60000 // in ms
16 #define MAX_PACKET_SIZE 16384
17 #define MAX_OOB_DATA_SIZE 4096
20 struct main_file socket;
21 struct main_timer timer;
23 struct json_context *json;
24 struct json_node *request;
25 struct json_node *reply;
28 extern clist zone_list; // of struct auth_zone
29 extern char *database_name;
33 void cmd_dispatch(struct client *c);
35 const char *get_string(struct json_node *n, const char *key);
36 bool get_uint(struct json_node *n, const char *key, uint *dest);
37 struct json_node **get_array(struct json_node *n, const char *key);
38 struct json_node *get_object(struct json_node *n, const char *key);
45 uint auto_create_acct;
51 clist accounts; // of struct auth_acct
57 struct auth_user *user;
58 struct auth_zone *zone;
59 clist tokens; // of struct auth_token
70 struct auth_acct *acct;
80 struct auth_zone *auth_find_zone(const char *name);
81 struct auth_user *auth_find_user(const char *login, bool create);
82 struct auth_acct *auth_find_acct(struct auth_user *au, struct auth_zone *az, bool create);
83 void auth_delete_user(struct auth_user *au);
84 void auth_delete_acct(struct auth_acct *aa);
85 void auth_delete_token(struct auth_token *at);
86 struct auth_token *auth_create_token(struct auth_acct *aa);
87 void auth_set_token_passwd(struct auth_token *at, const char *passwd);