Hi, <div><br></div><div>I can not receive some mails from this mail list, though I can read them in the digest mail.</div><div>but it's really inconvenient to reply those ones.</div><div><br></div><div>Thanks</div><div>
--Shrek<br><br><div class="gmail_quote">On Thu, Nov 4, 2010 at 4:14 PM, <span dir="ltr"><<a href="mailto:grok-dev-request@zope.org">grok-dev-request@zope.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Send Grok-dev mailing list submissions to<br>
<a href="mailto:grok-dev@zope.org">grok-dev@zope.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="https://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">https://mail.zope.org/mailman/listinfo/grok-dev</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:grok-dev-request@zope.org">grok-dev-request@zope.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:grok-dev-owner@zope.org">grok-dev-owner@zope.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Grok-dev digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Re: grok 1.2 and session based auth. (Shrek Zhou)<br>
2. Re: grok 1.2 and session based auth. (Jan-Wijbrand Kolman)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 4 Nov 2010 09:49:12 +0800<br>
From: Shrek Zhou <<a href="mailto:zgwmike@gmail.com">zgwmike@gmail.com</a>><br>
Subject: Re: [Grok-dev] grok 1.2 and session based auth.<br>
To: <a href="mailto:grok-dev@zope.org">grok-dev@zope.org</a><br>
Cc: <a href="mailto:cklinger@novareto.de">cklinger@novareto.de</a><br>
Message-ID:<br>
<<a href="mailto:AANLkTin66%2BCYTfkhVRGMVaVObFhzQKRQ6ggMoOV-p0p3@mail.gmail.com">AANLkTin66+CYTfkhVRGMVaVObFhzQKRQ6ggMoOV-p0p3@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="windows-1252"<br>
<br>
To Christian,<br>
<br>
I can not found groupfolder.zcml in that folder under *<br>
.buildout/eggs/zope.pluggableauth-1.0.3-py2.6.egg/zope/pluggableauth/plugins/<br>
*<br>
<br>
i think you have to include zope.pluggableauth and this zcml-snippet:<br>
<br>
<include package="zope.pluggableauth.plugins" file="groupfolder.zcml" /><br>
<br>
Maybe you can report if it works for you.<br>
Christian<br>
<br>
<br>
On Thu, Nov 4, 2010 at 9:30 AM, Shrek Zhou <<a href="mailto:zgwmike@gmail.com">zgwmike@gmail.com</a>> wrote:<br>
<br>
> Hi, Jerrfey,<br>
> I did that before I sent the mail. and I noticed that,<br>
> in .buildout/eggs/zope.app.publication-3.12.0-py2.6.egg/zope/app/publication/zopepublication.py(89),<br>
> the following func is called, which just get IAuthentication Utility from<br>
> global site manager.<br>
><br>
> def beforeTraversal(self, request):<br>
> notify(StartRequestEvent(request))<br>
> # Try to authenticate against the root authentication utility.<br>
> auth = zope.component.getGlobalSiteManager().getUtility(<br>
> zope.authentication.interfaces.IAuthentication)<br>
> principal = auth.authenticate(request)<br>
> if principal is None:<br>
> principal = auth.unauthenticatedPrincipal()<br>
> if principal is None:<br>
> # Get the fallback unauthenticated principal<br>
> principal = zope.component.getUtility(<br>
> IFallbackUnauthenticatedPrincipal)<br>
><br>
> request.setPrincipal(principal)<br>
> newInteraction(request)<br>
> transaction.begin()<br>
> ps:<br>
><br>
> *And code snippet of app.py*<br>
> class Bada(grok.Application, grok.Container):<br>
> grok.implements(IBada)<br>
> grok.local_utility(auth.UserAuthenticatorPlugin,<br>
> provides=IAuthenticatorPlugin,<br>
> name='users')<br>
> grok.local_utility(PluggableAuthentication,provides=IAuthentication,<br>
> setup=auth.setup_authentication,<br>
> )<br>
> *And code snippet of auth.py*<br>
> def setup_authentication(pau):<br>
> pau.credentialsPlugins=['credentials']<br>
> pau.authenticatorPlugins=['users']<br>
><br>
> class Account(grok.Model):<br>
> def __init__(self,name,password,real_name,role):<br>
> <a href="http://self.name" target="_blank">self.name</a>=name<br>
> self.real_name=real_name<br>
> self.role=role<br>
> self.setPassword(password)<br>
> def setPassword(self,password):<br>
> passwordManager=getUtility(IPasswordManager,'SHA1')<br>
> self.password=passwordManager.encodePassword(password)<br>
> def checkPassword(self,password):<br>
> passwordManager=getUtility(IPasswordManager,'SHA1')<br>
> return passwordManager.checkPassword(self.password,password)<br>
> class UserFolder(grok.Container):<br>
> pass<br>
> class<br>
> MySessionCredentialsPlugin(grok.GlobalUtility,SessionCredentialsPlugin):<br>
> grok.provides(ICredentialsPlugin)<br>
> <a href="http://grok.name" target="_blank">grok.name</a>("credentials")<br>
><br>
> loginpagename="login"<br>
> loginfield='login'<br>
> passwordfield='password'<br>
><br>
> class PrincipalInfo(object):<br>
> grok.implements(IPrincipalInfo)<br>
> def __init__(self,id,title,description):<br>
> <a href="http://self.id" target="_blank">self.id</a>=id<br>
> self.title=title<br>
> self.description=description<br>
> self.credentialsPlugin=None<br>
> self.authenticatorPlugin=None<br>
> class UserAuthenticatorPlugin(grok.LocalUtility):<br>
> grok.implements(IAuthenticatorPlugin)<br>
> <a href="http://grok.name" target="_blank">grok.name</a>('users')<br>
><br>
> def __init__(self):<br>
> self.user_folder=UserFolder()<br>
> def authenticateCredentials(self,credentials):<br>
> if not isinstance(credentials,dict):<br>
> return None<br>
> if not ('login' in credentials and 'password' in credentials):<br>
> return None<br>
> account=self.getAccount(credentials['login'])<br>
> if account is None:<br>
> return None<br>
> if not account.checkPassword(credentials['password']):<br>
> return None<br>
> return PrincipalInfo(id=<a href="http://account.name" target="_blank">account.name</a>,<br>
> title=account.real_name,<br>
> description=account.real_name<br>
> )<br>
> def principalInfo(self,id):<br>
> account=self.getAccount(id)<br>
> if account is None:<br>
> return None<br>
> return PrincialInfo(id=<a href="http://account.name" target="_blank">account.name</a>,<br>
> title=account.real_name,<br>
> description=account.real_name<br>
> )<br>
> def getAccount(self,login):<br>
> return login in self.user_folder and self.user_folder[login] or<br>
> None<br>
> def addUser(self,username,password,real_name,role,**kwargw):<br>
> import pdb;pdb.set_trace()<br>
> if username not in self.user_folder:<br>
> user=Account(username,password,real_name,role)<br>
> self.user_folder[username]=user<br>
> role_manager=IPrincipalRoleManager(grok.getSite())<br>
> permission_manager=IPrincipalPermissionManager(grok.getSite())<br>
> #TODO: do role or permission assigning here.<br>
> permission_manager.grantPermissionToPrincipal('zope.View',<br>
> <a href="http://user.name" target="_blank">user.name</a>)<br>
><br>
> class ILoginForm(Interface):<br>
> login=schema.BytesLine(title=_(u'Username'),required=True)<br>
> camefrom=schema.BytesLine(title=u'',required=False)<br>
> password=schema.Password(title=_(u'Password'),required=True)<br>
><br>
> class Login(megrok.layout.Form):<br>
> grok.context(Interface)<br>
> grok.require('zope.Public')<br>
> label='Login'<br>
> prefix=''<br>
> form_fields=grok.Fields(ILoginForm)<br>
><br>
> def setUpWidgets(self,ignore_request=False):<br>
> super(Login,self).setUpWidgets(ignore_request)<br>
> self.widgets['camefrom'].type='hidden'<br>
> self.widgets['login'].cssClass='title'<br>
> self.widgets['password'].cssClass='title'<br>
><br>
> @grok.action('Login')<br>
> def handle_login(self,**data):<br>
> import pdb;pdb.set_trace()<br>
><br>
> self.redirect(self.request.form.get('camefrom',self.url(grok.getSite())))<br>
><br>
> class IAddUserForm(Interface):<br>
> login=schema.BytesLine(title=_(u"Username"),required=True)<br>
> password=schema.Password(title=_(u'Password'),required=True)<br>
> confirm_password=schema.Password(title=_(u"Confirm password"),<br>
> required=True)<br>
> real_name=schema.TextLine(title=_(u'Real name'),required=True)<br>
> role=schema.Choice(title=_(u'User role'),<br>
> values=[_(u'Bada Member'),_(u'Bada Master<br>
> Account')],<br>
> required=True)<br>
><br>
> class AddUserForm(megrok.layout.Form):<br>
> grok.context(Interface)<br>
> grok.require('zope.Public')<br>
> label=_('Register')<br>
> form_fields=grok.Fields(IAddUserForm)<br>
> @grok.action(_(u'Register'))<br>
> def handle_add(self,**data):<br>
> users=getUtility(IAuthenticatorPlugin,'users')<br>
><br>
> users.addUser(data['login'],data['password'],data['real_name'],data['role'])<br>
> self.redirect(self.url(grok.getSite()))<br>
><br>
> On Thu, Nov 4, 2010 at 1:49 AM, Jeffrey D Peterson <<a href="mailto:bgpete@gmail.com">bgpete@gmail.com</a>>wrote:<br>
><br>
>> There is a bug, it?s been documented.<br>
>><br>
>><br>
>><br>
>> You need to include zope.pluggableauth in your setup.py in<br>
>> install_requires and rerun buildout. This will work around the bug.<br>
>><br>
>><br>
>><br>
>> Hopefully that?s the issue, otherwise, we?ll have to look closer.<br>
>><br>
>><br>
>><br>
>> --<br>
>><br>
>> Jeffrey Peterson<br>
>><br>
>> <a href="mailto:bgpete3@gmail.com">bgpete3@gmail.com</a><br>
>><br>
>><br>
>><br>
>> *From:* <a href="mailto:grok-dev-bounces@zope.org">grok-dev-bounces@zope.org</a> [mailto:<a href="mailto:grok-dev-bounces@zope.org">grok-dev-bounces@zope.org</a>] *On<br>
>> Behalf Of *Shrek Zhou<br>
>> *Sent:* Wednesday, November 03, 2010 12:01 PM<br>
>> *To:* <a href="mailto:grok-dev@zope.org">grok-dev@zope.org</a><br>
>> *Subject:* [Grok-dev] grok 1.2 and session based auth.<br>
>><br>
>><br>
>><br>
>> hi, grokkers,<br>
>><br>
>><br>
>><br>
>> *My problem:*<br>
>><br>
>> I can not use PluggableAuthenticationPlugin from zope.pluggableauth to do<br>
>> a session based auth.<br>
>><br>
>><br>
>><br>
>> *Steps I took:*<br>
>><br>
>> 1. added the following lines to my gork.Application:<br>
>><br>
>><br>
>><br>
>> grok.local_utility(auth.UserAuthenticatorPlugin,<br>
>><br>
>> provides=IAuthenticatorPlugin,<br>
>><br>
>> name='users')<br>
>><br>
>> grok.local_utility(PluggableAuthentication,provides=IAuthentication,<br>
>><br>
>> setup=auth.setup_authentication,<br>
>><br>
>> )<br>
>><br>
>><br>
>><br>
>> 2. created corresponding authenticatorPlugin and credentialsPlugin, and<br>
>> add them to pau through setup_authentication.<br>
>><br>
>><br>
>><br>
>> *Results*:<br>
>><br>
>> The authentication utility is not called at all. only<br>
>> princialRegistry(from zope.principalregistry which is a globalsite utility<br>
>> that implements IAuthentication.) works.<br>
>><br>
>><br>
>><br>
>> Expected:<br>
>><br>
>> The local authentication utility should work and substitute the global<br>
>> one.<br>
>><br>
>><br>
>><br>
>> *How can I fix the above problem??*<br>
>><br>
>><br>
>><br>
><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://mail.zope.org/pipermail/grok-dev/attachments/20101104/b33f1dfc/attachment-0001.html" target="_blank">http://mail.zope.org/pipermail/grok-dev/attachments/20101104/b33f1dfc/attachment-0001.html</a><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Thu, 04 Nov 2010 09:14:44 +0100<br>
From: Jan-Wijbrand Kolman <<a href="mailto:janwijbrand@gmail.com">janwijbrand@gmail.com</a>><br>
Subject: Re: [Grok-dev] grok 1.2 and session based auth.<br>
To: <a href="mailto:grok-dev@zope.org">grok-dev@zope.org</a><br>
Message-ID: <iatq1j$7jo$<a href="mailto:1@dough.gmane.org">1@dough.gmane.org</a>><br>
Content-Type: text/plain; charset=windows-1252; format=flowed<br>
<br>
On 11/4/10 2:49 AM, Shrek Zhou wrote:<br>
> To Christian,<br>
><br>
> I can not found groupfolder.zcml in that folder under<br>
> *.buildout/eggs/zope.pluggableauth-1.0.3-py2.6.egg/zope/pluggableauth/plugins/<br>
<br>
Grok-1.2 still uses zope.pluggableauth-1.0.3 indeed. I'm not sure of the<br>
chronology of the Grok 1.2 release and the zope.pluggableauth 1.1<br>
anymore, but, if you were to say in your project's buildout.cfg:<br>
<br>
[versions]<br>
...<br>
zope.pluggableauth = 1.1<br>
...<br>
<br>
and then re-run ./bin/buildout, you should get the latest<br>
zope.pluggableauth *with* the aforementioned plugins.<br>
<br>
As Christian said, the subject of zope.pluggablauth and related have<br>
soke glitches concerning the correct configuration. I *think* this is<br>
being worked on as we speak during the Grok Forest Sprint.<br>
<br>
Thanks for keeping up with this and helping identifying the issues.<br>
<br>
Kind regards, jw<br>
<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
Grok-dev mailing list<br>
<a href="mailto:Grok-dev@zope.org">Grok-dev@zope.org</a><br>
<a href="https://mail.zope.org/mailman/listinfo/grok-dev" target="_blank">https://mail.zope.org/mailman/listinfo/grok-dev</a><br>
<br>
<br>
End of Grok-dev Digest, Vol 50, Issue 5<br>
***************************************<br>
</blockquote></div><br></div>