Ignore:
Timestamp:
22/03/10 14:22:21 (9 years ago)
Author:
sdonegan
Message:

Added Phils amended code to allow succesful transfer of mountpoint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI01-discovery-OaiInfoEditor/trunk/v3n_NDG3/OAIInfoEditor/oai_info_editor/lib/security_redirector.py

    r6273 r6757  
    1414__revision__ = '$Id$' 
    1515import logging 
     16log = logging.getLogger(__name__) 
    1617 
    17  
    18 import unittest 
    19 import os 
    20 from urlparse import urlunsplit 
    21  
    22 from os.path import expandvars as xpdVars 
    23 from os.path import join as jnPath 
    24 mkPath = lambda file: jnPath(os.environ['NDGSEC_COMBINED_SRVS_UNITTEST_DIR'],  
    25                              file) 
    26  
    27 import paste.fixture 
    28 from paste.deploy import loadapp 
    2918from ndg.security.server.wsgi import NDGSecurityMiddlewareBase 
    3019from ndg.security.server.wsgi.authz import PEPResultHandlerMiddleware 
    31 from ndg.security.common.authz.msi import Response 
    3220from oai_info_editor.lib.base import * 
    3321from oai_info_editor.controllers.master import ADMIN_PARAMETER 
    3422 
     23 
    3524class RedirectFollowingAccessDenied(PEPResultHandlerMiddleware): 
    36     mountPoint = '/oai-info-editor' 
     25    """Ensure Admin users invoke the home page with the Admin 
     26    query string set.  If they don't a redirect is invoked to the 
     27    same URL but with the admin rights flag set in the query 
     28    string 
     29    """ 
     30    MOUNT_POINT_OPTNAME = 'mountPoint' 
     31    MOUNT_POINT_DEFAULT = '/' 
     32 
     33    def __init__(self, app, global_conf, prefix='', **app_conf): 
     34        super(RedirectFollowingAccessDenied, self).__init__(app, 
     35                                                            global_conf, 
     36                                                            **app_conf) 
     37        cls = RedirectFollowingAccessDenied 
     38        optName = prefix + cls.MOUNT_POINT_OPTNAME 
     39        self.__mountPoint = app_conf.get(optName, cls.MOUNT_POINT_DEFAULT) 
     40        log.debug("Mount point %r = %r", optName, self.__mountPoint) 
     41        log.debug("app_conf = %r", app_conf) 
    3742     
    3843    @NDGSecurityMiddlewareBase.initCall 
     
    4550        queryString = environ.get('QUERY_STRING', '') 
    4651        path = environ.get('PATH_INFO', '') 
    47 #        if path == '/home' and '?' + queryString != ADMIN_PARAMETER: 
    48         if '?' + queryString != ADMIN_PARAMETER: 
    49             return self.redirect("%s%s%s" %(RedirectFollowingAccessDenied.mountPoint, 
    50                                             path, ADMIN_PARAMETER)) 
     52        if path == '/home' and '?' + queryString != ADMIN_PARAMETER: 
     53            redirectURI = "%s%s%s" % (self.__mountPoint, path, ADMIN_PARAMETER) 
     54            log.debug("Redirecting to %r", redirectURI) 
     55            return self.redirect(redirectURI) 
    5156        else: 
    5257            response = \ 
Note: See TracChangeset for help on using the changeset viewer.