File: __init__.py

package info (click to toggle)
zope-pas 1.4-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,084 kB
  • ctags: 1,205
  • sloc: python: 9,373; xml: 348; makefile: 31; sh: 2
file content (288 lines) | stat: -rw-r--r-- 12,422 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights
# Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this
# distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" PluggableAuthService product initialization.

$Id: __init__.py 69264 2006-07-25 22:59:44Z tseaver $
"""

from utils import allTests

from AccessControl.Permissions import manage_users as ManageUsers

from Products.PluginRegistry import PluginRegistry

from PluggableAuthService import registerMultiPlugin

import PluggableAuthService

from permissions import ManageGroups

from plugins import HTTPBasicAuthHelper as HBAH
from plugins import InlineAuthHelper as IAH
from plugins import CookieAuthHelper as CAH
from plugins import SessionAuthHelper as SAH
from plugins import DomainAuthHelper as DAH
from plugins import ScriptablePlugin
from plugins import ZODBGroupManager
from plugins import ZODBUserManager
from plugins import ZODBRoleManager
from plugins import LocalRolePlugin
from plugins import DelegatingMultiPlugin as DMP
from plugins import SearchPrincipalsPlugin as SPP
from plugins import RecursiveGroupsPlugin as RGP
from plugins import DynamicGroupsPlugin as DGP
from plugins import ChallengeProtocolChooser as CPC
from plugins import RequestTypeSniffer as RTS

registerMultiPlugin(HBAH.HTTPBasicAuthHelper.meta_type)
registerMultiPlugin(IAH.InlineAuthHelper.meta_type)
registerMultiPlugin(DAH.DomainAuthHelper.meta_type)
registerMultiPlugin(SAH.SessionAuthHelper.meta_type)
registerMultiPlugin(CAH.CookieAuthHelper.meta_type)
registerMultiPlugin(ScriptablePlugin.ScriptablePlugin.meta_type)
registerMultiPlugin(ZODBGroupManager.ZODBGroupManager.meta_type)
registerMultiPlugin(ZODBUserManager.ZODBUserManager.meta_type)
registerMultiPlugin(ZODBRoleManager.ZODBRoleManager.meta_type)
registerMultiPlugin(LocalRolePlugin.LocalRolePlugin.meta_type)
registerMultiPlugin(DMP.DelegatingMultiPlugin.meta_type)
registerMultiPlugin(SPP.SearchPrincipalsPlugin.meta_type)
registerMultiPlugin(RGP.RecursiveGroupsPlugin.meta_type)
registerMultiPlugin(DGP.DynamicGroupsPlugin.meta_type)
registerMultiPlugin(CPC.ChallengeProtocolChooser.meta_type)
registerMultiPlugin(RTS.RequestTypeSniffer.meta_type)

try:
    from Products.GenericSetup import profile_registry
    from Products.GenericSetup import BASE
    from Products.GenericSetup.tool import SetupTool
except ImportError:
    profile_registry = None
else:
    registerMultiPlugin(SetupTool.meta_type)

# monkey patch Zope to cause zmi logout to be PAS-aware
from App.Management import Navigation
from interfaces.authservice import IPluggableAuthService
from zExceptions import Unauthorized

def manage_zmi_logout(self, REQUEST, RESPONSE):
    """Logout current user"""
    p = getattr(REQUEST, '_logout_path', None)
    if p is not None:
        return apply(self.restrictedTraverse(p))

    acl_users = self.acl_users
    realm=RESPONSE.realm
    RESPONSE.setHeader('WWW-Authenticate', 'basic realm="%s"' % realm, 1)

    if IPluggableAuthService.isImplementedBy(acl_users):
        acl_users.resetCredentials(REQUEST, RESPONSE)
    else:
        raise Unauthorized, '<p>You have been logged out.</p>'

    RESPONSE.setStatus(401)
    RESPONSE.setBody("""<html>
<head><title>Logout</title></head>
<body>
<p>
You have been logged out.
</p>
</body>
</html>""")

Navigation.manage_zmi_logout = manage_zmi_logout
del manage_zmi_logout

def initialize(context):

    context.registerClass( PluggableAuthService.PluggableAuthService
                         , permission=ManageUsers
                         , constructors=(
                            PluggableAuthService.addPluggableAuthService, )
                         , icon='www/PluggableAuthService.png'
                         )

    context.registerClass( HBAH.HTTPBasicAuthHelper
                         , permission=ManageUsers
                         , constructors=(
                            HBAH.manage_addHTTPBasicAuthHelperForm,
                            HBAH.addHTTPBasicAuthHelper, )
                         , visibility=None
                         , icon='plugins/www/HTTPBasicAuthHelper.png'
                         )

    context.registerClass( IAH.InlineAuthHelper
                         , permission=ManageUsers
                         , constructors=(
                            IAH.manage_addInlineAuthHelperForm,
                            IAH.addInlineAuthHelper, )
                         , visibility=None
                         , icon='plugins/www/InlineAuthHelper.png'
                         )

    context.registerClass( CAH.CookieAuthHelper
                         , permission=ManageUsers
                         , constructors=(
                            CAH.manage_addCookieAuthHelperForm,
                            CAH.addCookieAuthHelper, )
                         , visibility=None
                         , icon='plugins/www/CookieAuthHelper.gif'
                         )

    context.registerClass( DAH.DomainAuthHelper
                         , permission=ManageUsers
                         , constructors=(
                            DAH.manage_addDomainAuthHelperForm,
                            DAH.manage_addDomainAuthHelper, )
                         , visibility=None
                         , icon='plugins/www/DomainAuthHelper.png'
                         )

    context.registerClass( SAH.SessionAuthHelper
                         , permission=ManageUsers
                         , constructors=(
                            SAH.manage_addSessionAuthHelperForm,
                            SAH.manage_addSessionAuthHelper, )
                         , visibility=None
                         , icon='plugins/www/SessionAuthHelper.gif'
                         )

    context.registerClass( ScriptablePlugin.ScriptablePlugin
                         , permission=ManageUsers
                         , constructors=(
                            ScriptablePlugin.manage_addScriptablePluginForm,
                            ScriptablePlugin.addScriptablePlugin, )
                         , visibility=None
                         , icon='plugins/www/ScriptablePlugin.png'
                         )

    context.registerClass( ZODBGroupManager.ZODBGroupManager
                         , permission=ManageGroups
                         , constructors=(
                            ZODBGroupManager.manage_addZODBGroupManagerForm,
                            ZODBGroupManager.addZODBGroupManager, )
                         , visibility=None
                         , icon='plugins/www/ZODBGroupManager.gif'
                         )

    context.registerClass( ZODBUserManager.ZODBUserManager
                         , permission=ManageUsers
                         , constructors=(
                            ZODBUserManager.manage_addZODBUserManagerForm,
                            ZODBUserManager.addZODBUserManager, )
                         , visibility=None
                         , icon='plugins/www/ZODBUserManager.gif'
                         )

    context.registerClass( ZODBRoleManager.ZODBRoleManager
                         , permission=ManageUsers
                         , constructors=(
                            ZODBRoleManager.manage_addZODBRoleManagerForm,
                            ZODBRoleManager.addZODBRoleManager, )
                         , visibility=None
                         , icon='plugins/www/ZODBRoleManager.gif'
                         )

    context.registerClass( LocalRolePlugin.LocalRolePlugin
                         , permission=ManageUsers
                         , constructors=(
                            LocalRolePlugin.manage_addLocalRolePluginForm,
                            LocalRolePlugin.addLocalRolePlugin, )
                         , visibility=None
                         , icon='plugins/www/ZODBRoleManager.gif'
                         )

    context.registerClass( DMP.DelegatingMultiPlugin
                         , permission=ManageUsers
                         , constructors=(
                            DMP.manage_addDelegatingMultiPluginForm,
                            DMP.manage_addDelegatingMultiPlugin, )
                         , visibility=None
                         , icon='plugins/www/DelegatingMultiPlugin.png'
                         )

    context.registerClass( SPP.SearchPrincipalsPlugin
                         , permission=ManageUsers
                         , constructors=(
                            SPP.addSearchPrincipalsPluginForm,
                            SPP.addSearchPrincipalsPlugin, )
                         , visibility=None
                         , icon='plugins/www/DelegatingMultiPlugin.png'
                         )

    context.registerClass( RGP.RecursiveGroupsPlugin
                         , permission=ManageUsers
                         , constructors=(
                            RGP.manage_addRecursiveGroupsPluginForm,
                            RGP.addRecursiveGroupsPlugin, )
                         , visibility=None
                         , icon='plugins/www/RecursiveGroupsPlugin.png'
                         )

    context.registerClass( DGP.DynamicGroupsPlugin
                         , permission=ManageUsers
                         , constructors=(
                            DGP.manage_addDynamicGroupsPluginForm,
                            DGP.addDynamicGroupsPlugin, )
                         , visibility=None
                         , icon='plugins/www/DynamicGroupsPlugin.png'
                         )

    context.registerClass( CPC.ChallengeProtocolChooser
                         , permission=ManageUsers
                         , constructors=(
                            CPC.manage_addChallengeProtocolChooserForm,
                            CPC.addChallengeProtocolChooserPlugin, )
                         , visibility=None
                         , icon='plugins/www/DelegatingMultiPlugin.png'
                         )

    context.registerClass( RTS.RequestTypeSniffer
                         , permission=ManageUsers
                         , constructors=(
                            RTS.manage_addRequestTypeSnifferForm,
                            RTS.addRequestTypeSnifferPlugin, )
                         , visibility=None
                         , icon='plugins/www/DelegatingMultiPlugin.png'
                         )

    if profile_registry is not None:

        context.registerClass( PluggableAuthService.PluggableAuthService
                             , meta_type='Configured PAS'
                             , permission=ManageUsers
                             , constructors=(
                                PluggableAuthService.addConfiguredPASForm,
                                PluggableAuthService.addConfiguredPAS,
                               )
                             , icon='www/PluggableAuthService.png'
                             )
        profile_registry.registerProfile('simple',
                                         'Simple PAS Content Profile',
                                         'Content for a simple PAS.',
                                         'profiles/simple',
                                         'PluggableAuthService',
                                         BASE,
                                         IPluggableAuthService,
                                        )
        profile_registry.registerProfile('empty',
                                         'Empty PAS Content Profile',
                                         'Content for an empty PAS '
                                         '(plugins registry only).',
                                         'profiles/empty',
                                         'PluggableAuthService',
                                         BASE,
                                         IPluggableAuthService,
                                        )