HTML Authentication with Python

Matthew T Lineen mli389 at merle.acns.nwu.edu
Thu Apr 15 16:40:30 EDT 1999


I am currently running python on an Windows NT Server.  We only want certain
pages to be accessed by people with accounts on the server in order to
update a database through python.  Using this code:

def main():
	if not os.environ.has_key("REMOTE_USER"):
		print "HTTP/1.0 401 Access Denied"
		print "Status: 401 Authenication Required"
		print "WWW-authenticate: Basic;"
		print "Content-type: text/html\n\n\n"
	else:
		print "Worked"

I was able to get an authentication box to pop up in both netscape and ie,
but when a user who is not an administrator tries to authenticate it
doesn't accept the username / password.

Is this a good way to go about authentication in python or is there another
library to interface with the browsers and the NT user database? 
Furthermore, I'm relatively sure that the problem lies in user permissions,
but I have no idea where to begin troubleshooting.  Where is the os.environ
'kept'?

Any help would be appriciated.

Matthew Lineen




More information about the Python-list mailing list