Package: repoze.what.plugins.ini
repoze.what.plugins.ini -- Plugin for repoze.what authorization framework=========================================================================What is repoze.what.plugins.ini?--------------------------------repoze.what.plugins.ini is a plugin for repoze.what that offers group andpermissions adapters for sources based on INI files.What is repoze.what?--------------------From repoze.what site:repoze.what is an authorization framework for WSGI applications, basedon repoze.who (which deals with authentication).On the one hand, it enables an authorization system based on the groupsto which the authenticated or anonymous user belongs and the permissionsgranted to such groups by loading these groups and permissions into therequest on the way in to the downstream WSGI application.And on the other hand, it enables you to manage your groups andpermissions from the application itself or another program, under abackend-independent API. For example, it would be easy for you to switchfrom one back-end to another, and even use this framework to migrate thedata.repoze.what can be used as authorization framework for turbogear, repoze.bfgor your own WSGI server.How to install repoze.what.plugins.ini?---------------------------------------You can install the last stable version with easy_install::easy_install repoze.what.plugins.inior the developer version via git::git clone git://github.com/jdinuncio/repoze.what.plugins.ini.gitcd repoze.what.plugins.inipython setup.py installThe source file format----------------------The format used in the source files is similar to the INI file format. Thefile consists in a serie of sections, each one with a section header of theform “[section-name]”, followed by entries of the form “value”. Spacesbefore and after section headers or entries are ignored. Characters after”#” are ignored.An example of a group file::[admins]rms[developers]rmslinus[trolls]sballmer[python][php]An example of a permissions file:[see-site]trolls[edit-site]adminsdevelopers[commit]developersHow to use it?--------------All you need to do is to instantiate a repoze.what middleware usingrepoze.what.plugins.ini.INIGroupAdapter orrepoze.what.plugins.ini.INIPermissionsAdapter::# First, we'll need a WSGI applicationmy_app = None   # Of course, you'll change None for your WSGI app# We need to set up the repoze.who components used by repoze.what for# authenticationfrom repoze.who.plugins.htpasswd import HTPasswdPlugin, crypt_checkfrom repoze.who.plugins.basicauth import BasicAuthPluginhtpasswd = HTPasswdPlugin('passwd', crypt_check)basicauth = BasicAuthPlugin('MyRepoze')identifiers = [('basicauth', basicauth)]authenticators = [('htpasswd', htpasswd)]challengers = [('basicauth', basicauth)]mdproviders = []# We'll use group and permission based exclusively on INI filesfrom repoze.what.plugins.ini import INIGroupAdapterfrom repoze.what.plugins.ini import INIPermissionsAdaptergroups = {'all_groups': INIGroupAdapter('groups.ini')}permissions = {'all_perms': INIPermissionsAdapter('permissions.ini')}# Finally, we create the repoze.what middlewareimport loggingfrom repoze.what.middleware import setup_authmiddleware = setup_auth(app = my_app,group_adapters = groups,permission_adapters = permissions,identifiers = identifiers,authenticators = authenticators,challengers = challengers,mdproviders = mdproviders,log_level = logging.DEBUG)