From df6de3ef2f03ef155c65a719c908ed14fb2f3078 Mon Sep 17 00:00:00 2001 From: chapeau Date: Sat, 28 Nov 2020 16:24:36 +0100 Subject: [PATCH] =?UTF-8?q?premi=C3=A8re=20passe=20de=20debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freeradius_utils/auth.py | 14 +++++++------- radius/api/serializers.py | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/freeradius_utils/auth.py b/freeradius_utils/auth.py index 2ef25e70..9b7d27e8 100644 --- a/freeradius_utils/auth.py +++ b/freeradius_utils/auth.py @@ -193,14 +193,14 @@ def post_auth(data): sw_name = switch["name"] or "?" room = "Unknown port" if port: - room = port.room or "Unknown room" + room = port["room"] or "Unknown room" out = decide_vlan_switch(data_from_api, mac, nas_port) reason, vlan_id, decision, attributes = out if decision: log_message = "(wired) %s -> %s [%s%s]" % ( - sw_name + ":" + port + "/" + str(room), + sw_name + ":" + nas_port + "/" + str(room), mac, vlan_id, (reason and ": " + reason), @@ -219,8 +219,8 @@ def post_auth(data): (), ) else: - log_message = "(fil) %s -> %s [Reject %s]" % ( - sw_name + ":" + port + "/" + str(room), + log_message = "(wired) %s -> %s [Reject %s]" % ( + sw_name + ":" + nas_port + "/" + str(room), mac, (reason and ": " + reason), ) @@ -270,7 +270,7 @@ def check_user_machine_and_register(nas_type, user, user_interface): def set_radius_attributes_values(attributes, values): return ( - (str(attribute.attribute), str(attribute.value % values)) + (str(attribute["attribute"]), str(attribute["value"] % values)) for attribute in attributes ) @@ -323,7 +323,7 @@ def decide_vlan_switch(data_from_api, user_mac, nas_port): attributes_kwargs = { "client_mac": str(user_mac), "switch_port": str(nas_port.split(".")[0].split("/")[-1][-2:]), - "switch_ip": str(switch.ipv4) + "switch_ip": str(switch["ipv4"]) } # Get port from switch and port number @@ -424,7 +424,7 @@ def decide_vlan_switch(data_from_api, user_mac, nas_port): # else: user OK, so we check MAC now # If we are authenticating with mac, we look for the interfaces and its mac address - if port_profile.radius_mode == "COMMON" or port_profile.radius_mode == "STRICT": + if port_profile["radius_mode"] == "COMMON" or port_profile["radius_mode"] == "STRICT": # If mac is unknown, if not user_interface: # We try to register mac, if autocapture is enabled diff --git a/radius/api/serializers.py b/radius/api/serializers.py index 1ad2e2eb..33b4127a 100644 --- a/radius/api/serializers.py +++ b/radius/api/serializers.py @@ -70,6 +70,7 @@ class VlanSerializer(Serializer): class PortProfileSerializer(Serializer): vlan_untagged = VlanSerializer() radius_type = serializers.CharField() + radius_mode = serializers.CharField() class SwitchSerializer(Serializer):