1 from django.conf import settings
2 from django_cas.backends import CASBackend
4 attr_map = getattr(settings, 'CAS_USER_ATTRS_MAP', {
6 'firstname': 'first_name',
7 'lastname': 'last_name',
10 class AttrCASBackend(CASBackend):
11 def authenticate(self, ticket, service, request):
12 user = super(AttrCASBackend, self).authenticate(ticket, service, request)
14 for attr, value in request.session.get('attributes', {}).items():
16 local_attr = attr_map[attr]
20 if getattr(user, local_attr, None) != value:
21 setattr(user, local_attr, value)