Changeset bd5b82 in indico
- Timestamp:
- 06/07/10 18:31:02 (3 years ago)
- Branches:
- master, burotel, hello-world-walkthrough, ipv6, new-webex, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
- Children:
- 083c31
- Parents:
- 0360f4
- git-author:
- David Martín Clavo <david.martin.clavo@…> (04/06/10 15:06:58)
- git-committer:
- Pedro Ferreira <jose.pedro.ferreira@…> (06/07/10 18:31:02)
- Location:
- indico/MaKaC
- Files:
-
- 3 edited
-
authentication/AuthenticationMgr.py (modified) (8 diffs)
-
authentication/baseAuthentication.py (modified) (4 diffs)
-
user.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/authentication/AuthenticationMgr.py
rbdd862 rbd5b82 27 27 28 28 class AuthenticatorMgr: 29 29 30 30 def __init__(self): 31 31 32 32 self.AuthenticatorList = [] 33 33 config = Config.getInstance() … … 39 39 self.AuthenticatorList.append( NiceAuthenticator() ) 40 40 self.create = True 41 42 41 42 43 43 def add( self, newId): 44 44 auth = self.getById( newId.getAuthenticatorTag() ) … … 77 77 return user 78 78 return None 79 79 80 def getAvatarByLogin(self, login, authenticator = None): 81 """ Returns an Avatar object based on the person's login. 82 If authenticator is set, we will only look in the given authenticator. 83 If not set, we will look in all autheticators. 84 If we find this login in more than one authenticator, and there is at least 2 85 different Avatar objects, we will return a dictionary authenticatorName:Avatar object. 86 If nothing is found, we will return None 87 88 :param login: the user login 89 :type login: str 90 91 :param login: the name of an authenticator to use, or a list of authenticator names, or None 92 :type login: str, list or NoneType 93 """ 94 95 if type(authenticator) is str: 96 #only one authenticator 97 auth = self.getById(authenticator) 98 try: 99 return auth.getAvatarByLogin(login) 100 except KeyError: 101 return None 102 103 else: 104 #multiple authenticators, we build a list of authenticators 105 if type(authenticator) is list: 106 authenticatorList = [] 107 for authName in authenticator: 108 authenticatorList.append(self.getById(authName)) 109 else: 110 authenticatorList = self.AuthenticatorList 111 112 #we search for Avatars in each authenticator 113 foundAvatars = {} 114 avatarIdsFound = set() 115 for auth in authenticatorList: 116 try: 117 avatar = auth.getAvatarByLogin(login) 118 foundAvatars[auth.getId().strip()] = avatar 119 avatarIdsFound.add(avatar.getId()) 120 except KeyError: 121 pass 122 123 if foundAvatars: 124 if len(foundAvatars) == 1 or len(avatarIdsFound) == 1: 125 #there's only one different avatar 126 return foundAvatars.values()[0] 127 else: 128 #there's more than 1 avatar, we return a dictionary 129 return foundAvatars 130 else: 131 #we found nothing, we return None 132 return None 133 134 80 135 def isLoginFree( self, login): 81 136 for au in self.AuthenticatorList: … … 86 141 pass 87 142 return True 88 143 89 144 def _getDefaultAuthenticator( self ): 90 return self.AuthenticatorList[0] 91 145 return self.AuthenticatorList[0] 146 92 147 def getList(self): 93 148 return self.AuthenticatorList … … 98 153 auth = self._getDefaultAuthenticator() 99 154 return auth.createIdentity(li, avatar) 100 155 101 156 def removeIdentity( self, Id): 102 157 #check if there is almost another one identity … … 104 159 auth = self.getById(Id.getAuthenticatorTag()) 105 160 auth.remove(Id) 106 161 107 162 def getIdentityById(self, id): 108 163 for auth in self.AuthenticatorList: … … 124 179 return av 125 180 return None 126 181 127 182 def autoLogout(self, rh): 128 183 authId = rh._getSession().getVar("autoLogin") … … 132 187 return auth.autoLogout(rh) 133 188 134 189 -
indico/MaKaC/authentication/baseAuthentication.py
rbdd862 rbd5b82 39 39 40 40 def getAvatar( self, li ): 41 41 """ Returns an Avatar object, checking that the password is right. 42 43 :param li: a LoginInfo object with the person's login string and password 44 :type li: MaKaC.user.LoginInfo 45 """ 46 42 47 identity = self.getById( li.getLogin() ) 43 48 return identity.authenticate( li ) … … 47 52 # return None 48 53 #return identity.authenticate( li ) 49 54 55 def getAvatarByLogin(self, login): 56 """ Returns an Avatar object, WITHOUT checking the password! 57 Will throw KeyError if not found. 58 59 :param login: the person's login string 60 :type login: str 61 """ 62 return self.getById(login).getUser() 63 50 64 def getIdx(self): 51 65 return self._getIdx() 52 66 53 67 def getId(self): 54 68 return self.id 55 69 getId = classmethod( getId ) 56 70 57 71 def getName(self): 58 72 return self.name 59 73 60 74 def getDescription(self): 61 75 return self.description 62 76 63 77 def getUserCreator(self): 64 78 return self.UserCreator 65 79 66 80 def autoLogin(self, rh): 67 81 return None 68 82 69 83 def autoLogout(self, rh): 70 84 return None … … 74 88 75 89 class PIdentity(Persistent): 76 90 77 91 def __init__(self, login, user): 78 92 self.setLogin( login ) … … 88 102 def getUser(self): 89 103 return self.user 90 104 91 105 def setLogin(self, newLogin): 92 106 self.login = newLogin.strip() -
indico/MaKaC/user.py
r2adefc rbd5b82 1101 1101 1102 1102 def addIdentity(self, newId): 1103 """ Adds a new identity to this Avatar. 1104 :param newId: a new PIdentity or inheriting object 1105 :type newId: PIdentity 1106 """ 1103 1107 if newId != None and (newId not in self.identities): 1104 1108 self.identities.append( newId ) … … 1106 1110 1107 1111 def removeIdentity(self, Id): 1112 """ Removed an identity from this Avatar. 1113 :param newId: a PIdentity or inheriting object 1114 :type newId: PIdentity 1115 """ 1108 1116 if Id in self.identities: 1109 1117 self.identities.remove(Id) … … 1111 1119 1112 1120 def getIdentityList( self ): 1121 """ Returns a list of identities for this Avatar. 1122 Each identity will be a PIdentity or inheriting object 1123 """ 1113 1124 return self.identities 1114 1125 1126 def getIdentityByAuthenticatorName(self, authenticatorName): 1127 """ Return a list of PIdentity objects given an authenticator name 1128 :param authenticatorName: the name of an authenticator, e.g. 'Local', 'Nice', etc 1129 :type authenticatorName: str 1130 """ 1131 result = [] 1132 for identity in self.identities: 1133 if identity.getAuthenticatorTag() == authenticatorName: 1134 result.append(identity) 1135 return result 1136 1137 1115 1138 def getIdentityById(self, id, tag): 1139 """ Returns a PIdentity object given an authenticator name and the identity's login 1140 :param id: the login string for this identity 1141 :type id: str 1142 :param tag: the name of an authenticator, e.g. 'Local', 'Nice', etc 1143 :type tag: str 1144 """ 1145 1116 1146 for Id in self.identities: 1117 1147 if Id.getAuthenticatorTag() == tag and Id.getLogin() == id:
Note: See TracChangeset
for help on using the changeset viewer.
