[PHP] PlexAuth - Authentication for your domain using Plex

PlexAuth, PHP based Plex authentication for your domain.

The idea was to secure my domain using familiar username and passwords for my users. I wanted to remove the need for users to have to sign in at each different website (comics, plex, requests, etc) but still wanted them to all be secure. I hate the idea of shared passwords so I came up with this project.

Using Nginx’s Auth_Request module I’ve now been able to secure all the services using users Plex credentials.

Let me know what you guys think.

Absolutely wow. Thank you so much for this. More motivation to get nginx working… because this is something i too want for my users.

I just have the hardest time with getting nginx to do anything, and i have grown to despise its lack of support. But i will try again to get it working for this.

So, i opted to try nginx with my synology. because it wont even load at all in ubuntu.

first step, install composer. which i was able to do… i think. i can ssh and get composer.phar to spit out errors.

second step, install rememberme from github. so, i set a folder path, /rememberme-master/ and navigated there. typed in cd /volume1/rememberme-master and then executed the command: composer require birke/rememberme but that fails, composer command not found. so not sure how to install that library.

i have the Plex Auth contents in my web folder directory, as /web/pa with the contents inside.

so, unable to figure out how to continue here, i googled things, but there is no documentation on how else to install a composer plugin really. the composer website is not clear on how to install a plugin, only how to make one.

I haven’t used composer on synology. My setup is running Ubuntu.

Does this help you out at all?
http://darktalker.com/2013/07/install-composer-synology/

Yes, that’s the same URL i used to figure out how to install composer. I believe i have composer installed. i made sure my php settings had phar enabled. i then had logged into ssh as admin, and ran the command: curl -s https://getcomposer.org/installer | php which dident give any errors.

my next step is installing rememberme. that’s what i’m stuck on.

Could you redownload from GitHub now please? I’ve added the rememberme in the inc folder…
The only thing you should need to do is create a folder “tokens” and give nginx write permissions.

Let me know how you go.

yes. i’ll do that then edit this post.

Downloaded newest version from github; created folder in /inc/ called tokens with full permissions.

loaded my page, and signed in with my plex account info (email address) and looks like it went through, to a nginx 405 not allowed.

issue? is that it denying my login?

Could I see your nginx logs please?

Sorry, took a while to get the right “log” for nginx. it was also full of other problems with everything else nginx wont run. so i purged the log of everything but the PlexAuth errors for today.

I also have a ubuntu install of nginx, and i would like to try it there, but at least the synology version loads some of the pages i’ve tried. my ubuntu loads nothing at all that i have tried with it.

I have better results with apache, but your app is nginx dependent and i want to use it.

Could you please confirm that /volume1/web/pa/inc/config.ini.php exists and is readable by nginx?

Yes, it should be. i edited the file name to remove the sample prefix, and footer file name. configured the config.ini with my info for plexpy.
tested again after resetting the web engine. just shows 401 error.

The PlexPy section of the config is the least important. You MUST add the Plex server owners token in the file. See below for example:

[PLEX_SERVER]
token = "YOUR PLEX TOKEN"; //Follow this guide to get your token. https://support.plex.tv/hc/en-us/articles/204059436-Finding-your-account-token-X-Plex-Token
plexowner = "PLEX OWNERS USERNAME"; //Your Plex username. Not your email.

[PLEXPY]
plexpy = true; //Enable or disable PlexPy features. This is only if you are using my custom PlexPy fork.

[SERVER]
domain = "Your domain."; //This is used for the cookie.
session_path = "/var/lib/php5/sessions/sess_"; //This is your PHP session path folder with session prefix.

[REMEMBER_ME]
remember_cookie = "YTB-SID"; //Name of the cookie that will be used to remember user.
expire_time = "604800"; //Time for the cookie to expire (Seconds). 604800 = 1 week.

In the log you provided you are getting a lot of “Missing files”. See lines; 726, 727, 728

2016/06/07 01:19:02 [error] 30446#30446: *16160 FastCGI sent in stderr: "PHP message: PHP Warning:  parse_ini_file(/volume1/web/pa/inc/config.ini.php): failed to open stream: No such file or directory in /volume1/web/pa/inc/include.php on line 4" while reading response header from upstream, client: 192.168.11.25, server: , request: "GET /pa/ HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/php56-fpm.sock:", host: "192.168.11.26"

The config.ini.php file is configured with the plex token from plexpy, as well as the default owner username, api key and correct IP address to my plexpy install.

i set all folder permissions to 755 for all of /pa/ and the include.php file is there.

Could you please post results of:

ls -la /volume1/web/pa/inc/config.ini.php

-rwxrwxrwx 1 m1e1w1 users 792 Jun 7 02:26 /volume1/web/pa/inc/config.ini.php

sent you a PM

I tried to copy the same file from nginx_example to sites-available, and i get permission denied. as a regular user though. not logged into root user with the “Files” app.

Got the PlexAuth file made in sites-available folder now.

also, when i read off your example, the spelling of the folder name sites-available was miss spelled as sites-avaliable. that was the error there.

Will wait for the instructions to be published to continue with ubuntu install. Thanks again.

Could you have a look at:

See if this helps you out.

looking that over now.