mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-30 15:34:24 +01:00
html: use api to fetch auth token
This commit is contained in:
16853
src/html.h
16853
src/html.h
File diff suppressed because it is too large
Load Diff
@@ -149,15 +149,15 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, voi
|
||||
p = buffer + LWS_PRE;
|
||||
end = p + sizeof(buffer) - LWS_PRE;
|
||||
|
||||
if (strncmp(pss->path, "/auth_token.js", 14) == 0) {
|
||||
if (strncmp(pss->path, "/token", 6) == 0) {
|
||||
const char *credential = server->credential != NULL ? server->credential : "";
|
||||
size_t n = sprintf(buf, "var tty_auth_token = '%s';\n", credential);
|
||||
size_t n = sprintf(buf, "{\"token\": \"%s\"}", credential);
|
||||
if (lws_add_http_header_status(wsi, HTTP_STATUS_OK, &p, end))
|
||||
return 1;
|
||||
if (lws_add_http_header_by_token(wsi,
|
||||
WSI_TOKEN_HTTP_CONTENT_TYPE,
|
||||
(unsigned char *) "application/javascript",
|
||||
22, &p, end))
|
||||
(unsigned char *) "application/json;charset=utf-8",
|
||||
30, &p, end))
|
||||
return 1;
|
||||
if (lws_add_http_header_content_length(wsi, (unsigned long) n, &p, end))
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user