[Repoze-checkins] r1641 - in repoze.who/trunk: . docs repoze/who repoze/who/plugins

Chris McDonough chrism at agendaless.com
Fri Aug 22 00:23:45 EDT 2008


Author: Chris McDonough <chrism at agendaless.com>
Date: Fri Aug 22 00:23:44 2008
New Revision: 1641

Log:
Prep for 1.0.4.


Modified:
   repoze.who/trunk/CHANGES.txt
   repoze.who/trunk/docs/conf.py
   repoze.who/trunk/docs/index.rst
   repoze.who/trunk/repoze/who/config.py
   repoze.who/trunk/repoze/who/plugins/auth_tkt.py
   repoze.who/trunk/repoze/who/tests.py
   repoze.who/trunk/repoze/who/version.txt

Modified: repoze.who/trunk/CHANGES.txt
==============================================================================
--- repoze.who/trunk/CHANGES.txt	(original)
+++ repoze.who/trunk/CHANGES.txt	Fri Aug 22 00:23:44 2008
@@ -1,7 +1,17 @@
 repoze.who changes
 ==================
 
-Next release
+1.0.4 (2008/08/22)
+
+ - Added a key to the '[general]' config section: ``remote_user_key``.
+   If you use this key in the config file, it tells who to 1)
+   not perform any authentication if it exists in the environment
+   during ingress and 2) to set the key in the environment for
+   the downstream app to use as the REMOTE_USER variable.  The
+   default is ``REMOTE_USER``.
+
+ - Using unicode user ids in combination with the auth_tkt plugin
+   would cause problems under mod_wsgi.
 
  - Allowed 'cookie_path' argument to InsecureCookiePlugin (and config
    constructor).  Thanks to Gustavo Narea.

Modified: repoze.who/trunk/docs/conf.py
==============================================================================
--- repoze.who/trunk/docs/conf.py	(original)
+++ repoze.who/trunk/docs/conf.py	Fri Aug 22 00:23:44 2008
@@ -51,9 +51,9 @@
 # other places throughout the built documents.
 #
 # The short X.Y version.
-version = '1.0.3'
+version = '1.0.4'
 # The full version, including alpha/beta/rc tags.
-release = '1.0.3'
+release = '1.0.4'
 
 # There are two options for replacing |today|: either, you set today to some
 # non-false value, then it is used:

Modified: repoze.who/trunk/docs/index.rst
==============================================================================
--- repoze.who/trunk/docs/index.rst	(original)
+++ repoze.who/trunk/docs/index.rst	Fri Aug 22 00:23:44 2008
@@ -541,6 +541,7 @@
     [general]
     request_classifier = repoze.who.classifiers:default_request_classifier
     challenge_decider = repoze.who.classifiers:default_challenge_decider
+    remote_user_key = REMOTE_USER
 
     [identifiers]
     # plugin_name;classifier_name:.. or just plugin_name (good for any)

Modified: repoze.who/trunk/repoze/who/config.py
==============================================================================
--- repoze.who/trunk/repoze/who/config.py	(original)
+++ repoze.who/trunk/repoze/who/config.py	Fri Aug 22 00:23:44 2008
@@ -32,6 +32,7 @@
         self.authenticators = []
         self.challengers = []
         self.mdproviders = []
+        self.remote_user_key = 'REMOTE_USER'
 
     def _makePlugin(self, name, iface, **kw):
         obj = _resolve(name)
@@ -94,6 +95,10 @@
                 cd = self._getPlugin(cd, IChallengeDecider)
             self.challenge_decider = cd
 
+            ru = general.get('remote_user_key')
+            if ru is not None:
+                self.remote_user_key = ru
+
         if 'identifiers' in cp.sections():
             identifiers = dict(cp.items('identifiers'))
             self._parsePluginSequence(self.identifiers,
@@ -156,4 +161,5 @@
                 parser.challenge_decider,
                 log_stream,
                 log_level,
+                parser.remote_user_key,
            )

Modified: repoze.who/trunk/repoze/who/plugins/auth_tkt.py
==============================================================================
--- repoze.who/trunk/repoze/who/plugins/auth_tkt.py	(original)
+++ repoze.who/trunk/repoze/who/plugins/auth_tkt.py	Fri Aug 22 00:23:44 2008
@@ -1,3 +1,6 @@
+from codecs import utf_8_decode
+from codecs import utf_8_encode
+
 from paste.request import get_cookies
 from paste.auth import auth_tkt
 
@@ -11,11 +14,13 @@
 
     userid_type_decoders = {
         'int':int,
+        'unicode':lambda x: utf_8_decode(x)[0],
         }
 
     userid_type_encoders = {
         int: ('int', str),
         long: ('int', str),
+        unicode: ('unicode', lambda x: utf_8_encode(x)[0]),
         }
     
     def __init__(self, secret, cookie_name='auth_tkt',

Modified: repoze.who/trunk/repoze/who/tests.py
==============================================================================
--- repoze.who/trunk/repoze/who/tests.py	(original)
+++ repoze.who/trunk/repoze/who/tests.py	Fri Aug 22 00:23:44 2008
@@ -1550,11 +1550,13 @@
         plugin = self._makeOne('secret')
         old_val = self._makeTicket(userid='userid')
         environ = self._makeEnviron({'HTTP_COOKIE':'auth_tkt=%s' % old_val})
-        new_val = self._makeTicket(userid=unicode('myid'), userdata='')
-        result = plugin.remember(environ, {'repoze.who.userid':unicode('myid'),
+        userid = unicode('\xc2\xa9', 'utf-8')
+        new_val = self._makeTicket(userid=userid.encode('utf-8'),
+                                   userdata='userid_type:unicode')
+        result = plugin.remember(environ, {'repoze.who.userid':userid,
                                            'userdata':''})
-        
         expected = 'auth_tkt=%s; Path=/;' % new_val
+        self.assertEqual(type(result[0][1]), str)
         self.assertEqual(result, [('Set-Cookie', expected)])
 
     def test_forget(self):
@@ -1894,6 +1896,7 @@
         config = self._makeOne()
         self.assertEqual(config.request_classifier, None)
         self.assertEqual(config.challenge_decider, None)
+        self.assertEqual(config.remote_user_key, 'REMOTE_USER')
         self.assertEqual(len(config.plugins), 0)
         self.assertEqual(len(config.identifiers), 0)
         self.assertEqual(len(config.authenticators), 0)
@@ -1905,6 +1908,7 @@
         config.parse('')
         self.assertEqual(config.request_classifier, None)
         self.assertEqual(config.challenge_decider, None)
+        self.assertEqual(config.remote_user_key, 'REMOTE_USER')
         self.assertEqual(len(config.plugins), 0)
         self.assertEqual(len(config.identifiers), 0)
         self.assertEqual(len(config.authenticators), 0)
@@ -1917,6 +1921,7 @@
         config.parse(StringIO())
         self.assertEqual(config.request_classifier, None)
         self.assertEqual(config.challenge_decider, None)
+        self.assertEqual(config.remote_user_key, 'REMOTE_USER')
         self.assertEqual(len(config.plugins), 0)
         self.assertEqual(len(config.identifiers), 0)
         self.assertEqual(len(config.authenticators), 0)
@@ -1938,6 +1943,7 @@
         config.parse('[general]')
         self.assertEqual(config.request_classifier, None)
         self.assertEqual(config.challenge_decider, None)
+        self.assertEqual(config.remote_user_key, 'REMOTE_USER')
         self.assertEqual(len(config.plugins), 0)
 
     def test_parse_general_only(self):
@@ -1950,6 +1956,7 @@
         config.parse(GENERAL_ONLY)
         self.failUnless(isinstance(config.request_classifier, PLUGIN_CLASS))
         self.failUnless(isinstance(config.challenge_decider, PLUGIN_CLASS))
+        self.assertEqual(config.remote_user_key, 'ANOTHER_REMOTE_USER')
         self.assertEqual(len(config.plugins), 0)
 
     def test_parse_general_with_plugins(self):
@@ -2100,6 +2107,7 @@
 [general]
 request_classifier = repoze.who.tests:DummyPlugin
 challenge_decider = repoze.who.tests:DummyPlugin
+remote_user_key = ANOTHER_REMOTE_USER
 """
 
 GENERAL_WITH_PLUGINS = """\

Modified: repoze.who/trunk/repoze/who/version.txt
==============================================================================
--- repoze.who/trunk/repoze/who/version.txt	(original)
+++ repoze.who/trunk/repoze/who/version.txt	Fri Aug 22 00:23:44 2008
@@ -1 +1 @@
-1.0.3
+1.0.4


More information about the Repoze-checkins mailing list