This repository has been archived on 2025-06-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
dusken-prototype/dusken/authentication.py
T
2013-10-17 14:51:44 +02:00

20 lines
566 B
Python

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