Changeset 4559 for TI12-security/trunk/python
- Timestamp:
- 08/12/08 10:02:52 (12 years ago)
- Location:
- TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/openid/provider
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI12-security/trunk/python/ndg.security.server/ndg/security/server/wsgi/openid/provider/__init__.py
r4554 r4559 135 135 other specific exception types. 136 136 """ 137 raise NotImplementedError( self.logon.__doc__.replace('\n ',''))137 raise NotImplementedError() 138 138 139 139 def username2UserIdentifiers(self, environ, username): … … 162 162 other specific exception types. 163 163 """ 164 raise NotImplementedError( 165 self.username2UserIdentifiers.__doc__.replace('\n ','')) 166 167 168 class BasicAuthNInterface(AbstractAuthNInterface): 169 '''Basic Authentication interface class for OpenIDProviderMiddleware 170 171 it uses username/password details retrieved from config file / keyword 172 entry. This class is for testing only. NOT for production use''' 173 174 def __init__(self, **prop): 175 """Make any initial settings 176 177 Settings are held in a dictionary which can be set from **prop, 178 a call to setProperties() or by passing settings in an XML file 179 given by propFilePath 180 181 @type **prop: dict 182 @param **prop: set properties via keywords 183 @raise AuthNInterfaceConfigError: error with configuration 184 """ 185 # Test/Admin username/password set from ini/kw args 186 userCreds = prop.get('userCreds') 187 if userCreds: 188 self._userCreds = dict([i.strip().split(':') 189 for i in userCreds.split(',')]) 190 else: 191 raise AuthNInterfaceConfigError('No "userCreds" config option ' 192 "found") 193 194 user2Identifier = prop.get('username2UserIdentifiers') 195 if user2Identifier: 196 self._username2Identifier = {} 197 for i in user2Identifier.split(): 198 username, identifierStr = i.strip().split(':') 199 identifiers = tuple(identifierStr.split(',')) 200 self._username2Identifier[username] = identifiers 201 else: 202 raise AuthNInterfaceConfigError('No "user2Identifier" config ' 203 'option found') 204 205 userCredNames = self._userCreds.keys() 206 userCredNames.sort() 207 username2IdentifierNames = self._username2Identifier.keys() 208 username2IdentifierNames.sort() 209 if userCredNames != username2IdentifierNames: 210 raise AuthNInterfaceConfigError('Mismatch between usernames in ' 211 '"userCreds" and ' 212 '"username2UserIdentifiers" options') 213 214 def logon(self, environ, userIdentifier, username, password): 215 """Interface login method 216 217 @type environ: dict 218 @param environ: standard WSGI environ parameter 219 220 @type username: basestring 221 @param username: user identifier 222 223 @type password: basestring 224 @param password: corresponding password for username givens 225 226 @raise AuthNInterfaceInvalidCredentials: invalid username/password 227 """ 228 if self._userCreds.get(username) != password: 229 raise AuthNInterfaceInvalidCredentials() 230 231 if userIdentifier is not None and \ 232 userIdentifier not in self._username2Identifier.get(username): 233 raise AuthNInterfaceUsername2IdentifierMismatch() 234 235 def username2UserIdentifiers(self, environ, username): 236 """Map the login username to an identifier which will become the 237 unique path suffix to the user's OpenID identifier. The 238 OpenIDProviderMiddleware takes self.urls['id_url'] and adds it to this 239 identifier: 240 241 identifier = self._authN.username2UserIdentifiers(environ,username) 242 identityURL = self.urls['url_id'] + '/' + identifier 243 244 @type environ: dict 245 @param environ: standard WSGI environ parameter 246 247 @type username: basestring 248 @param username: user identifier 249 250 @rtype: tuple 251 @return: identifiers to be used to make OpenID user identity URLs. 252 253 @raise AuthNInterfaceRetrieveError: error with retrieval of information 254 to identifier e.g. error with database look-up. 255 """ 256 try: 257 return self._username2Identifier[username] 258 except KeyError: 259 raise AuthNInterfaceRetrieveError('No entries for "%s" user' % 260 username) 164 raise NotImplementedError() 261 165 262 166
Note: See TracChangeset
for help on using the changeset viewer.