Test htsworkflow under several different django & python versions
[htsworkflow.git] / htsworkflow / auth.py
1 """
2 Define some alternate authentication methods
3 """
4 from django.core.exceptions import PermissionDenied
5 from django.conf import settings
6
7 apidata = {'apiid': u'0', 'apikey': settings.DEFAULT_API_KEY}
8
9 def require_api_key(request):
10     # make sure we have the api component
11     if not ('apiid' in request.GET or 'apikey' in request.GET):
12         raise PermissionDenied
13
14     # make sure the id and key are right
15     if request.GET['apiid'] == apidata['apiid'] and \
16        request.GET['apikey'] == apidata['apikey']:
17         return True
18     else:
19         raise PermissionDenied