Login

Digest authentication for Piston

Author:
erikwright
Posted:
January 15, 2010
Language:
Python
Version:
1.1
Tags:
django http authentication api digest piston
Score:
2 (after 2 ratings)

This simple class allows you to use django-digest (http://bitbucket.org/akoha/django-digest/) with Piston.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from django_digest import HttpDigestAuthenticator

class HttpDigestAuthentication(object):
        
    def __init__(self):
        self._authenticator = HttpDigestAuthenticator()

    def is_authenticated(self, request):
        return self._authenticator.authenticate(request)
            
    def challenge(self):
        return self._authenticator.build_challenge_response()

More like this

Comments

paule (on January 19, 2010):
<p>Thanks a lot, could you please provide a short explanation how to integrate it? Thank you!</p>

#

paule (on January 20, 2010):
<p>I tried it this way now:</p> <pre>class P2f_HttpDigestAuthentication(object): def __init__(self): self._authenticator = HttpDigestAuthenticator() def is_authenticated(self, request): return self._authenticator.authenticate(request) def challenge(self): return self._authenticator.build_challenge_response() auth = P2f_HttpDigestAuthentication() urlpatterns = patterns('myapp.api', url(r'^(?P<emitter_format>.+)/test/$', Resource(TestHandler, authentication=auth)), … </pre> <p>but no authentication is required. Any ideas?</p>

#

paule (on January 20, 2010):
<p>Works now - I had the credentials in the cache...</p>

#

dumb906 (on May 12, 2012):
<p>works</p>

#

Please login first before commenting.