Revision dd53338a api/middleware.py

b/api/middleware.py
1 1
from django.conf import settings
2 2
from django.http import HttpResponse, HttpResponseRedirect
3
from synnefo.api.errors import Unauthorized
4 3
from synnefo.db.models import SynnefoUser
5 4

  
6 5
class SynnefoAuthMiddleware(object):
......
15 14
            #Retrieve user from DB or other caching mechanism
16 15
            user = SynnefoUser.objects.filter(auth_token = request.META[self.auth_token])
17 16
            if user is None :
18
                return HttpResponseRedirect(content='Athentication Required')
17
                return HttpResponseRedirect(settings.SIBBOLLETH_HOST)
19 18
            request.user = user
20 19
            return
21 20

  
......
28 27
            # mechanism
29 28
            user = SynnefoUser.objects.filter(username = request.META[self.auth_user])
30 29

  
31
            return HttpResponseRedirect(content= settings.SIBBOLLETH_HOST)
30
            return HttpResponseRedirect(settings.SIBBOLLETH_HOST)
32 31

  
33
        return HttpResponseRedirect(content='Athentication Required')
32
        return HttpResponseRedirect(settings.SIBBOLLETH_HOST)
33

  
34
    def process_response(self, request, response):
35
        response['Vary'] = self.auth_key
36
        return response
34 37

  
35 38
#class HttpResponseAuthenticationRequired(HttpResponse):
36 39
#    status_code = 401

Also available in: Unified diff