Return species information as part of the flowcell json information.
[htsworkflow.git] / htsworkflow / frontend / auth.py
1 """
2 Define some alternate authentication methods
3 """
4 from django.core.exceptions import PermissionDenied
5
6 from htsworkflow.frontend import settings
7
8 apidata = {'apiid': u'0', 'apikey': settings.DEFAULT_API_KEY}
9
10 def require_api_key(request):
11     # make sure we have the api component
12     if not (request.REQUEST.has_key('apiid') or request.REQUEST.has_key('apikey')):
13         raise PermissionDenied
14
15     # make sure the id and key are right
16     if request.REQUEST['apiid'] == apidata['apiid'] and \
17        request.REQUEST['apikey'] == apidata['apikey']:
18         return True
19     else:
20         raise PermissionDenied
21         
22