By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,235 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,235 IT Pros & Developers. It's quick & easy.

mod_python, user missing

P: n/a
apache conf
<Directory /python-publisher/>
SetHandler mod_python
PythonHandler mod_python.publisher
</Directory>
and this is in /python-publisher/index.py

__auth_realm__ = 'VIP'

def __auth__(req, user, passwd):
if user == 'noppa' and passwd == 'potti':
return True
else:
return False

def __access__(req, user):
if user == 'noppa':
return True
else:
return False

def index(req):
req.get_basic_auth_pw()
user = req.user
return 'user is %s' % (user)
So problem is, how I get user in index function? That gives allways "None"

--
(8)
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Good question, according to the documentation it should work, I'll
push this onto the mod_python mailing list for discussion and get a
bug report posted if necessary.

In the meantime, you could use the following work around:

def __auth__(req, user, passwd):
req.user = user
if user == 'noppa' and passwd == 'potti':
return True
else:
return False

Ie., explicitly set "req.user" in the __auth__ method.

Jul 18 '05 #2

P: n/a
Okay, reason it doesn't work is that req.get_basic_auth_pw() only
applies when using Apache itself to perform the user authentication.
Ie., where in Apache configuration files you have something like:

AuthType Basic
AuthName "VIP"
AuthUserFile /tmp/pwdb
Require user noppa

It doesn't work when using mod_python.publisher style authentication
as that is done in mod_python and not by Apache. Thus, you would
need to assign to req.user in the __auth__ method as I described to
have it so it is accessible in the published method. You will not need
to call the req.get_basic_auth_pw() function.

Jul 18 '05 #3

P: n/a
So damn simple that i am embarrassed :D
Now my news get added with user.
Thanks :)

--
(8)
gr*****@dscpl.com.au wrote:
Good question, according to the documentation it should work, I'll
push this onto the mod_python mailing list for discussion and get a
bug report posted if necessary.

In the meantime, you could use the following work around:

def __auth__(req, user, passwd):
req.user = user
if user == 'noppa' and passwd == 'potti':
return True
else:
return False

Ie., explicitly set "req.user" in the __auth__ method.

Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.