I tried putting tgrepozewho up on our linux server and it failed
wonderfully. Something about userid being a long that it doesnt
like. Where is the right place to cast the userid into a string?
cheers.
-chris
URL: http://sccdata:13001/login_handler?came_from=http://sccdata:13001/ File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
WebError-0.8a-py2.5.egg/weberror/evalexception/middleware.py', line
364 in respond
app_iter = self.application(environ, detect_start_response)
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
ToscaWidgets-0.8.5-py2.5.egg/tw/core/middleware.py', line 39 in
__call__
return self.wsgi_app(environ, start_response)
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
Paste-1.6-py2.5.egg/paste/registry.py', line 334 in __call__
app_iter = self.application(environ, start_response)
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
ToscaWidgets-0.8.5-py2.5.egg/tw/core/middleware.py', line 54 in
wsgi_app
app_iter = self.application(environ, start_response)
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
Beaker-0.9.4-py2.5.egg/beaker/middleware.py', line 75 in __call__
return self.app(environ, start_response)
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
Beaker-0.9.4-py2.5.egg/beaker/middleware.py', line 147 in __call__
return self.wrap_app(environ, session_start_response)
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
Routes-1.8-py2.5.egg/routes/middleware.py', line 99 in __call__
response = self.app(environ, start_response)
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
repoze.who-0.9.1-py2.5.egg/repoze/who/middleware.py', line 131 in
__call__
remember_headers = identifier.remember(environ, identity)
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
repoze.who-0.9.1-py2.5.egg/repoze/who/plugins/form.py', line 59 in
remember
return rememberer.remember(environ, identity)
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
repoze.who-0.9.1-py2.5.egg/repoze/who/plugins/auth_tkt.py', line 130
in remember
new_cookie_value = ticket.cookie_value()
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 102 in cookie_value
v = '%s%08x%s!' % (self.digest(), int(self.time), self.userid)
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 99 in digest
self.user_data)
File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 169 in
calculate_digest
+ tokens + '\0' + user_data).hexdigest()
TypeError: cannot concatenate 'str' and 'long' objects
I thought I fixed this in 0.9.1. You might have found an additional
bug. I've only tested under Python 2.4 using Paste 1.5, that may be
the difference. :-( There is code in repoze.who's plugins/auth_tkt.py
that is meant to cast an integer to a string on egress and back again
on ingress but it doesn't handle longs. Can you try the following
patch?
percious wrote:
> I tried putting tgrepozewho up on our linux server and it failed
> wonderfully. Something about userid being a long that it doesnt
> like. Where is the right place to cast the userid into a string?
> cheers.
> -chris
> URL: http://sccdata:13001/login_handler?came_from=http://sccdata:13001/ > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> WebError-0.8a-py2.5.egg/weberror/evalexception/middleware.py', line
> 364 in respond
> app_iter = self.application(environ, detect_start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> ToscaWidgets-0.8.5-py2.5.egg/tw/core/middleware.py', line 39 in
> __call__
> return self.wsgi_app(environ, start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Paste-1.6-py2.5.egg/paste/registry.py', line 334 in __call__
> app_iter = self.application(environ, start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> ToscaWidgets-0.8.5-py2.5.egg/tw/core/middleware.py', line 54 in
> wsgi_app
> app_iter = self.application(environ, start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Beaker-0.9.4-py2.5.egg/beaker/middleware.py', line 75 in __call__
> return self.app(environ, start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Beaker-0.9.4-py2.5.egg/beaker/middleware.py', line 147 in __call__
> return self.wrap_app(environ, session_start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Routes-1.8-py2.5.egg/routes/middleware.py', line 99 in __call__
> response = self.app(environ, start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> repoze.who-0.9.1-py2.5.egg/repoze/who/middleware.py', line 131 in
> __call__
> remember_headers = identifier.remember(environ, identity)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> repoze.who-0.9.1-py2.5.egg/repoze/who/plugins/form.py', line 59 in
> remember
> return rememberer.remember(environ, identity)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> repoze.who-0.9.1-py2.5.egg/repoze/who/plugins/auth_tkt.py', line 130
> in remember
> new_cookie_value = ticket.cookie_value()
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 102 in cookie_value
> v = '%s%08x%s!' % (self.digest(), int(self.time), self.userid)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 99 in digest
> self.user_data)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 169 in
> calculate_digest
> + tokens + '\0' + user_data).hexdigest()
> TypeError: cannot concatenate 'str' and 'long' objects
> I tried putting tgrepozewho up on our linux server and it failed
> wonderfully. Something about userid being a long that it doesnt
> like. Where is the right place to cast the userid into a string?
> cheers.
> -chris
> URL:http://sccdata:13001/login_handler?came_from=http://sccdata:13001/ > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> WebError-0.8a-py2.5.egg/weberror/evalexception/middleware.py', line
> 364 in respond
> app_iter = self.application(environ, detect_start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> ToscaWidgets-0.8.5-py2.5.egg/tw/core/middleware.py', line 39 in
> __call__
> return self.wsgi_app(environ, start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Paste-1.6-py2.5.egg/paste/registry.py', line 334 in __call__
> app_iter = self.application(environ, start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> ToscaWidgets-0.8.5-py2.5.egg/tw/core/middleware.py', line 54 in
> wsgi_app
> app_iter = self.application(environ, start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Beaker-0.9.4-py2.5.egg/beaker/middleware.py', line 75 in __call__
> return self.app(environ, start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Beaker-0.9.4-py2.5.egg/beaker/middleware.py', line 147 in __call__
> return self.wrap_app(environ, session_start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Routes-1.8-py2.5.egg/routes/middleware.py', line 99 in __call__
> response = self.app(environ, start_response)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> repoze.who-0.9.1-py2.5.egg/repoze/who/middleware.py', line 131 in
> __call__
> remember_headers = identifier.remember(environ, identity)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> repoze.who-0.9.1-py2.5.egg/repoze/who/plugins/form.py', line 59 in
> remember
> return rememberer.remember(environ, identity)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> repoze.who-0.9.1-py2.5.egg/repoze/who/plugins/auth_tkt.py', line 130
> in remember
> new_cookie_value = ticket.cookie_value()
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 102 in cookie_value
> v = '%s%08x%s!' % (self.digest(), int(self.time), self.userid)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 99 in digest
> self.user_data)
> File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 169 in
> calculate_digest
> + tokens + '\0' + user_data).hexdigest()
> TypeError: cannot concatenate 'str' and 'long' objects
> I thought I fixed this in 0.9.1. You might have found an additional
> bug. I've only tested under Python 2.4 using Paste 1.5, that may be
> the difference. :-( There is code in repoze.who's plugins/auth_tkt.py
> that is meant to cast an integer to a string on egress and back again
> on ingress but it doesn't handle longs. Can you try the following
> patch?
> percious wrote:
> > I tried putting tgrepozewho up on our linux server and it failed
> > wonderfully. Something about userid being a long that it doesnt
> > like. Where is the right place to cast the userid into a string?
> > cheers.
> > -chris
> > URL:http://sccdata:13001/login_handler?came_from=http://sccdata:13001/ > > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > WebError-0.8a-py2.5.egg/weberror/evalexception/middleware.py', line
> > 364 in respond
> > app_iter = self.application(environ, detect_start_response)
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > ToscaWidgets-0.8.5-py2.5.egg/tw/core/middleware.py', line 39 in
> > __call__
> > return self.wsgi_app(environ, start_response)
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > Paste-1.6-py2.5.egg/paste/registry.py', line 334 in __call__
> > app_iter = self.application(environ, start_response)
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > ToscaWidgets-0.8.5-py2.5.egg/tw/core/middleware.py', line 54 in
> > wsgi_app
> > app_iter = self.application(environ, start_response)
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > Beaker-0.9.4-py2.5.egg/beaker/middleware.py', line 75 in __call__
> > return self.app(environ, start_response)
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > Beaker-0.9.4-py2.5.egg/beaker/middleware.py', line 147 in __call__
> > return self.wrap_app(environ, session_start_response)
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > Routes-1.8-py2.5.egg/routes/middleware.py', line 99 in __call__
> > response = self.app(environ, start_response)
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > repoze.who-0.9.1-py2.5.egg/repoze/who/middleware.py', line 131 in
> > __call__
> > remember_headers = identifier.remember(environ, identity)
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > repoze.who-0.9.1-py2.5.egg/repoze/who/plugins/form.py', line 59 in
> > remember
> > return rememberer.remember(environ, identity)
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > repoze.who-0.9.1-py2.5.egg/repoze/who/plugins/auth_tkt.py', line 130
> > in remember
> > new_cookie_value = ticket.cookie_value()
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 102 in cookie_value
> > v = '%s%08x%s!' % (self.digest(), int(self.time), self.userid)
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 99 in digest
> > self.user_data)
> > File '/var/scratch/sccdata/sites/mbms/lib/python2.5/site-packages/
> > Paste-1.6-py2.5.egg/paste/auth/auth_tkt.py', line 169 in
> > calculate_digest
> > + tokens + '\0' + user_data).hexdigest()
> > TypeError: cannot concatenate 'str' and 'long' objects
Thanks for the fix. Works great now.... Now if we could only get a
way to authorize on TG Controllers (ie. requires) we would be in good
shape. I will probably be writing this code at the next sprint.
cheers.
-chris
On May 7, 5:30 pm, chrism <chr...@plope.com> wrote:
> On May 7, 7:20 pm, chrism <chr...@plope.com> wrote:
> > I thought I fixed this in 0.9.1. You might have found an additional
> > bug. I've only tested under Python 2.4 using Paste 1.5, that may be
> > the difference. :-( There is code in repoze.who's plugins/auth_tkt.py
> > that is meant to cast an integer to a string on egress and back again
> > on ingress but it doesn't handle longs. Can you try the following
> > patch?
> > percious wrote:
> > > I tried putting tgrepozewho up on our linux server and it failed
> > > wonderfully. Something about userid being a long that it doesnt
> > > like. Where is the right place to cast the userid into a string?
> Thanks for the fix. Works great now.... Now if we could only get a
> way to authorize on TG Controllers (ie. requires) we would be in good
> shape. I will probably be writing this code at the next sprint.
> cheers.
> -chris
> On May 7, 5:30 pm, chrism <chr...@plope.com> wrote:
> > On May 7, 7:20 pm, chrism <chr...@plope.com> wrote:
> > > I thought I fixed this in 0.9.1. You might have found an additional
> > > bug. I've only tested under Python 2.4 using Paste 1.5, that may be
> > > the difference. :-( There is code in repoze.who's plugins/auth_tkt.py
> > > that is meant to cast an integer to a string on egress and back again
> > > on ingress but it doesn't handle longs. Can you try the following
> > > patch?
> > > percious wrote:
> > > > I tried putting tgrepozewho up on our linux server and it failed
> > > > wonderfully. Something about userid being a long that it doesnt
> > > > like. Where is the right place to cast the userid into a string?
nope, what ChrisP wants is to be able to protect a full controller without being forced to used a decorator on each exposed method. This is something that is still needed.
> nope, what ChrisP wants is to be able to protect a full controller > without being forced to used a decorator on each exposed method. > This is something that is still needed.
I think I have a sample of something that could work for this somewhere, I'll try to post it up somewhere (or just add it to tgrepozewho) in the next couple of days.
for name, value in inspect.getmembers(controller): if inspect.ismethod(value): if iscontroller(value): value.decoration.hooks['before_call'].append( root_class._perform_validation ) elif hasattr(value, '__class__'): if name.startswith('__') and name.endswith('__'): continue walk_controller(root_class, value)
class SecuredControllerMeta(type): def __init__(cls, name, bases, dict_): walk_controller(cls, cls)
class SecuredController(object): __metaclass__ = SecuredControllerMeta
@classmethod def _perform_validation(cls, *args, **kwargs): if not cls.check_permissions(): abort(401, 'Unauthorized')
Basically this ensures that the classmethod check_permissions is called (at the before_call hook) for every method in the class, or any of it's member objects.
Obviously we could extend this so that we do identity predicate checks specifically. But as long as check_permission returns a boolian value we're good.
And we might be able to tweek the dispatch mechanism a bit to eliminate the need for some of this stuff. This works, but it's not particularly efficient at object instantiation time...
--Mark
On Sun, May 11, 2008 at 12:24 AM, Mark Ramm <mark.mchristen...@gmail.com> wrote: >> nope, what ChrisP wants is to be able to protect a full controller >> without being forced to used a decorator on each exposed method. >> This is something that is still needed.
> I think I have a sample of something that could work for this > somewhere, I'll try to post it up somewhere (or just add it to > tgrepozewho) in the next couple of days.