Discussion:
[TurboGears] Basic Authentication with Apache mod_wsgi
Jorge Macias
2018-05-14 22:52:26 UTC
Permalink
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
--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.
Jorge Macias
2018-05-15 15:53:52 UTC
Permalink
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
Post by Jorge Macias
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.
<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
--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.
Loading...