Exemple #1
0
 def getGroupMembers(self):
     # All references and all subobjects that are members
     mems = self.getRefs(GROUP_RELATIONSHIP)
     mem_dict = dict.fromkeys(
         [user_ifaces.IMembraneUserAuth(m).getUserId() for m in mems])
     mbtool = getToolByName(self, TOOLNAME)
     mems = mbtool.unrestrictedSearchResults(
         object_implements=(user_ifaces.IMembraneUserAuth.__identifier__),
         path='/'.join(self.getPhysicalPath()))
     for m in mems:
         mem_dict[m.getUserId] = 1
     return tuple(mem_dict.keys())
Exemple #2
0
 def getGroupMembers(self):
     # All references and all subobjects that are members
     members = dict.fromkeys([
         user_ifaces.IMembraneUserAuth(m).getUserId()
         for m in self.getRefs('participatesInProject')
     ])
     mt = getToolByName(self, TOOLNAME)
     usr = mt.unrestrictedSearchResults
     for m in usr(object_implements=(
             user_ifaces.IMembraneUserAuthAvail.__identifier__),
                  path='/'.join(self.getPhysicalPath())):
         members[m.getUserId] = 1
     return tuple(members.keys())
Exemple #3
0
    def testLockoutPolicy(self):
        sector = createSector(self.portal)
        mbtool = api.portal.get_tool(TOOLNAME)
        member = mbtool.getUserObject(login=sector.login)
        auth = user_ifaces.IMembraneUserAuth(member, None)
        status = IStatusMessage(auth.context.REQUEST)

        auth.applyLockoutPolicy(0)
        self.assertEqual(len(status.show()), 0)
        self.assertFalse(sector.locked)

        auth.applyLockoutPolicy(2)
        self.assertEqual(len(status.show()), 1)
        self.assertEqual(auth.context._v_login_attempts, 1)
        self.assertFalse(sector.locked)

        auth.applyLockoutPolicy(2)
        self.assertEqual(len(status.show()), 1)
        self.assertEqual(auth.context._v_login_attempts, 2)
        self.assertTrue(sector.locked)
Exemple #4
0
    def authenticateCredentials(self, credentials):
        """ See IAuthenticationPlugin.

        o We expect the credentials to be those returned by
          ILoginPasswordExtractionPlugin.
        """
        login = credentials.get('login')

        # We can't depend on security when authenticating the user,
        # or we'll get stuck in loops
        mbtool = getToolByName(self, TOOLNAME)
        member = mbtool.getUserObject(login=login)
        if member is None:
            return None

        # Delegate to member object
        auth = user_ifaces.IMembraneUserAuth(member, None)
        if auth is None:
            return None

        return auth.authenticateCredentials(credentials)