On 19-6-2012 9:46, Laurence MacNeill wrote: > On Monday, June 18, 2012, Melvyn Sopacua wrote: > >> On 18-6-2012 9:52, Laurence MacNeill wrote: >>> well -- I hit the wrong key and posted that before I was finished >> typing... >>> >>> here's what's in my views.py file: >>> def index(request) >>> current_username = os.environ['REMOTE_USER'] >> >> And you're sure this works? Try: >> return django.shortcuts.render_to_response(current_username) >> >> here to verify it's coming through. Normally, the authenticated username >> would be part of the request dictionary. > > > > Yeah, it's not working... How do I get the user-name from the request > dictionary? request.REMOTE_USER or somthing like that? > > It's not using Django for the user-validation, though... When someone logs > into the site, they get redirected to a page that validates them. This is > controled by the Apache web-server itself -- if they try to access any > document served by Apache, and they don't have a cookie on their computer, > they're redirected to a different page where they enter their user ID and > password, then are sent back to the original page. The user-id is then > stored in a linux environment variable called REMOTE_USER. So I figured > the only way to access it was via the os.environ method.
I get the feeling you're mixing and matching server-side programming languages. If you're using any variation of basic HTTP authentication, then the operating system environment isn't a factor, but the CGI environment is, which gets set "somewhere" based on module implementation. Maybe you think it's an environment variable, because Php stores it in $_SERVER. Or because you use plain CGI scripts and for those CGI environment equals OS environment. If that's the case, then what you're looking for is this: https://docs.djangoproject.com/en/1.4/howto/auth-remote-user/ HTTP protocol details as background: What really happens with HTTP authentication that way, is that the server sends a 401 Authorization Required response to the browser. The user then enters username and password and if the server finds this combination to be correct, it returns a redirect or shows the requested page. If not, the server sends a 403 Forbidden. Per CGI 1.1 specification [1], the server shall set the variable REMOTE_USER in the CGI environment if it successfully authenticated a user. [1] http://tools.ietf.org/html/rfc3875#section-4.1.11 -- Melvyn Sopacua -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.