From 1505fd346beb244d29154b9d0e7d77eba25ada5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 12 Mar 2021 11:41:53 +0100 Subject: [PATCH] * Fixed configuration commands with parameters with "equal" sign * Fixed access using ticket --- server/src/uds/management/commands/config.py | 2 +- server/src/uds/urls.py | 2 +- server/src/uds/web/util/configjs.py | 2 ++ server/src/uds/web/views/modern.py | 8 ++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/src/uds/management/commands/config.py b/server/src/uds/management/commands/config.py index 1593d1cb..09df55f6 100644 --- a/server/src/uds/management/commands/config.py +++ b/server/src/uds/management/commands/config.py @@ -51,7 +51,7 @@ class Command(BaseCommand): try: for config in options['name_value']: logger.debug('Config: %s', config) - first, value = config.split('=') + first, value = config.split('=', 1) # Only first = is separator :) first = first.split('.') if len(first) == 2: mod, name = first diff --git a/server/src/uds/urls.py b/server/src/uds/urls.py index 8e6a49d5..1c0ab573 100644 --- a/server/src/uds/urls.py +++ b/server/src/uds/urls.py @@ -81,7 +81,7 @@ urlpatterns = [ # Ticket authentication related re_path(r'^uds/page/ticket/auth/(?P[a-zA-Z0-9.-]+)$', uds.web.views.ticketAuth, name='page.ticket.auth'), - path(r'uds/page/ticket/launcher', uds.web.views.modern.index, name='page.ticket.launcher'), + path(r'uds/page/ticket/launcher', uds.web.views.modern.ticketLauncher, name='page.ticket.launcher'), # This must be the last, so any patition will be managed by client in fact re_path(r'uds/page/.*', uds.web.views.modern.index, name='page.placeholder'), diff --git a/server/src/uds/web/util/configjs.py b/server/src/uds/web/util/configjs.py index 1296a820..ecb8fc4f 100644 --- a/server/src/uds/web/util/configjs.py +++ b/server/src/uds/web/util/configjs.py @@ -68,6 +68,8 @@ def udsJs(request: 'HttpRequest') -> str: if user: role = 'staff' if user.isStaff() and not user.is_admin else 'admin' if user.is_admin else 'user' + if request.session.get('restricted', False): + role = 'restricted' profile: typing.Dict[str, typing.Any] = { 'user': user.name if user else None, diff --git a/server/src/uds/web/views/modern.py b/server/src/uds/web/views/modern.py index 2ed05fe8..ebce890e 100644 --- a/server/src/uds/web/views/modern.py +++ b/server/src/uds/web/views/modern.py @@ -59,11 +59,18 @@ def index(request: HttpRequest) -> HttpResponse: return response +# Includes a request.session ticket, indicating that +def ticketLauncher(request: HttpRequest) -> HttpResponse: + request.session['restricted'] = True # Access is from ticket + return index(request) + + # Basically, the original /login method, but fixed for modern interface def login(request: HttpRequest, tag: typing.Optional[str] = None) -> HttpResponse: # Default empty form logger.debug('Tag: %s', tag) if request.method == 'POST': + request.session['restricted'] = False # Access is from login form = LoginForm(request.POST, tag=tag) user, data = checkLogin(request, form, tag) if user: @@ -92,6 +99,7 @@ def login(request: HttpRequest, tag: typing.Optional[str] = None) -> HttpRespons @auth.webLoginRequired(admin=False) def logout(request: HttpRequest) -> HttpResponse: auth.authLogLogout(request) + request.session['restricted'] = False # Remove restricted logoutUrl = request.user.logout() if logoutUrl is None: logoutUrl = request.session.get('logouturl', None)