diff --git a/app_gateway/views.py b/app_gateway/views.py index 94e7e26..7c2fff4 100644 --- a/app_gateway/views.py +++ b/app_gateway/views.py @@ -41,6 +41,7 @@ def view_app_gateway_list(request): 'access_policies': access_policies, 'app_policies': app_policies, 'active_tab': tab, + 'caddy_enabled': settings.CADDY_ENABLED, } return render(request, 'app_gateway/app_gateway_list.html', context) @@ -460,17 +461,19 @@ def view_export_caddy_config(request): if not UserAcl.objects.filter(user=request.user).filter(user_level__gte=50).exists(): return render(request, 'access_denied.html', {'page_title': _('Access Denied')}) - if settings.CADDY_ENABLED: - export_caddy_config('/caddy_json_export/') - - if settings.DEBUG or not settings.CADDY_ENABLED: - export_caddy_config(os.path.join(settings.BASE_DIR, 'containers', 'caddy', 'config_files')) - redirect_url = reverse('app_gateway_list') + '?tab=applications' - if settings.CADDY_ENABLED: - messages.success(request, _('Configuration exported successfully.')) - else: - messages.error(request, _('Caddy is not active. Configuration files were exported for debugging purposes.')) + if not settings.CADDY_ENABLED: + messages.error(request, _( + 'Configuration export is not available because Caddy is not enabled. ' + 'To use App Gateway and Gatekeeper, start the application using docker-compose-caddy.yml.' + )) + return redirect(redirect_url) + export_caddy_config('/caddy_json_export/') + + if settings.DEBUG: + export_caddy_config(os.path.join(settings.BASE_DIR, 'containers', 'caddy', 'config_files')) + + messages.success(request, _('Configuration exported successfully.')) return redirect(redirect_url) diff --git a/gatekeeper/views.py b/gatekeeper/views.py index 0d6aaf3..83dd04f 100644 --- a/gatekeeper/views.py +++ b/gatekeeper/views.py @@ -2,6 +2,7 @@ import io import pyotp import qrcode +from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import login_required from django.http import HttpResponse @@ -40,6 +41,7 @@ def view_gatekeeper_list(request): 'auth_emails': auth_emails, 'auth_ips': auth_ips, 'active_tab': active_tab, + 'caddy_enabled': settings.CADDY_ENABLED, } return render(request, 'gatekeeper/gatekeeper_list.html', context) diff --git a/templates/app_gateway/app_gateway_list.html b/templates/app_gateway/app_gateway_list.html index 8f1d5ee..f6f14ba 100644 --- a/templates/app_gateway/app_gateway_list.html +++ b/templates/app_gateway/app_gateway_list.html @@ -2,6 +2,7 @@ {% load i18n %} {% block content %} +{% include 'app_gateway/caddy_disabled_alert.html' %}
@@ -36,12 +37,19 @@
{% if active_tab == 'applications' %}
+ {% if caddy_enabled %}
{% csrf_token %}
+ {% else %} + + {% endif %} {% trans 'Add Application' %} diff --git a/templates/app_gateway/caddy_disabled_alert.html b/templates/app_gateway/caddy_disabled_alert.html new file mode 100644 index 0000000..db66cf7 --- /dev/null +++ b/templates/app_gateway/caddy_disabled_alert.html @@ -0,0 +1,8 @@ +{% load i18n %} +{% if not caddy_enabled %} +
+ +
{% trans 'Caddy is not enabled' %}
+ {% trans 'The App Gateway and Gatekeeper modules require Caddy and the auth-gateway container to be running. Please start the application using docker-compose-caddy.yml.' %} +
+{% endif %} diff --git a/templates/gatekeeper/gatekeeper_list.html b/templates/gatekeeper/gatekeeper_list.html index cb833aa..8891990 100644 --- a/templates/gatekeeper/gatekeeper_list.html +++ b/templates/gatekeeper/gatekeeper_list.html @@ -2,6 +2,7 @@ {% load i18n %} {% block content %} +{% include 'app_gateway/caddy_disabled_alert.html' %}