Skip to content

Commit

Permalink
protocol: check basic auth on ws connection
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Aug 8, 2021
1 parent 8a75364 commit 1e5c524
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/protocol.c
Expand Up @@ -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)
Expand Down

0 comments on commit 1e5c524

Please sign in to comment.