Back to index

plone3  3.1.7
__init__.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights
00004 # Reserved.
00005 #
00006 # This software is subject to the provisions of the Zope Public License,
00007 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this
00008 # distribution.
00009 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00010 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00011 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00012 # FOR A PARTICULAR PURPOSE.
00013 #
00014 ##############################################################################
00015 """ PluggableAuthService product initialization.
00016 
00017 $Id: __init__.py 79440 2007-09-02 19:08:46Z jens $
00018 """
00019 
00020 from utils import allTests
00021 
00022 from AccessControl.Permissions import manage_users as ManageUsers
00023 
00024 from Products.PluginRegistry import PluginRegistry
00025 
00026 from PluggableAuthService import registerMultiPlugin
00027 
00028 import PluggableAuthService
00029 
00030 from permissions import ManageGroups
00031 
00032 from plugins import HTTPBasicAuthHelper as HBAH
00033 from plugins import InlineAuthHelper as IAH
00034 from plugins import CookieAuthHelper as CAH
00035 from plugins import SessionAuthHelper as SAH
00036 from plugins import DomainAuthHelper as DAH
00037 from plugins import ScriptablePlugin
00038 from plugins import ZODBGroupManager
00039 from plugins import ZODBUserManager
00040 from plugins import ZODBRoleManager
00041 from plugins import LocalRolePlugin
00042 from plugins import DelegatingMultiPlugin as DMP
00043 from plugins import SearchPrincipalsPlugin as SPP
00044 from plugins import RecursiveGroupsPlugin as RGP
00045 from plugins import DynamicGroupsPlugin as DGP
00046 from plugins import ChallengeProtocolChooser as CPC
00047 from plugins import RequestTypeSniffer as RTS
00048 
00049 registerMultiPlugin(HBAH.HTTPBasicAuthHelper.meta_type)
00050 registerMultiPlugin(IAH.InlineAuthHelper.meta_type)
00051 registerMultiPlugin(DAH.DomainAuthHelper.meta_type)
00052 registerMultiPlugin(SAH.SessionAuthHelper.meta_type)
00053 registerMultiPlugin(CAH.CookieAuthHelper.meta_type)
00054 registerMultiPlugin(ScriptablePlugin.ScriptablePlugin.meta_type)
00055 registerMultiPlugin(ZODBGroupManager.ZODBGroupManager.meta_type)
00056 registerMultiPlugin(ZODBUserManager.ZODBUserManager.meta_type)
00057 registerMultiPlugin(ZODBRoleManager.ZODBRoleManager.meta_type)
00058 registerMultiPlugin(LocalRolePlugin.LocalRolePlugin.meta_type)
00059 registerMultiPlugin(DMP.DelegatingMultiPlugin.meta_type)
00060 registerMultiPlugin(SPP.SearchPrincipalsPlugin.meta_type)
00061 registerMultiPlugin(RGP.RecursiveGroupsPlugin.meta_type)
00062 registerMultiPlugin(DGP.DynamicGroupsPlugin.meta_type)
00063 registerMultiPlugin(CPC.ChallengeProtocolChooser.meta_type)
00064 registerMultiPlugin(RTS.RequestTypeSniffer.meta_type)
00065 
00066 try:
00067     from Products.GenericSetup import profile_registry
00068     from Products.GenericSetup import BASE
00069     from Products.GenericSetup.tool import SetupTool
00070 except ImportError:
00071     profile_registry = None
00072 else:
00073     registerMultiPlugin(SetupTool.meta_type)
00074 
00075 # monkey patch Zope to cause zmi logout to be PAS-aware
00076 from App.Management import Navigation
00077 from interfaces.authservice import IPluggableAuthService
00078 from zExceptions import Unauthorized
00079 
00080 def manage_zmi_logout(self, REQUEST, RESPONSE):
00081     """Logout current user"""
00082     p = getattr(REQUEST, '_logout_path', None)
00083     if p is not None:
00084         return apply(self.restrictedTraverse(p))
00085 
00086     acl_users = self.acl_users
00087     realm=RESPONSE.realm
00088     RESPONSE.setHeader('WWW-Authenticate', 'basic realm="%s"' % realm, 1)
00089 
00090     if IPluggableAuthService.providedBy(acl_users):
00091         acl_users.resetCredentials(REQUEST, RESPONSE)
00092     else:
00093         raise Unauthorized, '<p>You have been logged out.</p>'
00094 
00095     RESPONSE.setStatus(401)
00096     RESPONSE.setBody("""<html>
00097 <head><title>Logout</title></head>
00098 <body>
00099 <p>
00100 You have been logged out.
00101 </p>
00102 </body>
00103 </html>""")
00104 
00105 Navigation.manage_zmi_logout = manage_zmi_logout
00106 del manage_zmi_logout
00107 
00108 def initialize(context):
00109 
00110     context.registerClass( PluggableAuthService.PluggableAuthService
00111                          , permission=ManageUsers
00112                          , constructors=(
00113                             PluggableAuthService.addPluggableAuthService, )
00114                          , icon='www/PluggableAuthService.png'
00115                          )
00116 
00117     context.registerClass( HBAH.HTTPBasicAuthHelper
00118                          , permission=ManageUsers
00119                          , constructors=(
00120                             HBAH.manage_addHTTPBasicAuthHelperForm,
00121                             HBAH.addHTTPBasicAuthHelper, )
00122                          , visibility=None
00123                          , icon='plugins/www/HTTPBasicAuthHelper.png'
00124                          )
00125 
00126     context.registerClass( IAH.InlineAuthHelper
00127                          , permission=ManageUsers
00128                          , constructors=(
00129                             IAH.manage_addInlineAuthHelperForm,
00130                             IAH.addInlineAuthHelper, )
00131                          , visibility=None
00132                          , icon='plugins/www/InlineAuthHelper.png'
00133                          )
00134 
00135     context.registerClass( CAH.CookieAuthHelper
00136                          , permission=ManageUsers
00137                          , constructors=(
00138                             CAH.manage_addCookieAuthHelperForm,
00139                             CAH.addCookieAuthHelper, )
00140                          , visibility=None
00141                          , icon='plugins/www/CookieAuthHelper.gif'
00142                          )
00143 
00144     context.registerClass( DAH.DomainAuthHelper
00145                          , permission=ManageUsers
00146                          , constructors=(
00147                             DAH.manage_addDomainAuthHelperForm,
00148                             DAH.manage_addDomainAuthHelper, )
00149                          , visibility=None
00150                          , icon='plugins/www/DomainAuthHelper.png'
00151                          )
00152 
00153     context.registerClass( SAH.SessionAuthHelper
00154                          , permission=ManageUsers
00155                          , constructors=(
00156                             SAH.manage_addSessionAuthHelperForm,
00157                             SAH.manage_addSessionAuthHelper, )
00158                          , visibility=None
00159                          , icon='plugins/www/SessionAuthHelper.gif'
00160                          )
00161 
00162     context.registerClass( ScriptablePlugin.ScriptablePlugin
00163                          , permission=ManageUsers
00164                          , constructors=(
00165                             ScriptablePlugin.manage_addScriptablePluginForm,
00166                             ScriptablePlugin.addScriptablePlugin, )
00167                          , visibility=None
00168                          , icon='plugins/www/ScriptablePlugin.png'
00169                          )
00170 
00171     context.registerClass( ZODBGroupManager.ZODBGroupManager
00172                          , permission=ManageGroups
00173                          , constructors=(
00174                             ZODBGroupManager.manage_addZODBGroupManagerForm,
00175                             ZODBGroupManager.addZODBGroupManager, )
00176                          , visibility=None
00177                          , icon='plugins/www/ZODBGroupManager.gif'
00178                          )
00179 
00180     context.registerClass( ZODBUserManager.ZODBUserManager
00181                          , permission=ManageUsers
00182                          , constructors=(
00183                             ZODBUserManager.manage_addZODBUserManagerForm,
00184                             ZODBUserManager.addZODBUserManager, )
00185                          , visibility=None
00186                          , icon='plugins/www/ZODBUserManager.gif'
00187                          )
00188 
00189     context.registerClass( ZODBRoleManager.ZODBRoleManager
00190                          , permission=ManageUsers
00191                          , constructors=(
00192                             ZODBRoleManager.manage_addZODBRoleManagerForm,
00193                             ZODBRoleManager.addZODBRoleManager, )
00194                          , visibility=None
00195                          , icon='plugins/www/ZODBRoleManager.gif'
00196                          )
00197 
00198     context.registerClass( LocalRolePlugin.LocalRolePlugin
00199                          , permission=ManageUsers
00200                          , constructors=(
00201                             LocalRolePlugin.manage_addLocalRolePluginForm,
00202                             LocalRolePlugin.addLocalRolePlugin, )
00203                          , visibility=None
00204                          , icon='plugins/www/ZODBRoleManager.gif'
00205                          )
00206 
00207     context.registerClass( DMP.DelegatingMultiPlugin
00208                          , permission=ManageUsers
00209                          , constructors=(
00210                             DMP.manage_addDelegatingMultiPluginForm,
00211                             DMP.manage_addDelegatingMultiPlugin, )
00212                          , visibility=None
00213                          , icon='plugins/www/DelegatingMultiPlugin.png'
00214                          )
00215 
00216     context.registerClass( SPP.SearchPrincipalsPlugin
00217                          , permission=ManageUsers
00218                          , constructors=(
00219                             SPP.addSearchPrincipalsPluginForm,
00220                             SPP.addSearchPrincipalsPlugin, )
00221                          , visibility=None
00222                          , icon='plugins/www/DelegatingMultiPlugin.png'
00223                          )
00224 
00225     context.registerClass( RGP.RecursiveGroupsPlugin
00226                          , permission=ManageUsers
00227                          , constructors=(
00228                             RGP.manage_addRecursiveGroupsPluginForm,
00229                             RGP.addRecursiveGroupsPlugin, )
00230                          , visibility=None
00231                          , icon='plugins/www/RecursiveGroupsPlugin.png'
00232                          )
00233 
00234     context.registerClass( DGP.DynamicGroupsPlugin
00235                          , permission=ManageUsers
00236                          , constructors=(
00237                             DGP.manage_addDynamicGroupsPluginForm,
00238                             DGP.addDynamicGroupsPlugin, )
00239                          , visibility=None
00240                          , icon='plugins/www/DynamicGroupsPlugin.png'
00241                          )
00242 
00243     context.registerClass( CPC.ChallengeProtocolChooser
00244                          , permission=ManageUsers
00245                          , constructors=(
00246                             CPC.manage_addChallengeProtocolChooserForm,
00247                             CPC.addChallengeProtocolChooserPlugin, )
00248                          , visibility=None
00249                          , icon='plugins/www/DelegatingMultiPlugin.png'
00250                          )
00251 
00252     context.registerClass( RTS.RequestTypeSniffer
00253                          , permission=ManageUsers
00254                          , constructors=(
00255                             RTS.manage_addRequestTypeSnifferForm,
00256                             RTS.addRequestTypeSnifferPlugin, )
00257                          , visibility=None
00258                          , icon='plugins/www/DelegatingMultiPlugin.png'
00259                          )
00260 
00261     if profile_registry is not None:
00262 
00263         context.registerClass( PluggableAuthService.PluggableAuthService
00264                              , meta_type='Configured PAS'
00265                              , permission=ManageUsers
00266                              , constructors=(
00267                                 PluggableAuthService.addConfiguredPASForm,
00268                                 PluggableAuthService.addConfiguredPAS,
00269                                )
00270                              , icon='www/PluggableAuthService.png'
00271                              )
00272         profile_registry.registerProfile('simple',
00273                                          'Simple PAS Content Profile',
00274                                          'Content for a simple PAS.',
00275                                          'profiles/simple',
00276                                          'PluggableAuthService',
00277                                          BASE,
00278                                          IPluggableAuthService,
00279                                         )
00280         profile_registry.registerProfile('empty',
00281                                          'Empty PAS Content Profile',
00282                                          'Content for an empty PAS '
00283                                          '(plugins registry only).',
00284                                          'profiles/empty',
00285                                          'PluggableAuthService',
00286                                          BASE,
00287                                          IPluggableAuthService,
00288                                         )