Changeset 1261

Show
Ignore:
Timestamp:
09/08/06 22:30:28 (2 years ago)
Author:
coderanger
Message:

TracForgePlugin:

Cleanup for last checkin.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tracforgeplugin/0.10/tracforge/linker/auth.py

    r1260 r1261  
    66from trac.web.auth import LoginModule 
    77from trac.web.main import _open_environment 
    8 from trac.env import Environment 
    98from trac.web.href import Href 
    109from trac.util.html import escape, html 
     
    1211 
    1312from urlparse import urlsplit 
    14 import inspect 
    1513 
    1614class TracForgeLoginModule(LoginModule): 
     
    4543                      doc='The smallest common URI for the whole TracForge setup') 
    4644                       
    47     real_get_header = Request.get_header 
    48                        
    4945    implements(IRequestFilter) 
    5046 
    51     def __init__(self): 
    52         #Request.get_header = self._my_get_header 
    53         pass 
    54  
    5547    def pre_process_request(self, req, handler): 
    56         #self.log.debug('TracForgeCookieMunger: Running') 
    5748        if req.path_info.startswith('/login') or req.path_info.startswith('/logout'): 
    58             #self.log.debug('TracForgeCookieMunger: Path match') 
    5949            def my_redirect(*args, **kwords): 
    60                 #self.log.debug('TracForgeCookieMunger: Captured redirect!') 
    61                 #self.log.debug('TracForgeCookieMunger: Pre munging\n%s'%req.outcookie) 
     50                # Munge the cookie path 
    6251                if 'trac_auth' in req.outcookie: 
    6352                    assert not self.uri_root.startswith('http'), 'The tracforge uri_root must be set to relative path' 
    6453                    req.outcookie['trac_auth']['path'] = self.uri_root 
    65                 #self.log.debug('TracForgeCookieMunger: Post munging\n%s'%req.outcookie) 
    6654 
     55                # Check to see if we should refer back to sibling Trac 
    6756                referer = req.args.get('referer') 
    6857                self.log.debug('TracForgeCookieMunger: Got referer as %r'%referer) 
     
    7564                Request.redirect(req, *args, **kwords) 
    7665             
    77             assert repr(req.redirect).startswith('<bound method') 
     66            assert repr(req.redirect).startswith('<bound method'), 'Someone else changed req.redirect first' 
    7867            req.redirect = my_redirect 
    7968             
     
    8170         
    8271    def post_process_request(self, req, template, content_type): 
    83         #if req.path_info.startswith('/login'): 
    84         #    if 'trac_auth' in req.outcookie: 
    85         #        req.outcookie['trac_auth']['path'] = self.uri_root 
    8672        return (template, content_type) 
    8773 
    88     # Internal methods 
    89     def _my_redirect_back(self, req): 
    90         """Modified version of LoginModule._redirect_back that checks  
    91         to see if the target is in the tracforge URI.""" 
    92         self.log.debug('TracForgeCookieMunger: In evil redirect captor') 
    93         referer = req.get_header('Referer') 
    94         parts = urlsplit(referer) 
    95         if referer and (not parts[2].startswith(self.uri_root) or not parts[1].startswith(req.server_name)): 
    96             referer = None 
    97         req.redirect(referer or req.abs_href()) 
    98  
    99     def _my_get_header(self, name): 
    100         """Severe evil. Contact Noah Kantrowitz if you need to know what this does.""" 
    101         if name == 'Referer': 
    102             try: 
    103                 stack = inspect.stack() 
    104                 for s in stack: 
    105                     if 'redirect' in s[3]: 
    106                         pass                         
    107                          
    108             finally: 
    109                 del stack 
    110          
    111         return TracForgeCookieMunger.real_get_header(self, name)