Disable federated auth if CAS_FEDERATE is False

This commit is contained in:
Valentin Samir 2016-06-19 13:00:28 +02:00
parent 5cf820e44f
commit e8a587f48a
2 changed files with 7 additions and 0 deletions

View File

@ -44,6 +44,9 @@ class FederatedUser(models.Model):
ticket = models.CharField(max_length=255) ticket = models.CharField(max_length=255)
last_update = models.DateTimeField(auto_now=True) last_update = models.DateTimeField(auto_now=True)
def __unicode__(self):
return u"%s@%s" % (self.username, self.provider)
class User(models.Model): class User(models.Model):
"""A user logged into the CAS""" """A user logged into the CAS"""

View File

@ -182,6 +182,8 @@ class LogoutView(View, LogoutMixin):
class FederateAuth(View): class FederateAuth(View):
def post(self, request, provider=None): def post(self, request, provider=None):
if not settings.CAS_FEDERATE:
return redirect("cas_server:login")
form = forms.FederateSelect(request.POST) form = forms.FederateSelect(request.POST)
if form.is_valid(): if form.is_valid():
params = utils.copy_params( params = utils.copy_params(
@ -202,6 +204,8 @@ class FederateAuth(View):
return redirect("cas_server:login") return redirect("cas_server:login")
def get(self, request, provider=None): def get(self, request, provider=None):
if not settings.CAS_FEDERATE:
return redirect("cas_server:login")
if provider not in settings.CAS_FEDERATE_PROVIDERS: if provider not in settings.CAS_FEDERATE_PROVIDERS:
return redirect("cas_server:login") return redirect("cas_server:login")
service_url = utils.get_current_url(request, {"ticket", "provider"}) service_url = utils.get_current_url(request, {"ticket", "provider"})