-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When accessing the web-ui-dashboard simultaneously using http/https, the http method does not display correctly. #2912
Comments
I look forward to receiving your reply. Thank you |
Please use HEAD or at least 7.15. We won't fix an obsolete release. |
I believe I have found the reason for the problem When HTTP and HTTPS access the same web server IP through LAN(not localhost), this problem will occurs: The reason is as follows: When there is a cookie under HTTPS, attempting to write a cookie in the same domain under HTTP will fail. The browser prompts: The operation of setting a cookie through the Set-Cookie header is prohibited because this header is not sent over a secure connection, and it will overwrite cookies with the Secure attribute. This also explains why, after accessing HTTPS first, then HTTP access will fail. Because HTTP cannot send the token to the browser using Set-Cookie, causing the HTTP POST request to always send an empty token [], and the authenticate function fails to validate it. |
No screen snapshots, please attach capture files. I can't see TCP traffic on a snapshot. Yes, you can, just zip it. |
@cpq @robertc2000 #2912 (comment) above and next one below.
|
I have updated the last comment. This is the zip file containing the screenshot and pcapng. Additional explanations are as follows: |
Right. Does that mean we need to have two different cookies, one for HTTP and one for HTTPS ? static void handle_login(struct mg_connection *c, struct user *u) {
char cookie[256];
mg_snprintf(cookie, sizeof(cookie),
"Set-Cookie: access_token=%s; Path=/; "
"%sHttpOnly; SameSite=Lax; Max-Age=%d\r\n",
u->access_token, c->is_tls ? "Secure; " : "", 3600 * 24);
mg_http_reply(c, 200, cookie, "{%m:%c%s%M%c}", MG_ESC("user"), '"', c->is_tls ? "s_" : "", MG_ESC(u->name), '"');
} |
@cpq I replaced this code in net.c and still had the same problem, the modified code did not have any effect |
It appears the same cookie name cannot be used both for HTTP and HTTPS simultaneous connections. Doing this will show the following console log on the HTTP tab.
The solution is to have different cookie names for HTTP and HTTPS to avoid any conflict.
@halikuosang Could you please try using the above handle_login function? Let us know if this fixes your issue. |
My goal is:
Mongoose supports using http/https to open the web-ui-dashboard simultaneously and display the same content.
My actions were:
Added CFLAGS_EXTRA = -DMG_TLS=MG_TLS_BUILTIN in the web-ui-dashboard Makefile and compiled and run it.
http uses port 8000.
https uses port 8443.
My expectation was:
When accessing via http/https, Dashboard, Settings, Firmware Update, and Events should display the same content.
The result I saw:
On the https page, Dashboard, Settings, Firmware Update, and Events display complete content.
On the http page, Firmwares display complete content, but Dashboard, Settings, and Events display blank.
My question is:
Why does the http page display blank content for Dashboard, Settings, and Events when accessed simultaneously with http; And when not using https and only using http, the http page can display normally?
Environment
log.txt
The text was updated successfully, but these errors were encountered: