[Grok-dev] megrok.login: substituting authenticator
Aroldo Souza-Leite
asouzaleite at gmx.de
Tue Sep 7 06:06:50 EDT 2010
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,
>
>
More information about the Grok-dev
mailing list