marcopeocchi / yt-dlp-web-ui

A terrible web ui for yt-dlp. Designed to be self-hosted.
Mozilla Public License 2.0
794 stars 81 forks source link

[Bug] Problem with config file #171

Closed CrazyWolf13 closed 1 month ago

CrazyWolf13 commented 1 month ago

Version running latest, build today, checked against dockerhub

Describe the bug I'm unable to get the config file to map, or auth is not correctly applying.

To Reproduce Steps to reproduce the behavior:

  1. Create a config file -> conf.yml
  2. bind mount parent folder of conf.yml to /conf in container
  3. change the start command of the container to -> ./yt-dlp-webui --conf /config/config.yml
  4. After clearing cookies
  5. Visiting yt-dlp-web-ui shows no auth and I can fully browse and download the webui, even tough I enabled require_auth, like described here: https://github.com/marcopeocchi/yt-dlp-web-ui/wiki/Authentication-methods

Expected behavior I expect either a login screen or at least that I cannot download stuff, but when I enable auth and an unathentificated user can dl stuff...

Screenshots If applicable, add screenshots to help explain your problem.

Additional context I wanted to test out the openid auth, and tought it may be a good time to switch to config instead of docker env vars. Using the openid gives me the following screen when manually clicking login-> openid:

grafik

Docker command I used:

docker run -dit \
    --name yt-dlp-web-ui \
    --restart unless-stopped \
    --network 20 \
    --ip 10.10.20.220 \
    -v /dockerdata/yt-dlp-web-ui:/config \
    -v /mnt/nas/Youtube-dl:/downloads \
    -e JWT_SECRET=randomsecret \
    marcobaobao/yt-dlp-webui \
    ./yt-dlp-webui --conf /config/config.yml

Config file:

port: 3030
downloadPath: /downloads
queue_size: 8
downloaderPath: /usr/local/bin/yt-dlp
log_path: /config
session_file_path: /config
require_auth: true
password: ciao
username: ciao
use_openid: false
openid_provider_url: https://auth.domain.dev/application/o/ytdlp/
openid_client_id: {client-id-redacted}
openid_client_secret: {client-secret-redacted}
openid_redirect_url: https://ytdlp.domain.dev/auth/openid/signin
marcopeocchi commented 1 month ago

in config file,

use_openid needs to be set to true and require_auth to false (I know, it's a bit counter intuitive but to enable openid it's necessary)

marcopeocchi commented 1 month ago

there's no need to change the start command of the container, just bind your /conf mountpoint

the last line of your docker command can be omitted:

docker run -d \
    --name yt-dlp-web-ui \
    --restart unless-stopped \
    --network 20 \
    --ip 10.10.20.220 \
    -v /dockerdata/yt-dlp-web-ui:/config \
    -v /mnt/nas/Youtube-dl:/downloads \
    -e JWT_SECRET=randomsecret \
    marcobaobao/yt-dlp-webui
CrazyWolf13 commented 1 month ago

there's no need to change the start command of the container, just bind your /conf mountpoint

Thanks! Good to know :)

use_openid needs to be set to true and require_auth to false

Yeah I know, that's totally fine, sorry my wording was a bit poorly explained, apologies. I meant: First I've tested openID auth, and noticed that 404 error above in the screenshot , then I tough maybe it's an issue with the config file, so I just enable RPC auth and test it that gets applied after reboot, but somehow it does not, when I visit the instance I'm not prompted for a password and have full access (cleared cookies before), have you spotted and obvious mistake I made?

CrazyWolf13 commented 1 month ago

@marcopeocchi
I'm still unable to make the config file apply, any ideas what I'm doing wrong?

I've mapped the config file to the container, and it's correctly available in the container, checked with docker exec.

the config file itself should also be valid, so for testing normal auth should be working, as configured in my config file above?

marcopeocchi commented 1 month ago

Hi @CrazyWolf13,

Sorry for the late reply. I will try to reproduce your setup and add additional logging on the configuration parser side.

I hope to catch this strange bug đŸ¤”

CrazyWolf13 commented 1 month ago

@marcopeocchi

No problem, thanks sounds awesome!

Let me know if I can test anything, or you need additional info.

marcopeocchi commented 1 month ago

So,

I've setup the container in a fresh environment:

  1. I've created the dl and conf directories
  2. touch ./conf/config.yml
  3. edited ./conf/config.yml with
    ---
    use_openid: true
    openid_provider_url: https://accounts.google.com
    openid_client_id: ***
    openid_client_secret: ***
    openid_redirect_url: http://localhost:3033/auth/openid/signin
  4. executed the following command
    docker run --rm --name yt-dlp-test -p 3033:3033 -v ./dl:/downloads -v ./conf:/config -e JWT_SECRET=randomsecret marcobaobao/yt-dlp-webui

The OpenID login works :/

Considerations

If the config volume is mounted correctly, after the first boot there will be a file named local.db inside the folder.

If the config file is empty (but existing and successfully detected) this line will be logged: 2024/07/30 08:12:51 config EOF

If the config file is correctly parsed the first logged lined will be:

time=2024-07-30T08:12:51.822Z level=INFO msg="yt-dlp-webui started" address=0.0.0.0:3033
time=2024-07-30T08:12:51.822Z level=INFO msg="sucessfully persisted session"

@CrazyWolf13 if after a clean re-setup it doesn't work we maybe can schedule a call or something on discord (If it's okay with you obv.).

CrazyWolf13 commented 1 month ago

Hi @marcopeocchi

Thank you for your reply :)

So I've fully rebuilt everything now, but I'm still experiencing the same issue.

I created a download and a config file directory and mount them, I mount the parent folder of config, so the file will be and is mounted directly into the container, as I can confirm by using docker exec -it /bin/sh and the browsing the files.

The config file is correctly mounted inside the container and contains the text correctly. My path of the config file inside the container is /config/conf.yml

First of all I tested with RPC auth, which also did not work, then with openid, but as the config is not correctly read, neither one will be applied.

Here the logs from yt-dlp-web-ui:

2024/07/30 13:19:22  config  open /config/config.yml: no such file or directory
time=2024-07-30T13:19:22.463Z level=INFO msg="yt-dlp-webui started" address=0.0.0.0:3033
time=2024-07-30T13:19:22.466Z level=INFO msg="sucessfully persisted session"

Which seems really strange to me, as the file really is at that exact path in the container.

(Normally I have to use sudo to edit the conf.yml on the host side, can there be some sort of permission issue?=

marcopeocchi commented 1 month ago

(Normally I have to use sudo to edit the conf.yml on the host side, can there be some sort of permission issue?=

This explains why yt-dlp-webui doens't see the config.yml file at all.

CrazyWolf13 commented 1 month ago

Hmm I see, guess that makes sense, but I run 20+ containers and none had a problem with that.

CrazyWolf13 commented 1 month ago

grafik

So for testing I just set the permissions to 777, so everyone full access

Here inside the container: grafik

Root-Docker is not actually root here, just a dumb name I chose lol

So as you can see, the file is in the correct plac, is in the container and contains the correct config.

Here the log entrys: grafik

marcopeocchi commented 1 month ago

hello @CrazyWolf13,

I see that the config file is named conf.yml instead of config.yml

CrazyWolf13 commented 1 month ago

Nononononon, no way I missed that!

Apologies!

In the beginning I was not sure what filename yt-dlp-web-ui is using as it is nowwhere documented, but after you implemented the logging, it should be clear for any other user. thanks!

marcopeocchi commented 1 month ago

Apologies for the lack of documentation but I'm glad you resolved!