[Grok-dev] megrok.login: substituting authenticator

Uli Fouquet uli at gnufix.de
Wed Sep 8 08:43:39 EDT 2010


Hi Aroldo,

Aroldo Souza-Leite wrote:

> I'm trying to understand a little of what happens in the "test.simple" 
> case before I can think of how much of 'megrok.login' I need to customize.
> 
> I understand that at some point a 
> 'megrok.login.authplugins.PrincipalRegistryAuthenticator' instance gets 
> automagically registered in the component architecture as a utility 
> providing
> 
> 'zope.pluggableauth.interfaces.IAuthenticatorPlugin',

No, I'm afraid this is a misunderstanding. The
PrincipalRegistryAuthenticator, that authenticates against global
principals defined in the global principal registry, is not a utility
(in the ZCA sense). It's a simple object instance, directly added to the
PAU during setup (see megrok.login.authplugins).

As you certainly know, a PAU (as a BTree) can store plugins in itself
and you can tell a PAU to register a plugin by providing a list of
names. These names can be names of (named) utilities _or_ names of
instances of some plugin stored in the PAU under that name directly. For
the mentioned plugin the latter applies.

> but I didn't manage to retrieve this utility in the 
> 'interactive_debugger' using 'sm=app.getSiteManager() and 
> 'u=sm.getUtility(IAuthenticationPlugin)' from the persistent 'Simple' 
> application of from any other site manager I got hold of. Which site 
> manager in the framework has this utility, or where is it registered?

The setup code is in megrok.login.grokkers.setupPAU. The setup itself is
triggered by authenticationSubscriber in the same module. The PAU is
registered under the name 'megrok_login_pau' in any grok.Application on
creation (if megrok.enable() is used) and gets a
PrincipalRegistryAuthenticator instance under the name
'readonly_principals' (see setupPAU()).

So, normally you should get the principal registry with something like

  >>> sm = root['mysite'].getSiteManager()
  >>> sm['megrok_login_pau']['readonly_principals']
  <megrok.login.authplugins.PrincipalRegistryAuthenticator object ...>

Hope that helps,

-- 
Uli

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20100908/b3c18c7c/attachment.bin 


More information about the Grok-dev mailing list