Re: Shibboleth login
"John P. Rouillard" <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Tonu: In message <CABDFm8gyiT-UfpSPSShUwWz=xahgkvxgUfkKHMsXtJsDfPq-6g@mail.gmail.com> , Tonu Mikk writes: >Thanks, I tried adding to the wsgi config file (support.py) > >import os >os.environ['REMOTE_USER'] = os.environ['HTTP_REMOTE_USER'] > >I get the following error: >[swadm@drcweb-prd trackers]$ python support.py >Traceback (most recent call last): > File "support.py", line 2, in <module> > os.environ['REMOTE_USER'] = os.environ['HTTP_REMOTE_USER'].strip > File "/usr/lib64/python2.7/UserDict.py", line 23, in __getitem__ > raise KeyError(key) >KeyError: 'HTTP_REMOTE_USER' > >I wonder if the os.environ is different than the wsgi environment? The >HTTP_REMOTE_USER is definately present in wsgi environment. Ok. Then lets try hijacking/monkey patching the __call__ routine in roundup/cgi/wsgi_handler.py. I think that's the entry point that is being used by wsgi's make_server. See below: >On Mon, Dec 31, 2018 at 8:22 PM John P. Rouillard <[email protected]> wrote: >> In message >> <CABDFm8g24B=2vifajtnWqyvXjCv9oZ-+DpJZxfZZmrvR42gySg@mail.gmail.com>, >> Tonu Mikk writes: [...] >> >How could I change the WSGI directions provided in the roundup >> >documentation to incorporate >> > >> >"environ['REMOTE_USER'] = environ['HTTP_REMOTE_USER'].strip()" ? [...] >> This is a shot in the dark but, does this work? >> >> == >> import os >> os.environ['REMOTE_USER'] = os.environ['HTTP_REMOTE_USER'] >> >> from wsgiref.simple_server import make_server >> >> # obtain the WSGI request dispatcher >> from roundup.cgi.wsgi_handler import RequestDispatcher >> tracker_home = 'demo' >> app = RequestDispatcher(tracker_home) >> >> httpd = make_server('', 8917, app) >> httpd.serve_forever() Try this modification: == from roundup.cgi.wsgi_handler import RequestDispatcher class MyDispatcher(RequestDispatcher): def __call__(self, environ, start_response): environ['REMOTE_USER'] = environ['HTTP_REMOTE_USER'].strip() RequestDispatcher.__call__(self,environ,start_response) from wsgiref.simple_server import make_server # use our request dispatcher tracker_home = 'demo' app = MyDispatcher(tracker_home) httpd = make_server('', 8917, app) httpd.serve_forever() == What I am doing is creating a new class MyDispatcher (inheriting from RequestDispatcher) creating a replacement __call__ routine. Then I use make_server call MyDispatcher instead of RequestDispatcher. This should result in MyDispatcher.__call__ being called by make_server. MyDispatcher.__call__ allows you to change the wsgi environment dictionary. Then it calls roundup's RequestDispatcher.__call__ just as though you had assigned the output of RequestDispatcher(tracker_home) to app. I think this is safe as the environ should be unique and unshared with any other call to the roundup back end. Anybody with better python knowledge feel free to chime in here, I am kind of grasping at straws here. -- -- rouilj John Rouillard =========================================================================== My employers don't acknowledge my existence much less my opinions.