Nikolais ninja workbranch

This commit is contained in:
nikolark committed 2013-10-17 14:51:44 +02:00
1 parent d7659c4a17
commit 42e83727dd
10 files changed
+86 -24

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
from tastypie.authentication import ApiKeyAuthentication as tastypieApiKeyAuth
class ApiKeyAuthentication(tastypieApiKeyAuth):
"""
Override with our own ApiKey model.
"""
def get_key(self, user, api_key):
"""
Attempts to find the API key for the user. Uses ``ApiKey`` by default
but can be overridden.
"""
from dusken.models import ApiKey
try:
ApiKey.objects.get(user=user, key=api_key)
except ApiKey.DoesNotExist:
return self._unauthorized()
return True