diff --git a/gatekeeper/forms.py b/gatekeeper/forms.py index d80c950..2c809ed 100644 --- a/gatekeeper/forms.py +++ b/gatekeeper/forms.py @@ -1,4 +1,5 @@ import pyotp +from crispy_forms.bootstrap import PrependedText from crispy_forms.helper import FormHelper from crispy_forms.layout import Layout, Submit, HTML, Div, Field from django import forms @@ -210,7 +211,7 @@ class GatekeeperIPAddressForm(forms.ModelForm): ), Div( Div('address', css_class='col-xl-6'), - Div('prefix_length', css_class='col-xl-6'), + Div(PrependedText('prefix_length', '/'), css_class='col-xl-6'), css_class='row' ), Div( @@ -245,7 +246,7 @@ class AuthMethodAllowedDomainForm(forms.ModelForm): self.helper.layout = Layout( Div( Div('auth_method', css_class='col-md-6'), - Div('domain', css_class='col-md-6'), + Div(PrependedText('domain', '@'), css_class='col-xl-6'), css_class='row' ), Div( diff --git a/gatekeeper/views.py b/gatekeeper/views.py index f0e7852..4313fbf 100644 --- a/gatekeeper/views.py +++ b/gatekeeper/views.py @@ -21,16 +21,15 @@ def view_gatekeeper_list(request): """Main list view containing tabs for Users, Groups, and Auth Methods""" if not UserAcl.objects.filter(user=request.user).filter(user_level__gte=20).exists(): return render(request, 'access_denied.html', {'page_title': _('Access Denied')}) - + + active_tab = request.GET.get('tab', 'auth_methods') + auth_methods = AuthMethod.objects.all().order_by('name') users = GatekeeperUser.objects.all().order_by('username') groups = GatekeeperGroup.objects.all().order_by('name') - auth_methods = AuthMethod.objects.all().order_by('name') auth_domains = AuthMethodAllowedDomain.objects.all().order_by('domain') auth_emails = AuthMethodAllowedEmail.objects.all().order_by('email') auth_ips = GatekeeperIPAddress.objects.all().order_by('address') - tab = request.GET.get('tab', 'users') - context = { 'users': users, 'groups': groups, @@ -38,7 +37,7 @@ def view_gatekeeper_list(request): 'auth_domains': auth_domains, 'auth_emails': auth_emails, 'auth_ips': auth_ips, - 'active_tab': tab, + 'active_tab': active_tab, } return render(request, 'gatekeeper/gatekeeper_list.html', context) @@ -380,10 +379,29 @@ def view_manage_gatekeeper_ip(request): messages.success(request, _('IP Address saved successfully.')) return redirect(cancel_url) + form_description = { + 'size': 'col-lg-6', + 'content': _(''' +
Manage specific IP addresses or networks that are allowed or denied access when using the IP Address List authentication method.
+ +Enter a single IP address (e.g., 192.168.1.50) or a network address. Use the prefix length for CIDR notation (e.g., 24 for a /24 network). Leave prefix blank for a single host (/32 for IPv4, /128 for IPv6).
+ +Allow: Grants access to the specified IP/network.
+ Deny: Specifically blocks access from the specified IP/network.
An optional note to help identify this entry (e.g., "Office Network", "Blocked Attacker").
+ ''') + } + context = { 'form': form, 'title': title, 'page_title': title, + 'form_description': form_description, } return render(request, 'generic_form.html', context) diff --git a/templates/gatekeeper/gatekeeper_list.html b/templates/gatekeeper/gatekeeper_list.html index 47de553..2b79423 100644 --- a/templates/gatekeeper/gatekeeper_list.html +++ b/templates/gatekeeper/gatekeeper_list.html @@ -6,18 +6,18 @@