if(rc == HTTP_STATUS_UNAUTHORIZED)
htsbuf_qprintf(&hdrs, "WWW-Authenticate: Basic realm=\"tvheadend\"\r\n");
+ if (hc->hc_logout_cookie == 1) {
+ htsbuf_qprintf(&hdrs, "Set-Cookie: logout=1; Path=\"/logout\"\r\n");
+ } else if (hc->hc_logout_cookie == 2) {
+ htsbuf_qprintf(&hdrs, "Set-Cookie: logout=0; Path=\"/logout'\"; expires=Thu, 01 Jan 1970 00:00:00 GMT\r\n");
+ }
htsbuf_qprintf(&hdrs, "Connection: %s\r\n",
hc->hc_keep_alive ? "Keep-Alive" : "Close");
free(hc->hc_password);
hc->hc_password = NULL;
+ hc->hc_logout_cookie = 0;
+
} while(hc->hc_keep_alive && http_server);
error:
struct config_head *hc_user_config;
int hc_no_output;
+ int hc_logout_cookie;
/* Support for HTTP POST */
if (hc->hc_access == NULL ||
hc->hc_access->aa_username == NULL ||
hc->hc_access->aa_username == '\0') {
+redirect:
http_redirect(hc, "/", &hc->hc_req_args);
return 0;
} else {
+ const char *s = http_arg_get(&hc->hc_args, "Cookie");
+ if (s) {
+ while (*s && *s != ';')
+ s++;
+ if (*s) s++;
+ while (*s && *s <= ' ') s++;
+ if (!strncmp(s, "logout=1", 8)) {
+ hc->hc_logout_cookie = 2;
+ goto redirect;
+ }
+ hc->hc_logout_cookie = 1;
+ }
return HTTP_STATUS_UNAUTHORIZED;
}
}