From b66b7fb531ac01e9f493438b6b1df8105ccc8384 Mon Sep 17 00:00:00 2001 From: Christian Dresen <c.dresen@fh-muenster.de> Date: Sat, 9 Jan 2016 16:54:27 +0100 Subject: [PATCH] Docker for Web --- web/templates/base.html | 2 +- web/warpauth/views/login.py | 6 +++++- web/warpzone/settings.py | 12 ++++++------ web_docker/Dockerfile | 34 ++++++++++++++++++++++++++++++++++ web_docker/build.sh | 1 + web_docker/entrypoint.sh | 3 +++ web_docker/run.sh | 5 +++++ 7 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 web_docker/Dockerfile create mode 100644 web_docker/build.sh create mode 100644 web_docker/entrypoint.sh create mode 100644 web_docker/run.sh diff --git a/web/templates/base.html b/web/templates/base.html index 76a0785..3735961 100644 --- a/web/templates/base.html +++ b/web/templates/base.html @@ -77,7 +77,7 @@ <div class="container"> <div class="container"> <div class="navbar-header"> - <p class="text-muted"><small>Warpzone</small></p> + <p class="text-muted"><small>Warpzone</small></p>{% get_current_language as LANGUAGE_CODE %} {{ LANGUAGE_CODE}} </div> </div> </div> diff --git a/web/warpauth/views/login.py b/web/warpauth/views/login.py index cffb99b..7bc07bc 100644 --- a/web/warpauth/views/login.py +++ b/web/warpauth/views/login.py @@ -3,7 +3,7 @@ from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotAll from django.contrib.auth import authenticate, login, logout from django.shortcuts import redirect from django.contrib.auth.decorators import login_required - +from django.utils import translation from warpauth.util import * def login_view(request): @@ -18,6 +18,10 @@ def login_view(request): if user is not None: if user.is_active: login(request, user) + + user_language = 'de_DE' + translation.activate(user_language) + request.session[translation.LANGUAGE_SESSION_KEY] = user_language return redirect('/') else: if username != "" and password != "": diff --git a/web/warpzone/settings.py b/web/warpzone/settings.py index 6ceebef..562aabb 100644 --- a/web/warpzone/settings.py +++ b/web/warpzone/settings.py @@ -155,7 +155,7 @@ AUTH_LDAP_USER_SEARCH = LDAPSearch(AUTH_LDAP_USER_SEARCH_PATH, AUTH_LDAP_USER_ATTR_MAP = {"first_name": "givenName", "last_name": "sn", "email": "description"} AUTH_LDAP_PROFILE_ATTR_MAP = {"home_directory": "homeDirectory"} -AUTH_LDAP_GROUP_SEARCH_PATH = "ou=Groups,dc=warpzone,dc=ms" +AUTH_LDAP_GROUP_SEARCH_PATH = "dc=warpzone,dc=ms" AUTH_LDAP_GROUP_SEARCH = LDAPSearch(AUTH_LDAP_GROUP_SEARCH_PATH, ldap.SCOPE_SUBTREE, "(objectClass=posixGroup)" ) @@ -163,16 +163,16 @@ AUTH_LDAP_GROUP_SEARCH = LDAPSearch(AUTH_LDAP_GROUP_SEARCH_PATH, AUTH_LDAP_GROUP_TYPE = PosixGroupType() AUTH_LDAP_USER_FLAGS_BY_GROUP = { - "is_active": "cn=active,ou=Groups,dc=warpzone,dc=ms", - "is_staff": ["cn=superuser,ou=Groups,dc=warpzone,dc=ms", - "cn=superuser,ou=Groups,dc=warpzone,dc=ms"], - "is_superuser": "cn=superuser,ou=Groups,dc=warpzone,dc=ms" + "is_active": "cn=active,ou=groups,ou=WarpAuth,ou=Warpzone,dc=warpzone,dc=ms", + "is_staff": ["cn=superuser,ou=groups,ou=WarpAuth,ou=Warpzone,dc=warpzone,dc=ms", + "cn=superuser,ou=groups,ou=WarpAuth,ou=Warpzone,dc=warpzone,dc=ms"], + "is_superuser": "cn=superuser,ou=groups,ou=WarpAuth,ou=Warpzone,dc=warpzone,dc=ms" } AUTH_LDAP_FIND_GROUP_PERMS = True AUTH_LDAP_CACHE_GROUPS = True -AUTH_LDAP_GROUP_CACHE_TIMEOUT = 300 +AUTH_LDAP_GROUP_CACHE_TIMEOUT = 10 logger = logging.getLogger('django_auth_ldap') logger.addHandler(logging.StreamHandler()) diff --git a/web_docker/Dockerfile b/web_docker/Dockerfile new file mode 100644 index 0000000..d7a616f --- /dev/null +++ b/web_docker/Dockerfile @@ -0,0 +1,34 @@ +From debian:jessie + +RUN apt-get update && apt-get install -y \ + debconf-utils \ + apt-utils \ + ssh \ + less \ + ldap-utils \ + rsyslog \ + nano \ + python \ + python-pip \ + python-django-auth-ldap \ + python-bootstrapform \ + python-ldap \ + python-dev + build-essential \ + libfreetype6-dev \ + python-imaging \ + libjpeg-dev + +RUN pip install django \ + django-ldapdb \ + reportlab + +RUN cd /opt/warpauth/;python manage.py migrate + +COPY entrypoint.sh /opt/entrypoint.sh +EXPOSE 22 8000 + +VOLUME ["/opt/warpauth"] + +ENTRYPOINT sh /opt/entrypoint.sh + diff --git a/web_docker/build.sh b/web_docker/build.sh new file mode 100644 index 0000000..e833f90 --- /dev/null +++ b/web_docker/build.sh @@ -0,0 +1 @@ +docker build -t warpauth_web . diff --git a/web_docker/entrypoint.sh b/web_docker/entrypoint.sh new file mode 100644 index 0000000..bb41662 --- /dev/null +++ b/web_docker/entrypoint.sh @@ -0,0 +1,3 @@ +service rsyslog restart +bash + diff --git a/web_docker/run.sh b/web_docker/run.sh new file mode 100644 index 0000000..d043c24 --- /dev/null +++ b/web_docker/run.sh @@ -0,0 +1,5 @@ +docker run \ + -v /home/chris/Documents/warpzone/web:/opt/warpauth \ + -p 8124:80 \ + -it \ + warpauth_web -- GitLab