Ejemplo n.º 1
0
def migrate_root_uf(self):
    # Acquire parent user folder.
    parent = self.getPhysicalRoot()
    uf = getToolByName(parent, 'acl_users')
    if IPluggableAuthService.providedBy(uf):
        # It's a PAS already, fixup if needed.
        pas_fixup(parent)

        # Configure Challenge Chooser plugin if available
        challenge_chooser_setup(parent)
        return

    if not uf.meta_type == 'User Folder':
        # It's not a standard User Folder at the root. Nothing we can do.
        return

    # It's a standard User Folder, replace it.
    replace_acl_users(parent)

    # Get the new uf
    uf = getToolByName(parent, 'acl_users')

    pas = uf.manage_addProduct['PluggableAuthService']
    plone_pas = uf.manage_addProduct['PlonePAS']
    # Setup authentication plugins
    setupAuthPlugins(parent, pas, plone_pas,
                     deactivate_basic_reset=False,
                     deactivate_cookie_challenge=True)

    # Activate *all* interfaces for user manager. IUserAdder is not
    # activated for some reason by default.
    activatePluginInterfaces(parent, 'users')

    # Configure Challenge Chooser plugin if available
    challenge_chooser_setup(parent)
    def afterSetUp(self):
        # Upgrade the UserFolder to a PAS
        from Products.PluggableAuthService.Extensions.upgrade import replace_acl_users
        replace_acl_users(self.app)
        from Products.PluggableAuthService.interfaces.plugins import IGroupsPlugin, IGroupEnumerationPlugin
        self.uf = self.app.acl_users
        if not self.uf.hasObject('groups'):
            factory = self.uf.manage_addProduct['PluggableAuthService']
            factory.addZODBGroupManager('groups')
            plugins = self.uf.plugins
            plugins.activatePlugin(IGroupsPlugin, 'groups')
            plugins.activatePlugin(IGroupEnumerationPlugin, 'groups')


        # Add the session objects
        ZopeTestCase.utils.setupCoreSessions(self.app)

        from jcu.shibboleth.pas.plugin import ShibbolethHelper
        shib = ShibbolethHelper('shib', 'Shibboleth Helper')
        self.app.acl_users.acl_users['shib'] = shib

        # Setup attribute map resolver
        path = os.path.dirname(jcu.shibboleth.pas.__file__)
        self.uf.shib.shibboleth_config_dir = os.path.join(path, 'tests', 'shib2')

        self.shib = self.app.acl_users.shib
    def afterSetUp(self):
        # Upgrade the UserFolder to a PAS
        from Products.PluggableAuthService.Extensions.upgrade import replace_acl_users
        replace_acl_users(self.app.test_folder_1_)
        from Products.PluggableAuthService.interfaces.plugins import IGroupsPlugin, IGroupEnumerationPlugin, IUserEnumerationPlugin, IAuthenticationPlugin, IRolesPlugin
        from Products.PluggableAuthService.interfaces.plugins import ICredentialsUpdatePlugin, ICredentialsResetPlugin, IExtractionPlugin, IChallengePlugin
        self.uf = self.app.test_folder_1_.acl_users
        self.uf.roles.assignRoleToPrincipal('Manager', user_name)
        plugins = self.uf.plugins
        factory = self.uf.manage_addProduct['PluggableAuthService']
        if not self.uf.hasObject('groups'):
            factory.addZODBGroupManager('groups')
            plugins.activatePlugin(IGroupsPlugin, 'groups')
            plugins.activatePlugin(IGroupEnumerationPlugin, 'groups')
        if not self.uf.hasObject('cookies'):
            factory.addCookieAuthHelper('cookies')
            #plugins.activatePlugin(ICredentialsUpdatePlugin, 'cookies')
            #plugins.activatePlugin(ICredentialsResetPlugin, 'cookies')
            plugins.activatePlugin(IExtractionPlugin, 'cookies')
        if not self.uf.hasObject('basic_auth'):
            factory.addHTTPBasicAuthHelper('basic_auth')
            #plugins.activatePlugin(ICredentialsUpdatePlugin, 'cookies')
            #plugins.activatePlugin(ICredentialsResetPlugin, 'cookies')
            plugins.activatePlugin(IExtractionPlugin, 'basic_auth')
            plugins.activatePlugin(IChallengePlugin, 'basic_auth')

        zcml.load_site()
        zcml.load_config('configure.zcml', jcu.shibboleth.pas)
        installPackage('jcu.shibboleth.pas')

        # Add the session objects
        ZopeTestCase.utils.setupCoreSessions(self.app)

        from jcu.shibboleth.pas.plugin import ShibbolethHelper
        shib = ShibbolethHelper('shib', 'Shibboleth Helper')
        self.app.test_folder_1_.acl_users['shib'] = shib
        plugins.activatePlugin(IExtractionPlugin, 'shib')
        plugins.activatePlugin(IAuthenticationPlugin, 'shib')
        plugins.activatePlugin(IChallengePlugin, 'shib')
        plugins.activatePlugin(IRolesPlugin, 'shib')
        plugins.activatePlugin(IUserEnumerationPlugin, 'shib')
        #plugins.activatePlugin(IChallengePlugin, 'basic_auth')

        # Setup attribute map resolver
        path = os.path.dirname(jcu.shibboleth.pas.__file__)
        self.app.test_folder_1_.acl_users.shib.shibboleth_config_dir = os.path.join(path, 'tests', 'shib2')
    def afterSetUp(self):
        # Upgrade the UserFolder to a PAS
        from Products.PluggableAuthService.Extensions.upgrade import replace_acl_users
        replace_acl_users(self.app.test_folder_1_)
        from Products.PluggableAuthService.interfaces.plugins import IGroupsPlugin, IGroupEnumerationPlugin
        self.uf = self.app.test_folder_1_.acl_users
        self.uf.roles.assignRoleToPrincipal('Manager', user_name)
        if not self.uf.hasObject('groups'):
            factory = self.uf.manage_addProduct['PluggableAuthService']
            factory.addZODBGroupManager('groups')
            plugins = self.uf.plugins
            plugins.activatePlugin(IGroupsPlugin, 'groups')
            plugins.activatePlugin(IGroupEnumerationPlugin, 'groups')

        zcml.load_site()
        installPackage('jcu.shibboleth.pas')

        # Add the session objects
        ZopeTestCase.utils.setupCoreSessions(self.app)