mirror of
https://github.com/tsl0922/ttyd.git
synced 2026-01-04 18:04:22 +01:00
protocol: check basic auth on ws connection
This commit is contained in:
@@ -155,6 +155,10 @@ int callback_tty(struct lws *wsi, enum lws_callback_reasons reason, void *user,
|
||||
lwsl_warn("refuse to serve WS client due to the --max-clients option.\n");
|
||||
return 1;
|
||||
}
|
||||
if (server->credential != NULL) {
|
||||
n = lws_hdr_copy(wsi, buf, sizeof(buf), WSI_TOKEN_HTTP_AUTHORIZATION);
|
||||
if (n < 7 || !strstr(buf, "Basic ") || strcmp(buf +6, server->credential)) return 1;
|
||||
}
|
||||
|
||||
n = lws_hdr_copy(wsi, pss->path, sizeof(pss->path), WSI_TOKEN_GET_URI);
|
||||
#if defined(LWS_ROLE_H2)
|
||||
|
||||
Reference in New Issue
Block a user