JagandeepBrar / lunasea

Self-hosted software controller built using Flutter
https://www.lunasea.app
GNU General Public License v3.0
1.31k stars 64 forks source link

[Bug] NZBGet doesn’t work with NGINX Basic Auth #64

Closed theg00s3 closed 4 years ago

theg00s3 commented 4 years ago

Describe the Bug NZBGet fails to authenticate

To Reproduce Type in URL, username and password in the nzbget tab. Press “Test Connection”

Expected Behaviour Connection succeeded

Versions LunaSea version 0.4.0+1 NZBGet version 21.0

Additional context Logs here: https://pastebin.com/vJr7y91N

JagandeepBrar commented 4 years ago

Hmm... In the logs I can see that it can successfully hit the host because you are getting HTTP status code 401.

[package:lunasea/logic/clients/nzbget/api.dart] [getStatus] [NZBGet: <POST> HTTP Status Code (401)] [Exception: null]

Status 401 means unauthorized, are you 100% sure that the username and password are correct? On that, do the username or password contain any special characters, such as symbols like @, !, #, etc.?

I was experiencing problems myself when using passwords with symbols, but I also was not able to login on the web GUI so I assumed it was a problem with NZBGet.

theg00s3 commented 4 years ago

This is what I get when NZBGet's authentication is disabled

JagandeepBrar commented 4 years ago

It still seems to be returning 401 Unauthorized continually. Do you have any authentication layer on top of NZBGet, maybe through NGINX or Apache?

theg00s3 commented 4 years ago

I do have an authentication layer with nginx, so my url is username:password@website.com, which works for Sonarr, Radarr and Lidarr

JagandeepBrar commented 4 years ago

I think this problem may be out of my control, because I already tried preventing this by passing the username and password to NZBGet by setting the "authorization" header in base64 in the request, seen here:

https://github.com/JagandeepBrar/LunaSea/blob/73eaa245284b33b2509228f7dd84b1c6291521e7/lib/logic/clients/nzbget/api.dart#L23-L27

If you look at the NZBGet API, they also support passing username and password in that same format (username:password@host), and I feel like these must be interfering with each other. I can't think of any other reason that it seems to be failing authentication if you are confident that the username and password combo are correct.

Can you see if it works if you disable the NGINX authentication layer?

theg00s3 commented 4 years ago

Disabling nginx's basic auth works, but strangely I didn't need a workaround when using NZBUnity which unfortunately doesn't release its source code.

theg00s3 commented 4 years ago

I got it working. Instead of putting the nginx credentials in the url, I put them into the username and password box in LunaSea.

So my URL is website.com and then the nginx credentials are in the nzbget credential boxes.