[Zope-dev] PAU question - how to I handle roles on principals
I have created a simple authenticator plug-in. It allows me to load my users from my database. The plug-in only allows me to control the name of a principal and validate their user name / password. I need to tell Zope which roles different users have. I have the roles stored on the database. How do I develop/install a plug-in/adapter which will will be invoked for the getRolesForPrincipal() method or be invoked as the IPrincipalRoleManager adapter? My authenticator just is setup to produce a zope.app.authentication.principalfolder.Principal for the Principal Object. Thanks Kevin ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: Re: PAU question - how to I handle roles on principals
Thanks Christophe I tried to configure a Principal annotation for 'roles' but I am afraid I have come up blank. Here is what I did... # Create a principal Annotations Utility (as recommeded by CC) from zope.component import provideUtility, provideAdapter from zope.app.principalannotation import PrincipalAnnotationUtility from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility annotationsUtility = PrincipalAnnotationUtility() provideUtility(annotationsUtility, IPrincipalAnnotationUtility) # Create a content object for testing import zope.interface from zope.annotation.interfaces import IAttributeAnnotatable class Ob(object): zope.interface.implements(IAttributeAnnotatable) ob = Ob() # Create a principal from zope.security.interfaces import IPrincipal from zope.interface import implements class Principal: implements(IPrincipal) def __init__(self, id): self.id = id self.groups = [] principal = Principal('bob') # Annotate the Principal with test roles - This my guess at how the # PrincipalAnnotation utility should be used import zope.securitypolicy.role role1=zope.securitypolicy.role.Role('role1', 'Role One') role2=zope.securitypolicy.role.Role('role2', 'Role Two') annotations = annotationsUtility.getAnnotations(principal) annotations.data['roles'] = [role1, role2] # Create an interaction and use it to link the principal to the object import zope.securitypolicy.zopepolicy interaction = zope.securitypolicy.zopepolicy.ZopeSecurityPolicy() class Participation: interaction = None participation = Participation() participation.principal = principal interaction.add(participation) # Verify that it is configured interaction.checkPermission('P1', ob) from zope.security.checker import CheckerPublic interaction.checkPermission(CheckerPublic, ob) # Get the RoleManager adapter. This should tell me what roles # the Principal has in the context of my object from zope.securitypolicy.interfaces import IRolePermissionManager, IPrincipalRoleManager, IPrincipalPermissionManager roleper = IRolePermissionManager(ob) prinrole = IPrincipalRoleManager(ob) prinper = IPrincipalPermissionManager(ob) # List the Roles and permissions print roleper.getRolesAndPermissions() Unfortunately, this prints [], an empty list of roles and permissions. I expected to see the two roles I annotated the Principal with. I could be just using the wrong types or name for the annotation. Do you have any example I could follow? Thanks Kevin ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Configuring PAU - Should it be this hard?
I spent approximately a weeks work (spread over a month) to get the PAU configured with my PostgreSQL database. When I look at what I am doing now, it seems very complicated. Please have a look at the following and let me know if I am doing it the hard way. This may also be helpful for anyone trying to achieve the same result. Here is my notes: Notes on Setting up an external authentication system for Zope3 === I use an external database to store my data. 1. My Security Model = I have three types of users (principal), members, casting directors and administrators. The login information (login name, password and roles) are stored in a relational database. I am migrating a Zope 2 system exUserFolder based solution. The Zope3 concept of a role is different from the Zope2 concept. In Zope3, roles are bundles of permissions only. The user (principal) side of the functionality is provided by groups. I configure my security rules in the code using permissions, and I bundle these permissions for logical users using role ZCML statements. In the Zope ZMI I configure a PAU with three groups. I map my users (principals) to the groups from the database. In the Zope ZMI I use the grant tab in the [top] folder to map the roles to permissions. Thus my relationships are: principals -> grouped mapped to groups in database groups -> mapped to roles in grant at root (ZMI) roles -> mapped to permissions in ZCML 2. Configuring PAU === I wrote three plugins for the PAU to get this configuration to work. 1. I wrote a PrincipalFolder. The PrincipalFolder provides authentication for the principals. It also provides lists of principals for Rotterdam UI. 2. I wrote a Group. The Group maps a single group to the members of that group. 3. I wrote a GroupFolder. The default GroupFolder caches the data in the Group. To update the default GroupFolder you have to trigger events. The external database updates do not trigger events so this model has to be replaced. I have to do the following configurations: 1. In the manage site -> default folder create a PAU. 2. Configure the credentials plugin. For now I use : 'Zope Realm Basic-Auth (a utility)' and 'No Challenge if Authenticated (a utility)' 3. I select the PAU Plugins tab. I create my principal Folder I go back to the PAU Configure Tab and add my Principal Folder to the Authenicator Plugins 5. I select the PAU Plugins tab I create my group folder I select the new group folder I add three new group objects. The object name maps to the 'role' on my database 6. I go back to the PAU Configure Tab I add the new group folder to my Authenticator Plugins 7. I select the registration tab. I register the PAU 8. I go the the [top] I select the grant tab I use this to grant the configured roles to the new groups 9. I edit the page template and add in the following to print out the logged in person information: Developer Info: Context: Logged in user: Groups: 10. I login with the user from the database. The groups should be displayed in the developer info block. Issues == This solution requires a second database call to get the group after the Principal has been configured. I may have to cache when I tune the system. I have a prefix on the user. The user ids map to prefix + the database user id. The principal prefix is hard coded in the group folder to generate compatible zope principal ids. ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Tutorial on SQLScript - Feedback solicited
I found that there is a lack of documentation for using SQLScript with Zope3. SQLAlchemy is newer and exciting and SQLScript is mostly ignored. This is unfortunate as it works well and is well known to Zope2 developers. I have made an attempt to redress the balance by adding a page on it to the ZopeInAnger section of the Wiki. http://wiki.zope.org/zope3/HowDoIUseSQLScript Unfortunately, the document is quite long. The example code is attached to the document. I would appreciate any feedback, particularly corrections, criticisms. I will (grudgingly) accept criticisms of my presentation style as well as the content. This is my first attempt to add to the documentation body for Zope. Thanks, Kevin ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: AW: [Zope-dev] Re: [Zope3-Users] How do I automatically login a user
If values are not provided in the dictionary, the request is searched """ def setCredentials(overrides, mode=REQUEST_ONLY): """Store the credentials for the current session. Do not login the current transaction (interaction)""" 5. Tracking of Logged in Users The credentials data, stored for the session shall have two new values stored to support tracking of this information: o extractTime o accessTime The extractTime shall be the time that the credentials were actually extracted. The accessTime shall be the last time that the credentials were recovered. For performance reasons, the accessTime updates may be disabled. It shall have a granularity of 60 seconds so that the session data is not updated unnecessarily frequently. 5a. Report of logged in users A new adapter shall be written which can trawl the session records in the session store and locate records for logged in users. The adapter shall return a list of all logged in users, (login, extractTime and accessTime). A UI change will provide a simple view on logged in users. 5b. Idle time out If the access time is being tracked, the SessionCredential plugin can easily implement an idle timeout. This effectively does a server side logout of users who have not accessed the system for a configured interval. There would be a UL change to enable Idle timeout. > Ha David > >> Betreff: Re: [Zope-dev] Re: [Zope3-Users] How do I >> automatically login a user >> >> Thanks Jim for doing this. Actually, the domain is something >> I have been looking for also. These other features are really >> nice. I am hoping this >> can be worked into something like z3c.authentication for >> generic use. >> Hoping roger is following this. > > Yes, yes, just found no time to pickup this. But it's on the > top of my 1000 things to do list ;-) > > Note: > I started to make progress with z3c.authenticator. > This will become a replacement for z3c.authentication.simple > Does anybody think we will need a migration script? > > > Regards > Roger Ineichen > _ > END OF MESSAGE > >> Regards, >> David >> >> Jim Fulton wrote: >> > >> > Let's move this discussion to zope-dev. >> > >> > On Apr 2, 2008, at 5:36 AM, kevin gill wrote: >> >> Please check in the code to the sandbox and I will have a >> look at it. >> >> The coding looks straight-forward, but choosing how to >> work it into >> >> the existing components. >> >> >> >> I will look at the code and come back with questions. >> > >> > >> > I just checked 2 files, session.txt and session.py, into >> > >> > http://svn.zope.org/Sandbox/J1m/ >> > >> > These provide several features, most of which are of particular >> > interest >> > here: >> > >> > - An api to save session credentials independent of login, >> > >> > - saving sha-encoded passwords, >> > >> > - logout api >> > >> > - having an optional additional credential of a user domain, >> > (probably not of general interest) >> > >> > Jim >> > >> > -- >> > Jim Fulton >> > Zope Corporation >> > >> > >> > ___ >> > Zope-Dev maillist - Zope-Dev@zope.org >> > http://mail.zope.org/mailman/listinfo/zope-dev >> > ** No cross posts or HTML encoding! ** (Related lists >> > -http://mail.zope.org/mailman/listinfo/zope-announce >> > http://mail.zope.org/mailman/listinfo/zope ) >> > >> ___ >> Zope3-users mailing list >> [EMAIL PROTECTED] >> http://mail.zope.org/mailman/listinfo/zope3-users >> > > ___ > Zope3-users mailing list > [EMAIL PROTECTED] > http://mail.zope.org/mailman/listinfo/zope3-users > > -- > ** Email Scanned by Elive's Virus Scanning Service - > http://www.elive.net ** > > > > > ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: AW: [Zope-dev] Re: [Zope3-Users] How do I automatically login a user]
I have completed a first draft of an implementation of a proposal for for changes to the SessionCredentials Access code (zope.app.authentication). http://wiki.zope.org/zope3/SessionCredentialsAPIEnhancements I want to put them somewhere so that they can be discussed. I think that a svn.zope.org/Sandbox is the appropriate place. Can I get committer access to the subversion repository to make changes to this area? [According to the faq, I ask for commiter access on this list]. Alternatively, is there another location where proposed changes to the core are generally posted. Thanks Kevin > On Apr 9, 2008, at 5:07 AM, kevin gill wrote: >> 1. IP Extraction >> >> Extract the IP Address from the credentials and store it. Return the >> IP Address in the dictionary from extractCredentials(). >> >> The value from request._environ['HTTP_X_FORWARDED_FOR'] will be used >> if present. otherwise request._environ['REMOTE_ADDR']. > > > On a basis of "privacy" of attributes starting with underscore, such > as _environ, I would suggest using request.headers (for X-Forwarded- > For) and request.environment instead. These are defined in the public > interface API. > > -- > Zvezdan Petkovic <[EMAIL PROTECTED]> > > ___ > Zope-Dev maillist - Zope-Dev@zope.org > http://mail.zope.org/mailman/listinfo/zope-dev > ** No cross posts or HTML encoding! ** > (Related lists - > http://mail.zope.org/mailman/listinfo/zope-announce > http://mail.zope.org/mailman/listinfo/zope ) > > -- > ** Email Scanned by Elive's Virus Scanning Service - > http://www.elive.net ** > > > > > ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: AW: [Zope-dev] Re: [Zope3-Users] How do I automatically login a user]
I have made many changes to the first version of this proposal and submitted a new version to the wiki. http://wiki.zope.org/zope3/SessionCredentialsAPIEnhancements I have checked in an example implementation to the Zope SVN repository. The code is at: svn://svn.zope.org/repos/main/Sandbox/kevingill2/zope.app.authentication Of via browser: http://svn.zope.org/Sandbox/kevingill2/zope.app.authentication/ I would appreciate any feedback on either the proposal or the implementation. Thanks Kevin ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] Need help - wrong hierarchy on svn.zope.org
Hi, I need a little help. I checked two packages into svn.zope.org, but I have set up the hierarchy incorrectly. The packages are z3c.rotterdam and z3c.boston. The egg is in the base folder, rather than in 'trunk'. I would appreciate it if someone with administration access to the repository could fix the paths. Sorry for the inconvenience, Kevin ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Zope3 sessions and database conflicts
Hi, For quite some time I see messages like this in my z3.log: 2010-03-02T16:27:14 WARNING ZopePublication Competing writes/reads at /BSPSite/act/++vh++http:zis.act.at:80/bankneu/++/images/sponsor_logo.png: database conflict error (oid 0x063f, class BTrees.OOBTree.OOBucket, serial this txn started with 0x038484dc7d5ac044 2010-03-02 14:52:29.379960, serial currently committed 0x038484ff3c6b5455 2010-03-02 15:27:14.160763) I followed an advice from the zope-dev list and added some debug messages in ZODB.Connection.py where the objects are registered for writing. The following debug messages (I print the key/values of the object in question) occur before and after the database conflict error: --- 2010-03-02T16:27:14 DEBUG zbsp keys: ['6ZZzgjNK0p.bIIlruXb4JkDo-T0J-XipPcVFGtcj0 LH6dMdI9akYvg', . , '7MmOPQOlkAHoa3T nydH9IIgKBqoVyn3Q.yH6OXJeLj7epObIy3M5Lg'] --- 2010-03-02T16:27:14 DEBUG zbsp values: [, , , . , , ,] --- So it seems these are the session data containers. I wonder why they are written? Perhaps this happens when somebody else is logging into the system (so a new session is added) and others are concurrently reading from the session? However, this would mean that the session mechanism has a flaw, as this is a standard procedure? Any ideas of how to fix this? Best Regards, Hermann -- herm...@qwer.tk GPG key ID: 299893C7 (on keyservers) FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7 ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope ) ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Zope3 sessions and database conflicts
> Hi, > For quite some time I see messages like this in my z3.log: > > 2010-03-02T16:27:14 WARNING ZopePublication Competing writes/reads > at > /BSPSite/act/++vh++http:zis.act.at:80/bankneu/++/images/sponsor_logo.png: > database conflict error (oid 0x063f, class BTrees.OOBTree.OOBucket, serial > this txn started with 0x038484dc7d5ac044 2010-03-02 14:52:29.379960, > serial > currently committed 0x038484ff3c6b5455 2010-03-02 15:27:14.160763) > > I followed an advice from the zope-dev list and added some debug messages > in > ZODB.Connection.py where the objects are registered for writing. > > The following debug messages (I print the key/values of the object in > question) occur before and after the database conflict error: > > --- > 2010-03-02T16:27:14 DEBUG zbsp keys: > ['6ZZzgjNK0p.bIIlruXb4JkDo-T0J-XipPcVFGtcj0 > LH6dMdI9akYvg', . , '7MmOPQOlkAHoa3T > nydH9IIgKBqoVyn3Q.yH6OXJeLj7epObIy3M5Lg'] > --- > 2010-03-02T16:27:14 DEBUG zbsp values: [ object at 0x43723bec>, 0x4372356c>, , > . > , > , > 0x43640b6c>,] > --- > > So it seems these are the session data containers. > > I wonder why they are written? Perhaps this happens when somebody else is > logging into the system (so a new session is added) and others are > concurrently reading from the session? However, this would mean that the > session mechanism has a flaw, as this is a standard procedure? > > Any ideas of how to fix this? I had a serious problem with the session machinery. I use a very long timeout on sessions and thus have a large number of sessions saved (up to 30k). The sweep machinery kicks in and sweeps everything. It takes so long that all the threads do the sweep and you get these errors. I customised the sweep for my site as follows: 1. Only sweep at night 2. Sweep a random subset of the data (20 records), but sweep very often 3. Different timeouts for authenticated sessions and anonymous sessions. Regards, Kevin > > Best Regards, > Hermann > > -- > herm...@qwer.tk > GPG key ID: 299893C7 (on keyservers) > FP: 0124 2584 8809 EF2A DBF9 4902 64B4 D16B 2998 93C7 > ___ > Zope-Dev maillist - Zope-Dev@zope.org > https://mail.zope.org/mailman/listinfo/zope-dev > ** No cross posts or HTML encoding! ** > (Related lists - > https://mail.zope.org/mailman/listinfo/zope-announce > https://mail.zope.org/mailman/listinfo/zope ) > > > ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK TTW Content Types Project Wiki
> So I am starting a project to build content types through the web using > the ZTK. > > Here is the url. > > http://specialtyjobmarkets.com/Wikis/LozinskiClasses/FrontPage > Hi Christopher, I understand where you are. Four years ago, I made the transition from Zope2 to Zope3. It was about 12 months before the new technologies felt comfortable. In particular, my biggest irritation was Zope3 heads who had never used ZClasses and TTW development bad mouthing it. Recently, I have gravitated to Plone. There are a number of tools in Plone that demonstrate an interest in RAD in general and TTW as a RAD mechanism where appropriate. PloneFormGen has been improved recently. It is great for creating forms for creating content objects. ArchGenXML can generate the structure of complex applications. If you do it right, you can end up just writing the Python Code and File system is better in my opinion for that due to the debugger. However, it is tricky to get setup with argo uml in the first place. Plomino.net has a wonderful product that is very like python TTW development. It is not consistent with the Zope idioms, but it doesn't need to be because Plone users don't know them. It is very fast to develop and has good forms. I urge you to try it out. Don't be too harsh on Grok/Dexterity. Dexterity has worked out how not to repeat the definitions in interfaces, forms and content objects. It also produces an application with suprisingly little redundant code. I urge you to try it out. The benefits are of course quick turn around, version control, testability and the debugger. I made some edits on your wiki. Good Luck in your project Kevin > Thank you for the recent feedback. It is nice to know that people > care. I have added a section reviewing the competing technologies, and > why they are not right for my needs. I have laid out the technical > proposal, a bit high level, I need to make it more specific. For > example I need to add what is the interface that is needed by Factory > objects. The great thing about ZTK is that somewhere that is documented. > > I have added a section on my software philosophies. I am sure that it > will drive some people nuts, but others will agree with it. Allow me to > have my point of view. I also respect your point of view. > > I do get a bunch of people who say I am nuts. So positive feedback > would be most appreciated. > > And of courses it is an anonymous wiki. I am using the ZWiki software. > You are invited to add your comments. I have no idea what you will say, > but I am sure it is useful. > > Regards > Chris > ___ > Zope-Dev maillist - Zope-Dev@zope.org > https://mail.zope.org/mailman/listinfo/zope-dev > ** No cross posts or HTML encoding! ** > (Related lists - > https://mail.zope.org/mailman/listinfo/zope-announce > https://mail.zope.org/mailman/listinfo/zope ) > > > ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK TTW Content Types Project Wiki
>> >> >> Don't be too harsh on Grok/Dexterity. Dexterity has worked out how not >> to >> repeat the definitions in interfaces, forms and content objects. It also >> produces an application with suprisingly little redundant code. I urge >> you >> to try it out. The benefits are of course quick turn around, version >> control, testability and the debugger. >> >> Also note that (the Plone integration for) Dexterity allows you to >> create > types entirely through-the-web. This can then be meaningfully transitioned > to filesystem development without forcing you to start from scratch. Is there a tool to do the "meaningful transition". I like the ability to design the content type schema TTW, but I haven't got a button to export it (b2 + plone 3.3.5). I found this... """The type definition can just be exported via portal_setup by exporting the types tool. We want some new UI for this. The schema will be in there, in escaped xml. You can also put this in a separate xml file, or define a zope 3 schema--use plone.directives.form for this.""" Also, is there a roadmap / vision. I used Dexterity earlier this year and loved it. But that was a standalone way to get grok to build a form with complex functionality. The TTW tool potentially gives the ability to customise classes built using dexterity. It is really cool. > > The big, big problem with any kind of TTW development is that it usually > breaks down badly when you move your code to a production server and then > need to continue development in a separate environment. Code and > configuration stored in a database is difficult to deploy and merge when > the > same database holds live data and content. The same problem exists where > more than one developer needs to collaborate. Without source files and > source control, it's impossible to give each developer their own sandbox. > These are all valid problems. I don't want to discuss them, because I am not advocating TTW. But I will point out that I worked around them all when doing TTW, e.g. APE allowed me to keep Code in SVN, multiple Zope instances allowed me to develop different branches, my data was in Postgres anyway etc. > Martin > > > ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )