speculatrix / tvh_epg

A very simple web based EPG for TVHeadend
GNU General Public License v3.0
27 stars 1 forks source link

Unable to authenticate against TVH #12

Closed Guyverix closed 3 years ago

Guyverix commented 3 years ago

Been following the instructions and have the cgi portion working. However I cannot seem to authenticate against TVH itself from within the python script.

Tried new users, existing users, as well as the admin user.
tvh version 4.3-1917 (docker)

Ubuntu 16.04 x64 python3 --version Python 3.4.3 Apache: 2.4.10-1ubuntu1.1

`

EPG

Error code 401
b'\r\n\r\n401 Unauthorized\r\n\r\n

401 Unauthorized

\r\n

Default login

New login

\r\n'
` have confirmed the ini file has the same password that I use via browser. This is where I suspect the issue lay: ts_response = requests.get(ts_query, auth=(ts_user, ts_pass))
Guyverix commented 3 years ago

I have now also tested on an Ubuntu 20 machine, using Python 3.8.5 I am pretty certain that I am the one who is causing the issue, since nobody else has reported troubles. Just am unsure how to proceed to figure out what I have messed up. Any suggestions would be appreciated.

dgilbert2 commented 3 years ago

Hi

I can offer the suggestions below based on my experience. First off, I can confirm that TVH_EPG does work, there is an open issue though with pychromecast (issue #10) but you are not that far yet. Also, I suggest the Tvheadend forum has a wider audience for support than here, a couple of posts for example;

https://tvheadend.org/boards/5/topics/34232 https://tvheadend.org/boards/5/topics/21836

What I suggest though is to check your permissions for the two folders you should now have installed;

/usr/lib/cgi-bin /var/lib/tvh_epg/

In my case (both folders should be set the same), recursively set; image

I use WinSCP to check / set these, or you can try entering into your SSH terminal;

chgrp www-data /usr/lib/cgi-bin chmod g+rwxs /usr/lib/cgi-bin chgrp www-data /var/lib/tvh_epg/tvh_epg_settings.ini chgrp www-data /var/lib/tvh_epg chmod g+rwxs /var/lib/tvh_epg

I don't pretend to be an expert on how to change permissions though!

Also, download TvhClient (for Tvheadend) onto your phone and run it. Enter your Tvheadend user details and if it comes up with an error, it offers to fix it. I'm not fully sure what it does, but it does enable TVH_EPG :-) You can delete TvhClient then if you want to.

Guyverix commented 3 years ago

Donno if this is an issue with the docker image that I am using for TVH, but I had to edit your code to support Digest authentication.

Added: from requests.auth import HTTPDigestAuth and changed: auth=HTTPDigestAuth(ts_user, ts_pass)) from auth=(ts_user, ts_pass))

speculatrix commented 3 years ago

thanks for the feedback.

what I did was set the directory where tvh_epg writes to so as to allow the apache server to write to the file, thus:

paulm@mcintyre:~/projects/tvh_epg$ ls -la /var/lib/tvh_epg/
total 8
drwxrwsr-x  2 root www-data   34 Feb  7 18:45 .
drwxr-xr-x 50 root root     4096 Nov 26 13:47 ..
-rw-rw-r--  1 root www-data  367 Feb  7 18:51 tvh_epg_settings.ini
speculatrix commented 3 years ago

as to authentication, my TVH server setting for "Authentication type:" is "plain (insecure)". I think I had to set it to that so I could get this cgi-bin to work.

your suggestion are very helpful as I can now fix my security, thanks!

speculatrix commented 3 years ago

Thanks @Guyverix I have added digest support. I turned digest on in my TVH config and change the tvh_epg and voila, it worked. You code snippet was perfect.

speculatrix commented 3 years ago

I'll take your graphics and start a section installation for Windows users.

speculatrix commented 3 years ago

does digest auth work for you now? it does for me

Guyverix commented 3 years ago

Been nice and stable for me. No issues at all.