Implement button to enable authentication for relay
This commit is contained in:
parent
d3dd070db0
commit
985705dfa4
|
@ -39,6 +39,7 @@ from core.views.manage.threshold.irc import (
|
||||||
ThresholdIRCNetworkDel,
|
ThresholdIRCNetworkDel,
|
||||||
ThresholdIRCNetworkInfo,
|
ThresholdIRCNetworkInfo,
|
||||||
ThresholdIRCNetworkInfoEdit,
|
ThresholdIRCNetworkInfoEdit,
|
||||||
|
ThresholdIRCNetworkRelayAuth,
|
||||||
ThresholdIRCNetworkRelayDel,
|
ThresholdIRCNetworkRelayDel,
|
||||||
ThresholdIRCNetworkRelayProvision,
|
ThresholdIRCNetworkRelayProvision,
|
||||||
ThresholdIRCNetworkRelays,
|
ThresholdIRCNetworkRelays,
|
||||||
|
@ -143,6 +144,11 @@ urlpatterns = [
|
||||||
ThresholdIRCNetworkRelayProvision.as_view(),
|
ThresholdIRCNetworkRelayProvision.as_view(),
|
||||||
name="threshold_irc_network_relay_provision",
|
name="threshold_irc_network_relay_provision",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"manage/threshold/irc/network/<str:net>/<int:num>/auth/",
|
||||||
|
ThresholdIRCNetworkRelayAuth.as_view(),
|
||||||
|
name="threshold_irc_network_relay_auth",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"manage/threshold/irc/actions/registration/",
|
"manage/threshold/irc/actions/registration/",
|
||||||
ThresholdIRCActionsRegistration.as_view(),
|
ThresholdIRCActionsRegistration.as_view(),
|
||||||
|
|
|
@ -241,3 +241,10 @@ def irc_provision_relay(net, num):
|
||||||
payload = {}
|
payload = {}
|
||||||
provisioned = threshold_request(url, payload, method="POST")
|
provisioned = threshold_request(url, payload, method="POST")
|
||||||
return provisioned
|
return provisioned
|
||||||
|
|
||||||
|
|
||||||
|
def irc_enable_auth(net, num):
|
||||||
|
url = f"irc/network/{net}/{num}/auth"
|
||||||
|
payload = {}
|
||||||
|
enabled = threshold_request(url, payload, method="POST")
|
||||||
|
return enabled
|
||||||
|
|
|
@ -123,6 +123,18 @@
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="nowrap-child">
|
||||||
|
<button
|
||||||
|
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||||
|
hx-post="{% url 'threshold_irc_network_relay_auth' relay|index:'net' relay|index:'id' %}"
|
||||||
|
hx-target="#relays"
|
||||||
|
hx-swap="outerHTML"
|
||||||
|
class="button is-info">
|
||||||
|
<span class="icon" data-tooltip="Enable authentication">
|
||||||
|
<i class="fa-solid fa-passport" aria-hidden="true"></i>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -158,6 +158,31 @@ class ThresholdIRCNetworkRelayProvision(SuperUserRequiredMixin, APIView):
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
|
||||||
|
class ThresholdIRCNetworkRelayAuth(SuperUserRequiredMixin, APIView):
|
||||||
|
template_name = "manage/threshold/irc/network/relays.html"
|
||||||
|
|
||||||
|
def post(self, request, net, num):
|
||||||
|
"""
|
||||||
|
Provision a relay
|
||||||
|
"""
|
||||||
|
provisioned = threshold.irc_enable_auth(net, num)
|
||||||
|
if provisioned["success"]:
|
||||||
|
|
||||||
|
message = f"Enabled authentication on relay {num}"
|
||||||
|
message_class = "success"
|
||||||
|
else:
|
||||||
|
message = provisioned["reason"]
|
||||||
|
message_class = "danger"
|
||||||
|
relays = threshold.get_irc_relays(net)
|
||||||
|
context = {
|
||||||
|
"net": net,
|
||||||
|
"message": message,
|
||||||
|
"class": message_class,
|
||||||
|
"relays": relays["relays"],
|
||||||
|
}
|
||||||
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
|
||||||
class ThresholdIRCNetworkRelayStatus(SuperUserRequiredMixin, APIView):
|
class ThresholdIRCNetworkRelayStatus(SuperUserRequiredMixin, APIView):
|
||||||
template_name = "manage/threshold/irc/network/relays.html"
|
template_name = "manage/threshold/irc/network/relays.html"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue