diff options
| author | default <nobody@localhost> | 2024-11-12 09:01:30 +0100 |
|---|---|---|
| committer | default <nobody@localhost> | 2024-11-12 09:01:30 +0100 |
| commit | 19b9998f8c42918430f7c41ebd40b8339b9d7cd7 (patch) | |
| tree | 8e2a88f826cc8bf61878f50292d68d1b21597915 /data.c | |
| parent | 50fa2ae0e620b813e2eab3b6a89efdf171d7856e (diff) | |
The proxy token seed is created on startup and never stored.
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 17 |
1 files changed, 4 insertions, 13 deletions
@@ -165,21 +165,12 @@ int srv_open(const char *basedir, int auto_upgrade) write_default_css(); } - /* if proxy_media is set but there is no token seed, create one */ - if (xs_is_true(xs_dict_get(srv_config, "proxy_media")) && - xs_is_null(xs_dict_get(srv_config, "proxy_token_seed"))) { + /* create the proxy token seed */ + { char rnd[16]; xs_rnd_buf(rnd, sizeof(rnd)); - xs *pts = xs_hex_enc(rnd, sizeof(rnd)); - - xs_dict_set(srv_config, "proxy_token_seed", pts); - if ((f = fopen(cfg_file, "w")) != NULL) { - xs_json_dump(srv_config, 4, f); - fclose(f); - - srv_log(xs_fmt("Created proxy_token_seed")); - } + srv_proxy_token_seed = xs_hex_enc(rnd, sizeof(rnd)); } return ret; @@ -3679,7 +3670,7 @@ xs_str *make_url(const char *href, const char *proxy, int by_token) xs *p = NULL; if (by_token) { - xs *tks = xs_fmt("%s:%s", xs_dict_get(srv_config, "proxy_token_seed"), proxy); + xs *tks = xs_fmt("%s:%s", srv_proxy_token_seed, proxy); xs *tk = xs_md5_hex(tks, strlen(tks)); p = xs_fmt("%s/y/%s/", proxy, tk); |