Basic Authentication with Apache mod_wsgi

25 views
Skip to first unread message

Jorge Macias

unread,
May 14, 2018, 10:29:24 PM5/14/18
to TurboGears
Hi. My app is working perfectly with basic auth under the traditional server provided with turbogears. The passwords are stored under the file passwd_file.  
Recently I move my app to Apache server  2.4.18  using mod wsgi.
I Installed python 3.5.2 in an ubuntu server 16.04 compiled with --enable-shared
I also compiled the mod_wsgi  version 4.6.4 and link it with my python 3.5.2 local installation. Also I validated with ldd mod_wsgi.so to check that everything is ok.
The app works fine under apache (with no errors) , but it fails to authenticate when the user enter a secure route.
I read that is necessary to pass WSGIPassAuthorization with on.
My Apache  tg2.conf as follows: 


<VirtualHost *:8080>

ServerName sun


 WSGIPassAuthorization On


 WSGIProcessGroup sun


 WSGIDaemonProcess sun user=wsgi group=wsgi threads=4 python-path=/home/wsgi/public_wsgi/.virtualenvs/tg2env/lib/python3.5/site-packages


 WSGIScriptAlias / /home/wsgi/public_wsgi/python.sun/app.wsgi


 <Location />


 WSGIPassAuthorization On


 </Location>


 #Serve static files directly without TurboGears


 Alias /images  /home/wsgi/public_wsgi/python.sun/pythonsun/public/images


 Alias /css /home/wsgi/public_wsgi/python.sun/pythonsun/public/css


 Alias /js /home/wsgi/public_wsgi/python.sun/pythonsun/public/js


 <Directory /home/wsgi/public_wsgi/python.sun/>


     WSGIProcessGroup sun


     WSGIApplicationGroup %{GLOBAL}


     WSGIScriptReloading On


     Require all granted


 </Directory>


 ErrorLog ${APACHE_LOG_DIR}/error.log


 CustomLog ${APACHE_LOG_DIR}/access.log combined


</VirtualHost>


WSGIPythonHome /home/wsgi/public_wsgi/.virtualenvs/tg2env


WSGIPythonPath /home/wsgi/public_wsgi/.virtualenvs/tg2env/lib/python3.5


The authentication fails and i don't what i missing.
Any help would be appreciated

Jorge Macias

unread,
May 15, 2018, 11:53:52 AM5/15/18
to TurboGears
I've just found the error. 
In my app_cfg.py was set with a current directory
base_config.sa_auth.authenticators = [('htpasswd', HTPasswdPlugin('./passwd_file', plain_check))]
Apache could not find the file
using a full directory resolve the problem
base_config.sa_auth.authenticators = [('htpasswd', HTPasswdPlugin('/home/wsgi/public_wsgi/python.sun/passwd_file', plain_check))]

Anyway Thanks

Reply all
Reply to author
Forward
0 new messages