[Grok-dev] megrok.login: substituting authenticator

Aroldo Souza-Leite asouzaleite at gmx.de
Wed Sep 8 06:26:39 EDT 2010


Hi Uli,

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',

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?

Or perhaps I started off my research from false assumptions?


Regards.

Aroldo.





Aroldo Souza-Leite wrote:
> Hi Uli,
>
> I hadn't read the 'megrok.login' documentation attentively enough, 
> sorry, I'm doing it now.
>
> I'm looking for a solution where I can keep using as much as possible 
> of  'megrok.login', just replacing some sort of  megrok.login-default 
> 'athenticateCredentials' method somewhere by my own custom 
> 'authenticateCredentials'  method and leaving the rest untouched as long 
> as the overall result is still logically consistent. Wait a little bit 
> till I read more of the megrok.login code.
>
> Thanks for megrok.login, which I've been using sucessfully,  and for the 
> support in the mailinglist.
>
> Regards,
>
> Aroldo.
>
>
> Uli Fouquet wrote:
>   
>> Hi Aroldo,
>>
>> Aroldo Souza-Leite wrote:
>>
>>   
>>     
>>> I'm trying to substitute the 
>>> 'authplugins.PrincipalRegistryAuthenticator' in 'megrok.loging' by 
>>> another authenticator that uses an external database of users. I 
>>> understand I have to model a class that implements 
>>> 'IAuthenticatorPlugin'. But where do I tell 'megrok.login' to use the my 
>>> custom authenticator?
>>>     
>>>       
>> You have to write your own PAU setup and register it using
>> `megrok.login.setup()`. For this you need an own setup function, roughly
>> like this::
>>
>>  from zope.pluggableauth.plugins.session import SessionCredentialsPlugin
>>
>>  def customPAUSetup(site, pau, viewname=None, strict=None,
>>                     autoregister=None):
>>      """Setup our own PAU.
>>      """
>>      # Assuming your authenticator is registered as a named global 
>>      # utility 'My custom authenticator plugin'
>>      pau.authenticatorPlugins = ('My custom authenticator plugin', )
>>      pau['custom_session'] = session = SessionCredentialsPlugin()
>>      pau.credentialsPlugins = ('No Challenge if Authenticated',
>>                                'custom_session',)
>>      return
>>
>> and then register this setup like this::
>>
>>   import grok
>>   import megrok.login
>>
>>   class CustomSetupApp(grok.Application, grok.Container):
>>       megrok.login.enable()
>>       megrok.login.setup(customPAUSetup)
>>
>> If you create a new application, the new PAU will be active.
>> A more elaborate example of the setup is part of the docs in
>>
>> http://svn.zope.org/megrok.login/trunk/src/megrok/login/tests/custompausetup.py?view=markup
>>
>> Naturally, if you do so much things yourself, you might be better off
>> dropping megrok.login and using the pluggableauth stuff directly.
>>
>> Best regards,
>>
>>   
>>     
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev
>   



More information about the Grok-dev mailing list