luci-base: use different cookie names for HTTP and HTTPS
authorJo-Philipp Wich <jo@mein.io>
Fri, 8 Jul 2022 13:38:53 +0000 (15:38 +0200)
committerJo-Philipp Wich <jo@mein.io>
Fri, 8 Jul 2022 13:38:53 +0000 (15:38 +0200)
commite1932592c3e0804eec5d85fee989ceeed1e1050a
tree469f729bd9b797a9b5306d2f591ee4e5e71254fb
parent2b0539ef9d1849b42fae206f0647bc647323c75d
luci-base: use different cookie names for HTTP and HTTPS

Since HTTP cookies may not overwrite HTTPS ("secure") ones, users are
frequently unable to log into LuCI when a stale, "secure" `sysauth` cookie
is still present in the browser as it commonly happens after e.g. a
sysupgrade operation or when frequently jumping between HTTP and HTTPS
access.

Rework the dispatcher to set either a `sysauth_http` or `sysauth_https`
cookie, depending on the HTTPS state of the server connection and accept
both cookie names when verifying the session ID.

This allows users to log into a HTTP-only LuCI instance while a stale,
"secure" HTTPS cookie is still present.

Requires commit 2b0539ef9d ("lucihttp: update to latest Git HEAD") to
function properly.

Fixes: #5843
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/luasrc/controller/admin/index.lua
modules/luci-base/luasrc/dispatcher.lua
modules/luci-base/root/usr/share/luci/menu.d/luci-base.json