[Zope3-Users] Re: Howto add roles to my principal
Christian Klinger
cklinger at novareto.de
Wed Aug 8 07:58:19 EDT 2007
Christian Klinger schrieb:
> Hi,
>
> i try to fetch users from an rdbms to authenticate them in zope3.
>
> I have created a custom AuthenticatorPlugin which reads the
> user from an sqltable and return the PrincipalInfo when
> username password is valid. This works so far.
>
> Now the Problem:
>
> I have role information in my rdbms table and i want that
> my principals get these roles.
> But i don´t know how can i assign these roles
> to my principal.
>
> Maybe something like that:
>
> return PrincipalInfo(self.prefix+login, login, login, login,
> ['Manager','Viewer',])
>
> In Zope2 PAS there is a IRolesPlugin which assign the role to
> the principal.
>
>
> Maybe someone had an idea or an example for me.
>
>
> Christian
Hi,
i have found it myself. I have to access the event
<subscriber
for="zope.app.authentication.interfaces.IAuthenticatedPrincipalCreated"
handler=".plugins.event.authenticated_principal_created"
/>
and add my role to:
def authenticated_principal_created(event):
principal = event.principal
principal.groups.append('zope.Manager')
Thx Christian
More information about the Zope3-users
mailing list