mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-03-21 16:06:18 +00:00
add alert for disabled Caddy in App Gateway and Gatekeeper modules
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
{% include 'app_gateway/caddy_disabled_alert.html' %}
|
||||
<div class="card card-primary card-outline">
|
||||
<div class="card-body">
|
||||
|
||||
@@ -36,12 +37,19 @@
|
||||
</div>
|
||||
{% if active_tab == 'applications' %}
|
||||
<div>
|
||||
{% if caddy_enabled %}
|
||||
<form method="post" action="{% url 'export_caddy_config' %}" class="d-inline">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-outline-secondary">
|
||||
<i class="fas fa-file-export"></i> {% trans 'Export Configuration' %}
|
||||
</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<button type="button" class="btn btn-outline-secondary" disabled
|
||||
title="{% trans 'Export is not available because Caddy is not enabled.' %}">
|
||||
<i class="fas fa-file-export"></i> {% trans 'Export Configuration' %}
|
||||
</button>
|
||||
{% endif %}
|
||||
<a href="{% url 'manage_application' %}" class="btn btn-outline-primary">
|
||||
<i class="fas fa-plus"></i> {% trans 'Add Application' %}
|
||||
</a>
|
||||
|
||||
8
templates/app_gateway/caddy_disabled_alert.html
Normal file
8
templates/app_gateway/caddy_disabled_alert.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{% load i18n %}
|
||||
{% if not caddy_enabled %}
|
||||
<div class="alert alert-warning alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h5><i class="icon fas fa-exclamation-triangle"></i> {% trans 'Caddy is not enabled' %}</h5>
|
||||
{% trans 'The App Gateway and Gatekeeper modules require Caddy and the auth-gateway container to be running. Please start the application using <code>docker-compose-caddy.yml</code>.' %}
|
||||
</div>
|
||||
{% endif %}
|
||||
@@ -2,6 +2,7 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
{% include 'app_gateway/caddy_disabled_alert.html' %}
|
||||
<div class="card card-primary card-outline">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user