[Repoze-checkins] r951 - www/trunk/blog.repoze.org/entries

Chris McDonough chrism at agendaless.com
Sun May 4 11:52:08 EDT 2008


Author: Chris McDonough <chrism at agendaless.com>
Date: Sun May  4 11:52:07 2008
New Revision: 951

Log:
Add blog entry about repoze.who 1.0.


Added:
   www/trunk/blog.repoze.org/entries/repozewho-1.0.txt   (contents, props changed)

Added: www/trunk/blog.repoze.org/entries/repozewho-1.0.txt
==============================================================================
--- (empty file)
+++ www/trunk/blog.repoze.org/entries/repozewho-1.0.txt	Sun May  4 11:52:07 2008
@@ -0,0 +1,137 @@
+repoze.who 1.0 Released
+#label general
+
+<p>
+
+Version 1.0 of the <a
+href="http://svn.repoze.org/repoze.who/trunk">repoze.who</a> WSGI
+authentication framework has been released.  You can get it via
+<code>easy_install -i http://dist.repoze.org/simple repoze.who</code>.
+
+</p>
+
+<p>
+
+Version 1.0 has optional support for middleware configuration via a
+config file (thanks to Tres).  Being a framework, <i>repoze.who</i> is
+configuration-heavy, and it can provide a better separation of
+concerns and more convenience to wire it up via a configuration file
+than via Python code.  So rather than configuring the middleware and
+attendant plugins via straight Python code, you can now wire who
+configuration up in an .ini file:
+
+</p>
+
+<pre>
+    # who.ini
+
+    [plugin:form]
+    # identification and challenge
+    use = repoze.who.plugins.form:make_plugin
+    login_form_qs = __do_login
+    rememberer_name = cookie
+    form = %(here)s/login_form.html
+
+    [plugin:auth_tkt]
+    # identification
+    use = repoze.who.plugins.auth_tkt:make_plugin
+    secret = s33kr1t
+    cookie_name = oatmeal
+    secure = False
+    include_ip = False
+
+    [plugin:basicauth]
+    # identification and challenge
+    use = repoze.who.plugins.basicauth:make_plugin
+    realm = 'sample'
+
+    [plugin:htpasswd]
+    # authentication
+    use = repoze.who.plugins.htpasswd:make_plugin
+    filename = %(here)s/passwd
+    check_fn = repoze.who.plugins.htpasswd:crypt_check
+
+    [plugin:sqlusers]
+    # authentication
+    use = repoze.who.plugins.sql:make_authenticator_plugin
+    query = "SELECT userid, password FROM users where login = %(login)s;"
+    conn_factory = repoze.who.plugins.sql:make_psycopg_conn_factory
+    compare_fn = repoze.who.plugins.sql:default_password_compare
+
+    [plugin:sqlproperties]
+    name = properties
+    use = repoze.who.plugins.sql:make_metadata_plugin
+    query = "SELECT firstname, lastname FROM users where userid = %(__userid)s;"
+    filter = my.package:filter_propmd
+    conn_factory = repoze.who.plugins.sql:make_psycopg_conn_factory
+
+    [general]
+    request_classifier = repoze.who.classifiers:default_request_classifier
+    challenge_decider = repoze.who.classifiers:default_challenge_decider
+
+    [identifiers]
+    # plugin_name;classifier_name:.. or just plugin_name (good for any)
+    plugins =
+          form;browser
+          auth_tkt
+          basicauth
+
+    [authenticators]
+    # plugin_name;classifier_name.. or just plugin_name (good for any)
+    plugins =
+          htpasswd
+          sqlusers
+
+    [challengers]
+    # plugin_name;classifier_name:.. or just plugin_name (good for any)
+    plugins =
+          form;browser
+          basicauth
+
+    [mdproviders]
+    plugins =
+          sqlproperties
+</pre>
+
+<p> Then you can use a constructor to create the configuration based
+on the .ini file, e.g.: </p>
+
+<pre>
+from repoze.who.config import WhoConfig
+
+app = {next app in pipeline}
+here = os.path.dirname(__file__)
+config_file = os.path.join(here, 'who.ini')
+parser = WhoConfig(here)
+parser.parse(open(config_file))
+middleware = PluggableAuthenticationMiddleware(app,
+             parser.identifiers,
+             parser.authenticators,
+             parser.challengers,
+             parser.mdproviders,
+             parser.request_classifier,
+             parser_challenge_decider,
+             log_stream = sys.stdout,
+             log_level = logging.DEBUG,
+             )
+</pre>
+
+<p> There is a PasteScript-compatible constructor available via the
+egg name <code>egg:repoze.who#config</code> that does just this, so
+you can also just wire it up via a paste config file equivalently,
+ala: </p>
+
+<pre>
+[filter:who]
+use = egg:repoze.who#config
+config_file = %(here)s/etc/who.ini
+log_level = debug
+log_stream = stdout
+</pre>
+
+<p>You can read the <a
+href="http://svn.repoze.org/repoze.who/trunk/README.txt">documentation</a>
+for more information about configuration.</p>
+
+<p> - Chris </p>
+


More information about the Repoze-checkins mailing list