28
28
#include "frozen.h"
29
29
30
30
#include "mgos_hal.h"
31
+ #include "mgos_sys_config.h"
31
32
32
33
static const char * s_headers =
33
34
"Content-Type: application/json\r\n"
@@ -94,6 +95,7 @@ static bool mg_rpc_channel_http_get_authn_info(
94
95
struct mg_str * hdr ;
95
96
char username_buf [50 ];
96
97
char * username = username_buf ;
98
+ int algo = mgos_sys_config_get_rpc_auth_algo ();
97
99
98
100
if (auth_domain == NULL || auth_file == NULL ) {
99
101
auth_domain = chd -> default_auth_domain ;
@@ -105,7 +107,8 @@ static bool mg_rpc_channel_http_get_authn_info(
105
107
}
106
108
107
109
if (!mg_http_is_authorized (chd -> hm , chd -> hm -> uri , auth_domain , auth_file ,
108
- MG_AUTH_FLAG_IS_GLOBAL_PASS_FILE )) {
110
+ (MG_AUTH_FLAG_IS_GLOBAL_PASS_FILE |
111
+ MG_AUTH_FLAG_ALGO (algo )))) {
109
112
goto clean ;
110
113
}
111
114
@@ -152,9 +155,10 @@ static void mg_rpc_channel_http_send_not_authorized(struct mg_rpc_channel *ch,
152
155
mg_printf (chd -> nc , "Connection: %s\r\n" , "close" );
153
156
mg_printf (chd -> nc ,
154
157
"WWW-Authenticate: Digest "
155
- "qop=\"auth\", realm=\"%s\", nonce=\"%lx\"\r\n"
158
+ "qop=\"auth\", realm=\"%s\", nonce=\"%lx\", algorithm=%s \r\n"
156
159
"\r\n" ,
157
- auth_domain , (unsigned long ) mg_time ());
160
+ auth_domain , (unsigned long ) mg_time (),
161
+ (mgos_sys_config_get_rpc_auth_algo () == MG_AUTH_ALGO_MD5 ? "MD5" : "SHA-256" ));
158
162
159
163
/* We sent a response, the channel is no more. */
160
164
chd -> nc -> flags |= MG_F_SEND_AND_CLOSE ;
0 commit comments