def _extractUserIds( self, request, plugins ): """ request -> [ validated_user_id ] o For each set of extracted credentials, try to authenticate a user; accumulate a list of the IDs of such users over all our authentication and extraction plugins. """ try: extractors = plugins.listPlugins( IExtractionPlugin ) except _SWALLOWABLE_PLUGIN_EXCEPTIONS: logger.debug('Extractor plugin listing error', exc_info=True) extractors = () if not extractors: extractors = ( ( 'default', DumbHTTPExtractor() ), ) try: authenticators = plugins.listPlugins( IAuthenticationPlugin ) except _SWALLOWABLE_PLUGIN_EXCEPTIONS: logger.debug('Authenticator plugin listing error', exc_info=True) authenticators = () result = [] for extractor_id, extractor in extractors: try: credentials = extractor.extractCredentials( request ) except _SWALLOWABLE_PLUGIN_EXCEPTIONS: PluggableAuthService.reraise(extractor) logger.debug( 'ExtractionPlugin %s error' % extractor_id , exc_info=True ) continue if credentials: try: credentials[ 'extractor' ] = extractor_id # XXX: in key? # Test if ObjectCacheEntries.aggregateIndex would work items = credentials.items() items.sort() except _SWALLOWABLE_PLUGIN_EXCEPTIONS: # XXX: would reraise be good here, and which plugin to ask # whether not to swallow the exception - the extractor? logger.debug( 'Credentials error: %s' % credentials , exc_info=True ) continue # First try to authenticate against the emergency # user and return immediately if authenticated user_id, name = self._tryEmergencyUserAuthentication( credentials ) if user_id is not None: return [ ( user_id, name ) ] # Now see if the user ids can be retrieved from the cache credentials['login'] = self.applyTransform( credentials.get('login') ) view_name = createViewName('_extractUserIds', credentials.get('login')) keywords = createKeywords(**credentials) user_ids = self.ZCacheable_get( view_name=view_name , keywords=keywords , default=None ) if user_ids is None: user_ids = [] for authenticator_id, auth in authenticators: try: uid_and_info = auth.authenticateCredentials( credentials ) # logger.info('plugin: %s' % str(auth.id)) # logger.info('uid_and_info: %s' % str(uid_and_info)) # Modificamos este codigo para que si la respuesta del oauthTokenRetriever mrs5.max.auth.py es BadUsernameOrPasswordError # no continue mirando los siguientes plugins de Authentication Plugins if auth.id == 'paspreauth' and uid_and_info == 'BadUsernameOrPasswordError' : break if uid_and_info is None: continue user_id, info = uid_and_info except _SWALLOWABLE_PLUGIN_EXCEPTIONS: PluggableAuthService.reraise(auth) msg = 'AuthenticationPlugin %s error' % ( authenticator_id, ) logger.debug(msg, exc_info=True) continue if user_id is not None: user_ids.append( (user_id, info) ) if user_ids: self.ZCacheable_set( user_ids , view_name=view_name , keywords=keywords ) result.extend( user_ids ) # Emergency user via HTTP basic auth always wins user_id, name = self._tryEmergencyUserAuthentication( DumbHTTPExtractor().extractCredentials( request ) ) if user_id is not None: return [ ( user_id, name ) ] return result