eed3653d22
Whenever a user logs in through CAS, their username is looked up in the .rhosts file provided through settings. If it is found, the user is granted staff status and BOcal group (cf fixture). The rights are re-evaluated at each login and at each access to /admin/login. Close #2.
16 lines
509 B
Python
16 lines
509 B
Python
from django.dispatch import receiver
|
|
from django_cas_ng.signals import cas_user_authenticated, cas_user_logout
|
|
from . import rhosts
|
|
|
|
|
|
@receiver(cas_user_authenticated)
|
|
def onCasLogin(sender, user, **kwargs):
|
|
''' Called upon login of a user through CAS '''
|
|
rhosts.evalRhostsPrivileges(user)
|
|
|
|
|
|
@receiver(cas_user_logout)
|
|
def onCasLogout(sender, user, **kwargs):
|
|
''' Strip the user from their privileges — in case something goes wrong
|
|
during the next authentication '''
|
|
rhosts.logout(user)
|