diff --git a/README.rst b/README.rst index 8d037af..78eaae1 100644 --- a/README.rst +++ b/README.rst @@ -104,6 +104,9 @@ All settings are optional. Add them to ``settings.py`` to customize ``django-cas Template settings: +* ``CAS_LOGO_URL``: Url to the logo showed in the up left corner on the default + templates. Set it to ``False`` to disable it. + * ``CAS_LOGIN_TEMPLATE``: Path to the template showed on ``/login`` then the user is not autenticated. The default is ``"cas_server/login.html"``. * ``CAS_WARN_TEMPLATE``: Path to the template showed on ``/login?service=...`` then diff --git a/cas_server/default_settings.py b/cas_server/default_settings.py index 139569d..9ad6f53 100644 --- a/cas_server/default_settings.py +++ b/cas_server/default_settings.py @@ -10,6 +10,7 @@ # (c) 2015 Valentin Samir """Default values for the app's settings""" from django.conf import settings +from django.contrib.staticfiles.templatetags.staticfiles import static def setting_default(name, default_value): @@ -17,6 +18,8 @@ def setting_default(name, default_value): value = getattr(settings, name, default_value) setattr(settings, name, value) +setting_default('CAS_LOGO_URL', static("cas_server/logo.png")) + setting_default('CAS_LOGIN_TEMPLATE', 'cas_server/login.html') setting_default('CAS_WARN_TEMPLATE', 'cas_server/warn.html') setting_default('CAS_LOGGED_TEMPLATE', 'cas_server/logged.html') diff --git a/cas_server/static/cas_server/login.css b/cas_server/static/cas_server/login.css index 865312a..cd81500 100644 --- a/cas_server/static/cas_server/login.css +++ b/cas_server/static/cas_server/login.css @@ -40,3 +40,10 @@ body { border-top-right-radius: 0; } +#app-name { + text-align: center; +} +#app-name img { + width:110px; +} + diff --git a/cas_server/static/cas_server/logo.png b/cas_server/static/cas_server/logo.png new file mode 100644 index 0000000..0bbae02 Binary files /dev/null and b/cas_server/static/cas_server/logo.png differ diff --git a/cas_server/static/cas_server/logo.svg b/cas_server/static/cas_server/logo.svg new file mode 100644 index 0000000..b9c3cdd --- /dev/null +++ b/cas_server/static/cas_server/logo.svg @@ -0,0 +1,114 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + CAS + + diff --git a/cas_server/templates/cas_server/base.html b/cas_server/templates/cas_server/base.html index 9a51014..cb3a93e 100644 --- a/cas_server/templates/cas_server/base.html +++ b/cas_server/templates/cas_server/base.html @@ -12,6 +12,15 @@ {% block bootstrap3_content %}
+
+
+
+

+ {% if settings.CAS_LOGO_URL %} {% endif %} + {% trans "Central Authentication Service" %}

+
+
+
diff --git a/cas_server/utils.py b/cas_server/utils.py index c3b2c32..fdb8f46 100644 --- a/cas_server/utils.py +++ b/cas_server/utils.py @@ -28,6 +28,11 @@ except ImportError: from urllib.parse import urlparse, urlunparse, parse_qsl, urlencode +def context(params): + params["settings"] = settings + return params + + def JsonResponse(request, data): data["messages"] = [] for msg in messages.get_messages(request): diff --git a/cas_server/views.py b/cas_server/views.py index 4e27ead..e431499 100644 --- a/cas_server/views.py +++ b/cas_server/views.py @@ -164,7 +164,7 @@ class LogoutView(View, LogoutMixin): return render( request, settings.CAS_LOGOUT_TEMPLATE, - {'logout_msg': logout_msg} + utils.context({'logout_msg': logout_msg}) ) @@ -348,7 +348,7 @@ class LoginView(View, LogoutMixin): return render( self.request, settings.CAS_WARN_TEMPLATE, - {'form': warn_form} + utils.context({'form': warn_form}) ) else: # redirect, using method ? @@ -402,7 +402,7 @@ class LoginView(View, LogoutMixin): return render( self.request, settings.CAS_LOGGED_TEMPLATE, - {'session': self.request.session} + utils.context({'session': self.request.session}) ) else: data = {"status": "error", "detail": "auth", "code": error} @@ -443,7 +443,7 @@ class LoginView(View, LogoutMixin): return render( self.request, settings.CAS_LOGGED_TEMPLATE, - {'session': self.request.session} + utils.context({'session': self.request.session}) ) def not_authenticated(self): @@ -483,7 +483,11 @@ class LoginView(View, LogoutMixin): } return JsonResponse(self.request, data) else: - return render(self.request, settings.CAS_LOGIN_TEMPLATE, {'form': self.form}) + return render( + self.request, + settings.CAS_LOGIN_TEMPLATE, + utils.context({'form': self.form}) + ) def common(self): """Part execute uppon GET and POST request"""