Ignore:
Timestamp:
16/06/06 11:38:22 (14 years ago)
Author:
pjkersha
Message:

Tests/AttAuthorityIOtest.py: added testTrustedHosts3 to test results from livglue

Tests/security.py: returnURI input to init isn't needed - it can be picked up from as a form variable.

NDG/SecurityCGI.py: returnCreds renamed to returnCredsResponse. This method now checks the domain of the input
cookie. If this matches that of the returnURI, then there is no need to return the cookie information as they
can share the cookie.

NDG/Session.py: Created a metaclass _MetaUserSession for UserSession?. This enables UserSession? to have read-
only class variables - e.g. "cookieTags"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/python/NDG/Session.py

    r1180 r1203  
    7171    def __str__(self): 
    7272        return self.__msg 
     73     
     74     
     75#_____________________________________________________________________________ 
     76class _MetaUserSession(type): 
     77    """Enable UserSession to have read only class variables e.g. 
     78     
     79    print UserSession.cookieTags is allowed but, 
     80     
     81    UserSession.cookieTags = None 
     82     
     83    ... raises - AttributeError: can't set attribute""" 
     84    def __getCookieTags(cls): 
     85        return ("NDG-ID1", "NDG-ID2") 
     86 
     87    cookieTags = property(fget=__getCookieTags) 
    7388 
    7489 
     
    7994    """Session details - created when a user logs into NDG""" 
    8095 
     96    __metaclass__ = _MetaUserSession 
     97     
    8198    # Session ID 
    8299    __sessIDlen = 64 
    83  
    84     __cookieTags = ("NDG-ID1", "NDG-ID2") 
    85100 
    86101    # Follow standard format for cookie path and expiry attributes 
     
    340355            tagValues = (sessID, encrSessMgrWSDLuri) 
    341356            i=0 
    342             for tag in cls.__cookieTags: 
     357            for tag in cls.cookieTags: 
    343358                 
    344359                sessCookie[tag] = tagValues[i] 
     
    350365                                             
    351366                # Make cookie as generic as possible for domains - Nb. '.uk' 
    352                 # alone won't work 
     367                # alone won't work but .rl.ac.uk would 
    353368                if cookieDomain: 
    354369                    sessCookie[tag][cls.__cookieDomainTag] = cookieDomain 
     
    383398                return False 
    384399         
    385         missingTags = [tag for tag in cls.__cookieTags if tag not in cookie] 
     400        missingTags = [tag for tag in cls.cookieTags if tag not in cookie] 
    386401        if missingTags: 
    387402            if raiseExcep: 
     
    392407                return False 
    393408 
    394         if len(cookie[cls.__cookieTags[0]].value) < cls.__sessIDlen: 
     409        if len(cookie[cls.cookieTags[0]].value) < cls.__sessIDlen: 
    395410            if raiseExcep: 
    396411                raise UserSessionError, "Session ID has an invalid length" 
Note: See TracChangeset for help on using the changeset viewer.