Skip to content

Commit ad62287

Browse files
committed
Add digest auth algorithm config option
1 parent eeab41a commit ad62287

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

mos.yml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ config_schema:
2020
- ["http.hidden_files", "s", {title: "Hidden file pattern"}]
2121
- ["http.auth_domain", "s", {title: "Enable authentication of all HTTP requests"}]
2222
- ["http.auth_file", "s", {title: "Password file to use for auth"}]
23+
- ["http.auth_algo", "i", 0, {title: "Password file hashing algorithm: 0 - MD5, 1 - SHA256"}]
2324
- ["http.extra_headers", "s", {title: "Extra headers to send with every file served"}]
2425

2526
cdefs:

src/mgos_http_server.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,8 @@ bool mgos_http_server_init(void) {
309309
mgos_sys_config_get_http_hidden_files();
310310
s_http_server_opts.auth_domain = mgos_sys_config_get_http_auth_domain();
311311
s_http_server_opts.global_auth_file = mgos_sys_config_get_http_auth_file();
312+
s_http_server_opts.auth_algo =
313+
(enum mg_auth_algo) mgos_sys_config_get_http_auth_algo();
312314
s_http_server_opts.extra_headers = mgos_sys_config_get_http_extra_headers();
313315
#endif
314316

@@ -398,11 +400,12 @@ void mgos_register_http_endpoint_opt(const char *uri_path,
398400

399401
void mgos_register_http_endpoint(const char *uri_path,
400402
mg_event_handler_t handler, void *user_data) {
401-
struct mg_http_endpoint_opts opts;
402-
memset(&opts, 0, sizeof(opts));
403-
opts.user_data = user_data;
404-
opts.auth_domain = mgos_sys_config_get_http_auth_domain();
405-
opts.auth_file = mgos_sys_config_get_http_auth_file();
403+
struct mg_http_endpoint_opts opts = {
404+
.user_data = user_data,
405+
.auth_domain = mgos_sys_config_get_http_auth_domain(),
406+
.auth_file = mgos_sys_config_get_http_auth_file(),
407+
.auth_algo = mgos_sys_config_get_http_auth_algo(),
408+
};
406409
mgos_register_http_endpoint_opt(uri_path, handler, opts);
407410
}
408411

0 commit comments

Comments
 (0)