-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
WebUI: Support authenticating via Basic auth #23564
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
Conversation
|
@Piccirello
|
This PR mostly modifies the WebAPI, but it's to support usage of the WebUI. I'll add the WebUI label to this PR.
Each of these auth methods is for a slightly different use case. The login page is the most basic auth method and works out of the box, without further configuration. It's for WebUI clients that want to access the WebAPI. Basic auth is more advanced and allows the user to shift responsibility for authenticating from the browser to their reverse proxy. It makes it easier to access the WebUI through a central proxy (e.g. nginx/traefik), including from multiple browsers/devices, by having the proxy send a Basic auth header. I personally use a reverse proxy and have done so for many years. On my network my devices authenticate once to my reverse proxy (via mTLS), and then I can access all my internal sites/tools without having to authenticate again to each individual tool. API key auth (
Each of the three supported auth methods is for a distinct use case. With this PR, I believe we now solve for all requested use cases. I don't foresee us needing to support an additional auth method in the future (or at least no one is asking for one yet). |
3f8dc02 to
92ee974
Compare
This looks weird. Isn't Basic auth a most primitive one? |
What I mean is that it's a more advanced use case, in that it requires additional configuration (and the use of a reverse proxy). The Basic auth header doesn't necessarily need to be sent on every request - though it can be. In our case we use the Basic auth header only if there isn't an existing session cookie. |
92ee974 to
12c44b7
Compare
But, IIRC, browsers usually do just that, i.e. they continue to send auth header with each subsequent request. Although, as far as I can understand, we do not expect such a use case (authentication using browser), and we do not even send a suitable status, which is supposed to prompt the browser to perform Basic auth... I'm just worried that this kind of "hybrid" authentication won't look unexpected to client applications. |
|
One thing I haven't seen mentioned about basic auth: it allows me to make it impossible to know what I'm running. If I access qbit through Right now, the only way to achieve this is to disable auth on localhost (or local subnet) and enable basic auth in the reverse proxy. But on a shared app host/seedbox, you don't want to disable local auth in qbittorrent, because other users on the same shared host would be able to access it. |
This isn't something we'll need to worry about at all. Clients won't attempt Basic auth and don't even have to be aware that it's supported. This is purely optional for reverse proxies to use when explicitly configured. |
12c44b7 to
e440d0f
Compare
Could you provide a description of how someone could set up a similar environment for their own review/testing? |
Why not? If it's available, why wouldn't some 3-rd party client developer want to use it in their client? You can't restrict it. That's what I'm talking about. |
You can test this using the sample nginx config below. This will result in you connecting to your nginx server, and the nginx server authenticating to qBittorrent in a manner completely transparent to your browser. First you'll need to generate your basic auth header value using upstream qbit {
# TODO replace with your IP
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80;
server_name qbit.example.com;
location / {
proxy_pass http://qbit/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
# TODO replace with your base64 encoded credentials
proxy_set_header Authorization "Basic YOUR_BASE64_VALUE";
proxy_hide_header Origin;
proxy_hide_header Referer;
proxy_set_header Origin '';
proxy_set_header Referer '';
}
} |
e440d0f to
2b84789
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
2b84789 to
60f1a65
Compare
This logic needs to be available outside of `AuthController`, for use by basic auth.
Previously these server errors would be swallowed.
A colon in either of these will break basic auth.
This is already checked in the WebUI and in the GUI.
|
Resolved merge conflict. |
|
I wrote up some basic docs on using basic auth. https://github.com/qbittorrent/qBittorrent/wiki/Basic-Authentication-(≥v5.2.0) |
|
@Piccirello |
|
Wiki mentions that https://github.com/qbittorrent/qBittorrent/blob/master/WebAPI_Changelog.md Also looking at the commit history of the webapplication.h file I noticed another PR by was previously merged and @glassez commit 93470f2#diff-13474ccd513f95826cbe8c120f2b739c0461d6d05a67fbaf6be8143a6f9d55c7 already updated WebAPI version to |
|
Addressed in #23709 |
@Piccirello
You should not edit the wiki via the |
This PR adds support for authenticating to the WebAPI via Basic auth. Failed login accounting and IP banning works identically for basic auth and the login page.
Closes #13238.
Closes #15007.