1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
.. _cookbook:
========
Cookbook
========
This is a place for community-contributed patterns & ideas for extending
Restless.
Authentication
==============
If your framework has the concept of a logged-in user (like Django), you can
do something like::
class MyResource(DjangoResource):
def is_authenticated(self):
return self.request.user.is_authenticated()
If you need a more fine graned authentication you could check your current endpoint and do something like that::
class MyResource(DjangoResource):
def is_authenticated(self):
if self.endpoint in ('update', 'create'):
return self.request.user.is_authenticated()
else:
return True
|