diff --git a/seahub/auth/views.py b/seahub/auth/views.py index 2c0a12a3ce..32c7f2ed89 100644 --- a/seahub/auth/views.py +++ b/seahub/auth/views.py @@ -191,14 +191,17 @@ def login(request, template_name='registration/login.html', else: signup_url = '' + enable_shib_login = getattr(settings, 'ENABLE_SHIB_LOGIN', False) + return render_to_response(template_name, { - 'form': form, - redirect_field_name: redirect_to, - 'site': current_site, - 'site_name': current_site.name, - 'remember_days': settings.LOGIN_REMEMBER_DAYS, - 'signup_url': signup_url, - }, context_instance=RequestContext(request)) + 'form': form, + redirect_field_name: redirect_to, + 'site': current_site, + 'site_name': current_site.name, + 'remember_days': settings.LOGIN_REMEMBER_DAYS, + 'signup_url': signup_url, + 'enable_shib_login': enable_shib_login, + }, context_instance=RequestContext(request)) def login_simple_check(request): """A simple check for login called by thirdpart systems(OA, etc). diff --git a/seahub/templates/registration/login.html b/seahub/templates/registration/login.html index 96a153cfe5..dcbbe964f6 100644 --- a/seahub/templates/registration/login.html +++ b/seahub/templates/registration/login.html @@ -61,6 +61,10 @@ {% if enable_signup %} {% trans "Signup" %} {% endif %} + + {% if enable_shib_login %} + + {% endif %} {% endblock %} @@ -126,5 +130,11 @@ $(function() { }); })(); +$(function() { + $('#shib-login').click(function() { + window.location = "{% url 'shib_login' %}"; + return false; + }); +}); {% endblock %} diff --git a/seahub/urls.py b/seahub/urls.py index cac251c0a9..c3422b6d0e 100644 --- a/seahub/urls.py +++ b/seahub/urls.py @@ -264,6 +264,11 @@ if getattr(settings, 'MULTI_TENANCY', False): (r'^org/', include('seahub_extra.organizations.urls')), ) +if getattr(settings, 'ENABLE_SHIB_LOGIN', False): + urlpatterns += patterns('', + url(r'^shib-login/', shib_login, name="shib_login"), + ) + # serve office converter static files from seahub.utils import HAS_OFFICE_CONVERTER, CLUSTER_MODE, OFFICE_CONVERTOR_NODE if HAS_OFFICE_CONVERTER: diff --git a/seahub/views/__init__.py b/seahub/views/__init__.py index 21a2939782..6f4dbcd4df 100644 --- a/seahub/views/__init__.py +++ b/seahub/views/__init__.py @@ -1938,3 +1938,6 @@ def image_view(request, filename): if content_encoding: response['Content-Encoding'] = content_encoding return response + +def shib_login(request): + return HttpResponseRedirect(reverse('myhome'))