blob: 87d22089e5f8a95f0a07a36f9f50b836809a6afa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
'''
Created on Dec 13, 2010
@author: leifj
'''
from django.core.exceptions import ImproperlyConfigured
from coip.apps.userprofile.models import UserProfile
import logging
from pprint import pformat
class UserMappingMiddleware(object):
'''
Middleware for supporting merged and mapped user identities
'''
def process_request(self,request):
if hasattr(request,'user'):
raise ImproperlyConfigured("Place before RemoteUserMiddleware")
logging.warning(pformat(request.META))
username = request.META['REMOTE_USER']
qs = UserProfile.objects.filter(user__username=username,primary=True)
if qs:
profile = qs[0]
username = profile.identifier
request.META['REMOTE_USER'] = username
|