Commit e8a587f4 authored by Valentin Samir's avatar Valentin Samir

Disable federated auth if CAS_FEDERATE is False

parent 5cf820e4
......@@ -44,6 +44,9 @@ class FederatedUser(models.Model):
ticket = models.CharField(max_length=255)
last_update = models.DateTimeField(auto_now=True)
def __unicode__(self):
return u"%s@%s" % (self.username, self.provider)
class User(models.Model):
"""A user logged into the CAS"""
......
......@@ -182,6 +182,8 @@ class LogoutView(View, LogoutMixin):
class FederateAuth(View):
def post(self, request, provider=None):
if not settings.CAS_FEDERATE:
return redirect("cas_server:login")
form = forms.FederateSelect(request.POST)
if form.is_valid():
params = utils.copy_params(
......@@ -202,6 +204,8 @@ class FederateAuth(View):
return redirect("cas_server:login")
def get(self, request, provider=None):
if not settings.CAS_FEDERATE:
return redirect("cas_server:login")
if provider not in settings.CAS_FEDERATE_PROVIDERS:
return redirect("cas_server:login")
service_url = utils.get_current_url(request, {"ticket", "provider"})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment