[Zope-CVS] CVS: Products/PluggableAuthService -
PluggableAuthService.py:1.7
Zachery Bir
zbir at urbanape.com
Mon Aug 30 11:24:52 EDT 2004
Update of /cvs-repository/Products/PluggableAuthService
In directory cvs.zope.org:/tmp/cvs-serv18334
Modified Files:
PluggableAuthService.py
Log Message:
- fix the missing arrows bug
- fix the broken assumption in searchPrincipals (that a plugin can
do user enumeration or group enumeration, but not both)
- PAS adds the 'Authenticated' Role, not any IRolesPlugin plugin.
=== Products/PluggableAuthService/PluggableAuthService.py 1.6 => 1.7 ===
--- Products/PluggableAuthService/PluggableAuthService.py:1.6 Mon Aug 30 09:22:41 2004
+++ Products/PluggableAuthService/PluggableAuthService.py Mon Aug 30 11:24:52 2004
@@ -17,6 +17,8 @@
$Id$
"""
+import sys
+
from Acquisition import Implicit, aq_parent, aq_base, aq_inner
from AccessControl import ClassSecurityInfo, ModuleSecurityInfo
@@ -27,7 +29,8 @@
from AccessControl.User import nobody
from AccessControl.SpecialUsers import emergency_user
-import sys
+from App.ImageFile import ImageFile
+
from zLOG import LOG, WARNING
from zExceptions import Unauthorized
from Persistence import PersistentMapping
@@ -117,7 +120,7 @@
return creds
InitializeClass( DumbHTTPExtractor )
-
+
class EmergencyUserAuthenticator( Implicit ):
@@ -146,7 +149,7 @@
InitializeClass( EmergencyUserAuthenticator )
-
+
class PluggableAuthService( Folder ):
""" All-singing, all-dancing user folder.
@@ -163,7 +166,15 @@
_nobody = nobody
maxlistusers = -1 # Don't allow local role form to try to list us!
-
+
+ #
+ # ZMI
+ #
+ arrow_right_gif = ImageFile( 'www/arrow-right.gif', globals() )
+ arrow_left_gif = ImageFile( 'www/arrow-left.gif', globals() )
+ arrow_up_gif = ImageFile( 'www/arrow-up.gif', globals() )
+ arrow_down_gif = ImageFile( 'www/arrow-down.gif', globals() )
+
def getId( self ):
return self._id
@@ -254,7 +265,7 @@
else:
return None
- if self._authorizeUser( user
+ if self._authorizeUser( user
, accessed
, container
, name
@@ -288,7 +299,7 @@
exact_match = kw.get( 'exact_match', False )
search_id = kw.get( 'id', None )
search_name = kw.get( 'name', None )
-
+
if exact_match and search_id:
plugin_id, principal_id = self._unmangleId( search_id )
plugin = getattr( self, plugin_id, None )
@@ -313,7 +324,7 @@
'UserEnumerationPlugin %s error' % plugin_id,
error=sys.exc_info())
return ()
-
+
result = []
max_results = kw.get('max_results', '')
sort_by = kw.get('sort_by', '')
@@ -331,7 +342,7 @@
plugins = self._getOb( 'plugins' )
enumerators = plugins.listPlugins( IUserEnumerationPlugin )
-
+
for enumerator_id, enum in enumerators:
try:
user_list = enum.enumerateUsers(**kw)
@@ -343,7 +354,7 @@
info[ 'principal_type' ] = 'user'
info[ 'title' ] = info[ 'login' ]
result.append(info)
-
+
except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
LOG('PluggableAuthService', WARNING,
'UserEnumerationPlugin %s error' % enumerator_id,
@@ -369,7 +380,7 @@
exact_match = kw.get( 'exact_match', False )
search_id = kw.get( 'id', None )
search_name = kw.get( 'name', None )
-
+
if exact_match and search_id:
plugin_id, principal_id = self._unmangleId( search_id )
plugin = getattr( self, plugin_id, None )
@@ -394,7 +405,7 @@
'GroupEnumerationPlugin %s error' % plugin_id,
error=sys.exc_info())
return ()
-
+
result = []
max_results = kw.get('max_results', '')
sort_by = kw.get('sort_by', '')
@@ -456,24 +467,29 @@
kw['login'] = search_name
if exact_match and search_id:
+ user_info = group_info = ()
+
plugin_id, principal_id = self._unmangleId( search_id )
plugin = getattr( self, plugin_id, None )
if plugin is not None:
if getattr( aq_base( plugin ), 'enumerateUsers', None ):
- enumeratePrincipals = plugin.enumerateUsers
- local_key = 'userid'
- principal_type = 'user'
- title_key = 'login'
- title_pattern = "%s"
- else:
- enumeratePrincipals = plugin.enumerateGroups
- local_key = 'groupid'
- principal_type = 'group'
- title_key = 'groupid'
- title_pattern = "(Group) %s"
+ user_info = plugin.enumerateUsers( id=principal_id
+ , exact_match=True )
+ if user_info:
+ local_key = 'userid'
+ principal_type = 'user'
+ title_key = 'login'
+ title_pattern = "%s"
+ if getattr( aq_base( plugin ), 'enumerateGroups', None ):
+ group_info = plugin.enumerateGroups( id=principal_id
+ , exact_match=True )
+ if group_info:
+ local_key = 'groupid'
+ principal_type = 'group'
+ title_key = 'groupid'
+ title_pattern = "(Group) %s"
try:
- principal_info = enumeratePrincipals( id=principal_id
- , exact_match=True )
+ principal_info = filter(None, (user_info + group_info))
assert( len( principal_info ) in [ 0, 1 ] )
if principal_info:
principal_info = principal_info[ 0 ]
@@ -543,7 +559,7 @@
manage_options = ( Folder.manage_options[:1]
+ ( { 'label' : 'Search'
, 'action': 'manage_search' }
- ,
+ ,
)
+ Folder.manage_options[2:]
)
@@ -712,7 +728,7 @@
security.declarePrivate( '_unmangleId' )
def _unmangleId( self, mangled_id ):
-
+
return mangled_id.split( MANGLE_DELIMITER, 1 )
security.declarePrivate( '_mangleId' )
@@ -724,14 +740,14 @@
def _computeMangledId( self, info_dict ):
""" Synthesize an from info_dict.
-
+
o Mangle plugin and original id together.
"""
return self._mangleId( info_dict[ 'pluginid' ], info_dict[ 'id' ] )
security.declarePrivate( '_tryEmergencyUserAuthentication' )
def _tryEmergencyUserAuthentication( self, credentials ):
-
+
""" credentials -> emergency_user or None
"""
try:
@@ -841,7 +857,7 @@
groups = self._getGroupsForPrincipal( user, request
, plugins=plugins )
user._addGroups( groups )
-
+
rolemakers = plugins.listPlugins( IRolesPlugin )
for rolemaker_id, rolemaker in rolemakers:
@@ -853,6 +869,7 @@
if roles:
user._addRoles( roles )
+ user._addRoles( ['Authenticated'] )
cache[ user_id ] = user
return user.__of__( self )
@@ -1009,7 +1026,7 @@
plugins = self._getOb( 'plugins' )
useradders = plugins.listPlugins( IUserAdderPlugin )
roleassigners = plugins.listPlugins( IRoleAssignerPlugin )
-
+
user = None
if not (useradders and roleassigners):
More information about the Zope-CVS
mailing list