mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-23 18:49:01 +08:00
Merge pull request #2964 from cesanta/http-cookie
Some checks are pending
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, , mip_test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, , test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, BUILTIN, mip_test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, BUILTIN, test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, , mip_test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, , test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, BUILTIN, mip_test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, BUILTIN, test) (push) Waiting to run
Build and test - essentials / s390 (push) Waiting to run
Build and test - essentials / armhf (push) Waiting to run
Build and test - essentials / unamalgamated-mg_prefix (push) Waiting to run
Build and test - essentials / macos SSL=${{ matrix.ssl }} () (push) Waiting to run
Build and test - essentials / macos SSL=${{ matrix.ssl }} (BUILTIN) (push) Waiting to run
Build and test - essentials / windows ${{ matrix.target }} (mingw++) (push) Waiting to run
Build and test - essentials / windows ${{ matrix.target }} (vc22) (push) Waiting to run
Build and test - essentials / windows ${{ matrix.target }} (vc98) (push) Waiting to run
Build and test - essentials / arm (push) Waiting to run
Build and test - essentials / riscv (push) Waiting to run
Build and test - essentials / examples (push) Waiting to run
Build and test - essentials / examples_win (push) Waiting to run
Build and test - essentials / examples_mac (push) Waiting to run
Build and test - essentials / refprojs (push) Waiting to run
Build and test - essentials / refprojs_win (push) Waiting to run
Build and test - essentials / refprojs_mac (push) Waiting to run
Build and test - essentials / tutorials (push) Waiting to run
Build and test - essentials / tutorials_win (push) Waiting to run
Build and test - essentials / tutorials_mac (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:infineon/infineon-xmc7200]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/frdm-mcxn947-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/frdm-mcxn947-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1020-evk-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1060-evk-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1170-evk-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f429zi-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f429zi-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h563zi-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h563zi-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h723zg-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h723zg-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h743zi-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h743zi-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/stm32h573i-dk-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/stm32h573i-dk-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:ti/ek-tm4c1294xl-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:ti/ek-tm4c1294xl-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:esp32/uart-bridge]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:esp8266/http-client-server]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:infineon/infineon-xmc4700_4800-lwip-rtx-rtos]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-g031-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:esp32/device-dashboard]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:microchip/same54-xpro/device-dashboard]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1020-evk-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1060-evk-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1170-evk-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-rndis-dashboard]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-w]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:renesas/ek-ra6m4-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-baremetal-builtin-cmsis_driver]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-freertos-tcp]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-rndis-device]) (push) Waiting to run
Build and test - essentials / cube_examples (push) Waiting to run
Build and test - essentials / test_f7 (push) Waiting to run
Build and test - essentials / test_f4 (push) Waiting to run
Build and test - essentials / test_h743 (push) Waiting to run
Build and test - essentials / test_h723 (push) Waiting to run
Build and test - essentials / test_h5 (push) Waiting to run
Build and test - essentials / test_rt1020 (push) Waiting to run
Build and test - essentials / test_rt1060 (push) Waiting to run
Build and test - essentials / test_rt1170 (push) Waiting to run
Build and test - essentials / test_ra6m4 (push) Waiting to run
Build and test - essentials / test_tm4c (push) Waiting to run
Build and test - essentials / test_same54 (push) Waiting to run
Build and test - essentials / test_pico_w5500 (push) Waiting to run
Some checks are pending
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, , mip_test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, , test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, BUILTIN, mip_test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (clang++, BUILTIN, test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, , mip_test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, , test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, BUILTIN, mip_test) (push) Waiting to run
Build and test - essentials / linux ${{ matrix.target }} CC=${{ matrix.cc }} SSL=${{ matrix.ssl }} (gcc, BUILTIN, test) (push) Waiting to run
Build and test - essentials / s390 (push) Waiting to run
Build and test - essentials / armhf (push) Waiting to run
Build and test - essentials / unamalgamated-mg_prefix (push) Waiting to run
Build and test - essentials / macos SSL=${{ matrix.ssl }} () (push) Waiting to run
Build and test - essentials / macos SSL=${{ matrix.ssl }} (BUILTIN) (push) Waiting to run
Build and test - essentials / windows ${{ matrix.target }} (mingw++) (push) Waiting to run
Build and test - essentials / windows ${{ matrix.target }} (vc22) (push) Waiting to run
Build and test - essentials / windows ${{ matrix.target }} (vc98) (push) Waiting to run
Build and test - essentials / arm (push) Waiting to run
Build and test - essentials / riscv (push) Waiting to run
Build and test - essentials / examples (push) Waiting to run
Build and test - essentials / examples_win (push) Waiting to run
Build and test - essentials / examples_mac (push) Waiting to run
Build and test - essentials / refprojs (push) Waiting to run
Build and test - essentials / refprojs_win (push) Waiting to run
Build and test - essentials / refprojs_mac (push) Waiting to run
Build and test - essentials / tutorials (push) Waiting to run
Build and test - essentials / tutorials_win (push) Waiting to run
Build and test - essentials / tutorials_mac (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:infineon/infineon-xmc7200]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/frdm-mcxn947-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/frdm-mcxn947-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1020-evk-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1060-evk-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1170-evk-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f429zi-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f429zi-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h563zi-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h563zi-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h723zg-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h723zg-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h743zi-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-h743zi-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/stm32h573i-dk-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/stm32h573i-dk-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:ti/ek-tm4c1294xl-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:ti/ek-tm4c1294xl-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:esp32/uart-bridge]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:esp8266/http-client-server]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:infineon/infineon-xmc4700_4800-lwip-rtx-rtos]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-g031-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:esp32/device-dashboard]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:microchip/same54-xpro/device-dashboard]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1020-evk-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1060-evk-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:nxp/rt1170-evk-make-freertos-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-rndis-dashboard]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-w]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:renesas/ek-ra6m4-make-baremetal-builtin]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-baremetal-builtin-cmsis_driver]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:stm32/nucleo-f746zg-make-freertos-tcp]) (push) Waiting to run
Build and test - essentials / ${{ matrix.example.path }} (map[path:pico-sdk/pico-rndis-device]) (push) Waiting to run
Build and test - essentials / cube_examples (push) Waiting to run
Build and test - essentials / test_f7 (push) Waiting to run
Build and test - essentials / test_f4 (push) Waiting to run
Build and test - essentials / test_h743 (push) Waiting to run
Build and test - essentials / test_h723 (push) Waiting to run
Build and test - essentials / test_h5 (push) Waiting to run
Build and test - essentials / test_rt1020 (push) Waiting to run
Build and test - essentials / test_rt1060 (push) Waiting to run
Build and test - essentials / test_rt1170 (push) Waiting to run
Build and test - essentials / test_ra6m4 (push) Waiting to run
Build and test - essentials / test_tm4c (push) Waiting to run
Build and test - essentials / test_same54 (push) Waiting to run
Build and test - essentials / test_pico_w5500 (push) Waiting to run
Use separate cookies for HTTP and HTTPS connections
This commit is contained in:
commit
b6dc830bcb
@ -77,19 +77,22 @@ static struct user *authenticate(struct mg_http_message *hm) {
|
||||
|
||||
static void handle_login(struct mg_connection *c, struct user *u) {
|
||||
char cookie[256];
|
||||
const char *cookie_name = c->is_tls ? "secure_access_token" : "access_token";
|
||||
mg_snprintf(cookie, sizeof(cookie),
|
||||
"Set-Cookie: access_token=%s; Path=/; "
|
||||
"Set-Cookie: %s=%s; Path=/; "
|
||||
"%sHttpOnly; SameSite=Lax; Max-Age=%d\r\n",
|
||||
u->access_token, c->is_tls ? "Secure; " : "", 3600 * 24);
|
||||
cookie_name, u->access_token,
|
||||
c->is_tls ? "Secure; " : "", 3600 * 24);
|
||||
mg_http_reply(c, 200, cookie, "{%m:%m}", MG_ESC("user"), MG_ESC(u->name));
|
||||
}
|
||||
|
||||
static void handle_logout(struct mg_connection *c) {
|
||||
char cookie[256];
|
||||
const char *cookie_name = c->is_tls ? "secure_access_token" : "access_token";
|
||||
mg_snprintf(cookie, sizeof(cookie),
|
||||
"Set-Cookie: access_token=; Path=/; "
|
||||
"Set-Cookie: %s=; Path=/; "
|
||||
"Expires=Thu, 01 Jan 1970 00:00:00 UTC; "
|
||||
"%sHttpOnly; Max-Age=0; \r\n",
|
||||
"%sHttpOnly; Max-Age=0; \r\n", cookie_name,
|
||||
c->is_tls ? "Secure; " : "");
|
||||
mg_http_reply(c, 200, cookie, "true\n");
|
||||
}
|
||||
|
@ -156,19 +156,23 @@ static struct user *authenticate(struct mg_http_message *hm) {
|
||||
|
||||
static void handle_login(struct mg_connection *c, struct user *u) {
|
||||
char cookie[256];
|
||||
const char *cookie_name = c->is_tls ? "secure_access_token" : "access_token";
|
||||
mg_snprintf(cookie, sizeof(cookie),
|
||||
"Set-Cookie: access_token=%s;Path=/;"
|
||||
"HttpOnly;SameSite=Lax;Max-Age=%d\r\n",
|
||||
u->access_token, 3600 * 24);
|
||||
"Set-Cookie: %s=%s;Path=/;"
|
||||
"%sHttpOnly;SameSite=Lax;Max-Age=%d\r\n", cookie_name,
|
||||
u->access_token, c->is_tls ? "Secure; " : "", 3600 * 24);
|
||||
mg_http_reply(c, 200, cookie, "{%m:%m}", MG_ESC("user"), MG_ESC(u->name));
|
||||
}
|
||||
|
||||
static void handle_logout(struct mg_connection *c) {
|
||||
mg_http_reply(c, 200,
|
||||
"Set-Cookie: access_token=; Path=/; "
|
||||
"Expires=Thu, 01 Jan 1970 00:00:00 UTC; "
|
||||
"Secure; HttpOnly; Max-Age=0; \r\n",
|
||||
"true\n");
|
||||
char cookie[256];
|
||||
const char *cookie_name = c->is_tls ? "secure_access_token" : "access_token";
|
||||
mg_snprintf(cookie, sizeof(cookie),
|
||||
"Set-Cookie: %s=; Path=/; "
|
||||
"Expires=Thu, 01 Jan 1970 00:00:00 UTC; "
|
||||
"%sHttpOnly; Max-Age=0; \r\n", cookie_name,
|
||||
c->is_tls ? "Secure; " : "");
|
||||
mg_http_reply(c, 200, cookie, "true\n");
|
||||
}
|
||||
|
||||
static void handle_debug(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
|
@ -78,19 +78,22 @@ static struct user *authenticate(struct mg_http_message *hm) {
|
||||
|
||||
static void handle_login(struct mg_connection *c, struct user *u) {
|
||||
char cookie[256];
|
||||
const char *cookie_name = c->is_tls ? "secure_access_token" : "access_token";
|
||||
mg_snprintf(cookie, sizeof(cookie),
|
||||
"Set-Cookie: access_token=%s; Path=/; "
|
||||
"Set-Cookie: %s=%s; Path=/; "
|
||||
"%sHttpOnly; SameSite=Lax; Max-Age=%d\r\n",
|
||||
u->access_token, c->is_tls ? "Secure; " : "", 3600 * 24);
|
||||
cookie_name, u->access_token,
|
||||
c->is_tls ? "Secure; " : "", 3600 * 24);
|
||||
mg_http_reply(c, 200, cookie, "{%m:%m}", MG_ESC("user"), MG_ESC(u->name));
|
||||
}
|
||||
|
||||
static void handle_logout(struct mg_connection *c) {
|
||||
char cookie[256];
|
||||
const char *cookie_name = c->is_tls ? "secure_access_token" : "access_token";
|
||||
mg_snprintf(cookie, sizeof(cookie),
|
||||
"Set-Cookie: access_token=; Path=/; "
|
||||
"Set-Cookie: %s=; Path=/; "
|
||||
"Expires=Thu, 01 Jan 1970 00:00:00 UTC; "
|
||||
"%sHttpOnly; Max-Age=0; \r\n",
|
||||
"%sHttpOnly; Max-Age=0; \r\n", cookie_name,
|
||||
c->is_tls ? "Secure; " : "");
|
||||
mg_http_reply(c, 200, cookie, "true\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user