-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
WebUI: Implement "Secure" flag for session cookie. Closes #11724 #11726
Conversation
What is the usefulness of using the |
The secure flag makes it such that a cookie set in a secure context isn't accessible outside that context. I haven't reviewed this PR yet but will add my review. |
@Piccirello @Chocobo1 See update in OP, I have successfully completed the testing that I deemed necessary. Let me know if you think of anything else |
I seem to understand the topic a better now. Now I think whether we should always set the secure flag when https is in use in our http server instead of providing an UI option? |
I also thought that should be the case at first. However, the point of implementing this as an option is to allow more flexibility and ensure everything works properly in all cases, i.e., even if it's not qBittorrent itself providing the secure HTTPS communication channel with the browser: But maybe changing this: if(m_isSecureCookieEnabled)
cookie.setSecure(true); to this: if(m_isSecureCookieEnabled || m_isHttpsEnabled)
cookie.setSecure(true); and renaming the option to something like "Force secure cookie flag (useful for HTTPS reverse proxy configs)" would be the best of both worlds. This way, users using qBittorrent's built-in HTTPS directly automatically have the secure flag set out-of-the-box. HTTPS reverse proxy users still need to turn on the option. Thoughts? |
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.
Please fix commit message. You need to move "Closes" statement into message body.
d06b83d
to
03ded49
Compare
@glassez |
I think we shouldn't take that case into consideration as HTTP is an end-to-end protocol and proxy breaks the end-to-end design. |
I will admit that doing it that way is more comfortable for users using a simple HTTPS setup. But the trade-off is that it completely cuts off the users using HTTPS reverse proxy (such as me). The way I proposed, everyone is given an option. |
Do you mean qbt <-> (http) <-> proxy <-> (https) <-> user? |
I'm familiar with a reverse proxy's ability to modify arbitrary headers, but I'm not sure about arbitrary cookie flags. Nginx has We generally set http headers based on what will be of most value to most users. A lot of our users use a reverse proxy (myself included), but we usually don't tailor application behavior to them due to the proxy's ability to add/remove arbitrary headers. So if this is possible with a reverse proxy then I'd personally rather not add the option and instead just always set the |
FYI, this is google first answer: https://geekflare.com/httponly-secure-cookie-nginx/ |
Exactly.
I wasn't aware of that. I just knew that you could modify HTTP headers arbitrarily.
Thanks, I will test this. If it works, I will change the PR to the option you mentioned above,
and then I will update the relevant wiki pages, so that reverse proxy users know how they should change their setup. |
@Piccirello proxy_cookie_path / "/; Secure"; inside the |
03ded49
to
7ded03e
Compare
@Chocobo1 @Piccirello |
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.
Shouldn't you disable "Enable cookie Secure flag" checkbox when HTTPS is disabled?
7ded03e
to
a4d7953
Compare
Closes qbittorrent#11724. Option is enabled by default for users using qBittorrent's built-in HTTPS capabilities. This flag will never be set if qBittorrent is using plain HTTP. Users using HTTPS reverse proxies, like "qbt <-> (http) <-> proxy <-> (https) <-> user" should override the flag in the proxy in order to set it, if they wish to do so.
a4d7953
to
691d5e5
Compare
The latest update does that. |
@FranciscoPombal |
Closes #11724.
Option is enabled by default for users using qBittorrent's built-in HTTPS capabilities. This flag will never be set if qBittorrent is using plain HTTP.
Users using HTTPS reverse proxies, like "qbt <-> (http) <-> proxy <-> (https) <-> user" should override the flag in the proxy in order to set it, if they wish to do so.
Testing:
TODODONE: HTTPS with reverse proxy (like the drawing in https://github.com/qbittorrent/qBittorrent/wiki/Linux-WebUI-HTTPS-with-Let's-Encrypt-certificates-and-NGINX-SSL-reverse-proxy)I installed
nginx
and used the following config:This config is close to a real "production" config, except it uses self-signed certs and does not do automatic HTTP->HTTPS redirection, for testing purposes. So the WebUI can be accessed either through either
http://localhost/qbit/
orhttps://localhost/qbit/
(127.0.0.1
can also be used instead oflocalhost
).When the user logs in at
https://localhost/qbit/
and then tries to accesshttp://localhost/qbit/
, they are unable to do so, and land back in the login page, which proves the cookie's secure flag is working as intended.