Ignore:
Timestamp:
08/06/10 16:33:29 (10 years ago)
Author:
pjkersha
Message:

Incomplete - task 5: MyProxy? Logon HTTPS Interface

  • Finished epydoc ready for first release to PyPI.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/MyProxyWebService/myproxy/server/wsgi/middleware.py

    r6943 r6950  
    3333 
    3434class MyProxyClientMiddlewareBase(object): 
    35     """Base class for common functionality""" 
    36     __slots__ = ('__app', '__clientEnvironKeyName',) 
     35    """Base class for common functionality 
     36     
     37    @cvar CLIENT_ENV_KEYNAME_OPTNAME: ini file option which sets the key name 
     38    in the WSGI environ for referring to the MyProxy client instance shared 
     39    between MyProxy* middleware/apps 
     40    @type CLIENT_ENV_KEYNAME_OPTNAME: string 
     41     
     42    @cvar DEFAULT_CLIENT_ENV_KEYNAME: default value for key name set in the 
     43    WSGI environ dict which refers to the MyProxy client instance shared 
     44    between MyProxy* middleware/apps 
     45    @type DEFAULT_CLIENT_ENV_KEYNAME: string 
     46     
     47    @ivar __app: WSGI callable for next middleware or app in the WSGI stack 
     48    @type __app: function 
     49     
     50    @ivar __clientEnvironKeyName: key name set in the WSGI environ dict which  
     51    refers to the MyProxy client instance shared between MyProxy* middleware/ 
     52    apps 
     53    @type __clientEnvironKeyName: string 
     54    """ 
     55    __slots__ = ( 
     56        '__app',  
     57        '__clientEnvironKeyName', 
     58    ) 
    3759     
    3860    CLIENT_ENV_KEYNAME_OPTNAME = 'clientEnvKeyName' 
     
    4163         
    4264    def __init__(self, app): 
     65        """Create WSGI app and MyProxy client attributes 
     66        @type app: function 
     67        @param app: WSGI callable for next middleware or app in the WSGI stack 
     68        """ 
    4369        self.__app = app 
    4470        self.__clientEnvironKeyName = None 
     
    82108        @type statusCode: int 
    83109        @param statusCode: HTTP status code 
    84         @rtype: str 
     110        @rtype: string 
    85111        @return: status code with standard message 
    86112        @raise KeyError: for invalid status code 
     
    90116     
    91117class MyProxyClientMiddleware(MyProxyClientMiddlewareBase): 
    92     ''' 
    93     Create a MyProxy client and make it available to other middleware in the  
     118    '''Create a MyProxy client and make it available to other middleware in the  
    94119    WSGI stack 
     120     
     121    @cvar LOGON_FUNC_ENV_KEYNAME_OPTNAME: ini file option name to set the key  
     122    name in WSGI environ dict to assign to the Logon function created by this 
     123    middleware 
     124    @type LOGON_FUNC_ENV_KEYNAME_OPTNAME: string 
     125     
     126    @cvar DEFAULT_LOGON_FUNC_ENV_KEYNAME: default value for the key name in  
     127    WSGI environ dict to assign to the Logon function created by this 
     128    middleware 
     129    @type DEFAULT_LOGON_FUNC_ENV_KEYNAME: string 
     130     
     131    @cvar CERT_REQ_POST_PARAM_KEYNAME: HTTP POST field name for the  
     132    certificate request posted in logon calls 
     133    @type CERT_REQ_POST_PARAM_KEYNAME: string 
     134     
     135    @cvar PARAM_PREFIX: prefix for ini file option names  
     136    @type PARAM_PREFIX: string 
     137     
     138    @cvar MYPROXY_CLIENT_PARAM_PREFIX: default value for ini file sub-prefix  
     139    used for MyProxyClient initialisation settings such as MyProxy server  
     140    hostname, CA cert directory etc.  The prefix is such that option names  
     141    will look like this e.g. 
     142    <PARAM_PREFIX><MYPROXY_CLIENT_PARAM_PREFIX>hostname 
     143    ... 
     144    @type MYPROXY_CLIENT_PARAM_PREFIX: string 
     145     
     146    @ivar __myProxyClient: MyProxy client interface object to enable this 
     147    middleware to communicate with a backend MyProxy server using the MyProxy 
     148    protocol 
     149    @type __myProxyClient: myproxy.client.MyProxyClient 
     150     
     151    @ivar __logonFuncEnvironKeyName:  
     152    @type __logonFuncEnvironKeyName: string 
    95153    ''' 
    96154    # Options for ini file 
     
    108166     
    109167    __slots__ = ( 
    110         '__app', 
    111168        '__myProxyClient',  
    112169        '__logonFuncEnvironKeyName', 
     
    136193        @type prefix: basestring 
    137194        @param prefix: prefix for configuration items 
     195        @type myProxyClientPrefix: ini file sub-prefix used for MyProxyClient  
     196        initialisation settings such as MyProxy server  hostname, CA cert.  
     197        directory etc.   
     198        @param myProxyClientPrefix: basestring 
    138199        @type app_conf: dict         
    139200        @param app_conf: PasteDeploy application specific configuration  
    140201        dictionary 
     202         
     203        @rtype: myproxy.server.wsgi.middleware.MyProxyClientMiddleware 
     204        @return: an instance of this application 
    141205        """ 
    142206        app = cls(app) 
     
    152216        @type prefix: basestring 
    153217        @param prefix: prefix for configuration items 
    154         @type prefix: basestring 
    155         @param prefix: explicit prefix for MyProxyClient class specific  
    156         configuration items 
     218        @type myProxyClientPrefix: basestring 
     219        @param myProxyClientPrefix: explicit prefix for MyProxyClient class  
     220        specific configuration items 
    157221        @type app_conf: dict         
    158222        @param app_conf: PasteDeploy application specific configuration  
     
    247311        """Return the MyProxy logon method wrapped as a HTTP Basic Auth  
    248312        authenticate interface function 
     313         
     314        @rtype: function 
     315        @return: MyProxy logon HTTP Basic Auth Callback 
    249316        """ 
    250317        def _myProxylogon(environ, start_response, username, password): 
    251318            """Wrap MyProxy logon method as a WSGI app 
     319            @type environ: dict 
     320            @param environ: WSGI environment variables dictionary 
     321            @type start_response: function 
     322            @param start_response: standard WSGI start response function 
     323            @type username: basestring 
     324            @param username: username credential to MyProxy logon 
     325            @type password: basestring 
     326            @param password: pass-phrase for MyProxy logon call 
     327            @raise HttpBasicAuthResponseException: invalid client request 
     328            @raise MyProxyClientMiddlewareError: socket error for backend 
     329            MyProxy server 
    252330            """   
    253331            requestMethod = environ.get('REQUEST_METHOD')              
     
    323401    upstream in the WSGI stack to set up a MyProxyClient instance and make it  
    324402    available in the environ to call its getTrustRoots method. 
     403     
     404    @cvar PATH_OPTNAME: ini file option to set the URI path for this service 
     405    @type PATH_OPTNAME: string 
     406     
     407    @cvar DEFAULT_PATH: default URI path setting 
     408    @type DEFAULT_PATH: string 
     409 
     410    @cvar PARAM_PREFIX: prefix for ini file option names  
     411    @type PARAM_PREFIX: string 
     412     
     413    @ivar __path: URI path setting for this service 
     414    @type __path: basestring 
    325415    """ 
    326      
    327     # Options for ini file 
    328     CLIENT_ENV_KEYNAME_OPTNAME = \ 
    329         MyProxyClientMiddleware.CLIENT_ENV_KEYNAME_OPTNAME 
    330416         
    331417    PATH_OPTNAME = 'path'      
    332      
    333     DEFAULT_CLIENT_ENV_KEYNAME = \ 
    334         MyProxyClientMiddleware.DEFAULT_CLIENT_ENV_KEYNAME 
    335      
    336418    DEFAULT_PATH = '/myproxy/get-trustroots' 
    337419     
     
    366448        @param app_conf: PasteDeploy application specific configuration  
    367449        dictionary 
     450         
     451        @rtype: myproxy.server.wsgi.middleware.MyProxyGetTrustRootsMiddleware 
     452        @return: an instance of this middleware 
    368453        """ 
    369454        app = cls(app) 
     
    421506        @type start_response: function 
    422507        @param start_response: standard WSGI start response function 
     508         
     509        @rtype: list 
     510        @return: get trust roots response 
    423511        ''' 
    424512        # Skip if path doesn't match 
     
    463551         
    464552        @rtype: basestring 
    465         @return: trust roots formatted as a HTTP response 
     553        @return: trust roots base64 encoded and concatenated together 
     554        @raise MyProxyGetTrustRootsMiddlewareError: socket error with backend 
     555        MyProxy server 
     556        @raise MyProxyClientError: error response received by MyProxyClient 
     557        instance 
    466558        """ 
    467559        try: 
Note: See TracChangeset for help on using the changeset viewer.