diff --git a/server/src/uds/core/util/request.py b/server/src/uds/core/util/request.py index 9abc7f29..443f593c 100644 --- a/server/src/uds/core/util/request.py +++ b/server/src/uds/core/util/request.py @@ -135,13 +135,13 @@ class GlobalRequestMiddleware: request.ip = request.META['REMOTE_ADDR'] except Exception: logger.exception('Request ip not found!!') - request.ip = '0.0.0.0' # No remote addr?? set this IP to a "basic" one, anyway, this should never ocur + request.ip = '' # No remote addr?? ... try: proxies = request.META['HTTP_X_FORWARDED_FOR'].split(",") request.ip_proxy = proxies[0] - if request.ip is None or behind_proxy is True: # Request.IP will be None in case of nginx & gunicorn + if not request.ip or behind_proxy is True: # Request.IP will be None in case of nginx & gunicorn request.ip = request.ip_proxy # Stores the ip # will raise "list out of range", leaving ip_proxy = proxy in case of no other proxy apart of nginx request.ip_proxy = proxies[1] diff --git a/server/src/uds/urls.py b/server/src/uds/urls.py index 829f7e9c..30fa407d 100644 --- a/server/src/uds/urls.py +++ b/server/src/uds/urls.py @@ -64,12 +64,12 @@ urlpatterns = [ # Login/logout path(r'uds/page/login/', uds.web.views.modern.login, name='page.login'), - re_path(r'^uds/page/login/(?P[a-zA-Z0-9-])$', uds.web.views.modern.login, name='page.login.tag'), + re_path(r'^uds/page/login/(?P[a-zA-Z0-9-]+)$', uds.web.views.modern.login, name='page.login.tag'), path(r'uds/page/logout/', uds.web.views.modern.logout, name='page.logout'), # Error URL (just a placeholder, calls index with data on url for angular) - re_path(r'^uds/page/error/(?P[a-zA-Z0-9=-]+)$', uds.web.views.error, name='page.error'), + re_path(r'^uds/page/error/(?P[a-zA-Z0-9=-]+)$', uds.web.views.error, name='page.error'), # Download plugins URL (just a placeholder, calls index with data on url for angular) path(r'uds/page/client-download', uds.web.views.modern.index, name='page.client-download'), diff --git a/server/src/uds/web/util/configjs.py b/server/src/uds/web/util/configjs.py index 51660a9d..dbf84854 100644 --- a/server/src/uds/web/util/configjs.py +++ b/server/src/uds/web/util/configjs.py @@ -72,6 +72,8 @@ def udsJs(request: 'HttpRequest') -> str: if csrf_token is not None: csrf_token = str(csrf_token) + tag = request.session.get('tag', None) + if GlobalConfig.DISALLOW_GLOBAL_LOGIN.getBool(False) is True: try: authenticators = [Authenticator.objects.get(small_name=auth_host)] @@ -83,6 +85,9 @@ def udsJs(request: 'HttpRequest') -> str: else: authenticators = Authenticator.objects.all().exclude(visible=False) + if tag: + authenticators = [x for x in authenticators if x.small_name == tag] + # the auths for client def getAuthInfo(auth: Authenticator): theType = auth.getType() diff --git a/server/src/uds/web/views/modern.py b/server/src/uds/web/views/modern.py index 9c4fdee4..ec655bf4 100644 --- a/server/src/uds/web/views/modern.py +++ b/server/src/uds/web/views/modern.py @@ -76,6 +76,7 @@ def login(request: HttpRequest, tag: typing.Optional[str] = None) -> HttpRespons request.session['errors'] = [data] return index(request) else: + request.session['tag'] = tag response = index(request) return response