-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
luci-base: add hardening header #1555
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -406,7 +406,7 @@ function dispatch(request) | |
return | ||
end | ||
|
||
http.header("Set-Cookie", 'sysauth=%s; path=%s' %{ sid, build_url() }) | ||
http.header("Set-Cookie", 'sysauth=%s; path=%s; HttpOnly; secure' %{ sid, build_url() }) | ||
http.redirect(build_url(unpack(ctx.requestpath))) | ||
end | ||
|
||
|
@@ -418,6 +418,13 @@ function dispatch(request) | |
ctx.authsession = sid | ||
ctx.authtoken = sdat.token | ||
ctx.authuser = sdat.username | ||
|
||
if http.getenv("HTTPS") == "on" then | ||
local forcehsts = conf.main.forcehsts | ||
if forcehsts then | ||
http.header("Strict-Transport-Security", 'max-age=%s' % forcehsts) | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change should better go to uhttpd2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yousong i do not know uhttpd2? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uhttpd2 is the default HTTP server in OpenWrt. Since the certs, keys etc. required for https are configured on uhttpd, the hsts knob naturally should also go there. |
||
end | ||
|
||
if c and require_post_security(c.target) then | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
secure
attribute should only be enabled ifHTTPS
is on, otherwise browsers will ignoreSet-Cookie
and users cannot login. It is indeed the case when I patched 17.01.04 armvirt qemu image to test this.