From 028a2cd28d9372a8de6938b259dc5702e0d2dbcc Mon Sep 17 00:00:00 2001 From: chapeau Date: Sat, 23 Mar 2024 09:12:10 +0100 Subject: [PATCH] Fix radius proxy bug --- freeradius_utils/auth.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/freeradius_utils/auth.py b/freeradius_utils/auth.py index e53127fa..15a8d902 100644 --- a/freeradius_utils/auth.py +++ b/freeradius_utils/auth.py @@ -163,10 +163,22 @@ def post_auth(data): nas_instance = find_nas_from_request(nas) # All non proxified requests if not nas_instance: + user = data.get("User-Name", "") + user = user.split("@", 1)[0] + user = User.objects.filter(pseudo__iexact=username).first() + if not user or not user.has_access(): + logger.info("Proxified request, user has no internet access: %s" % (username)) + return radiusd.RLM_MODULE_REJECT logger.info("Proxified request, nas unknown") return radiusd.RLM_MODULE_OK nas_type = Nas.objects.filter(nas_type=nas_instance.machine_type).first() if not nas_type: + user = data.get("User-Name", "") + user = user.split("@", 1)[0] + user = User.objects.filter(pseudo__iexact=username).first() + if not user or not user.has_access(): + logger.info("Proxified request, user has no internet access: %s" % (username)) + return radiusd.RLM_MODULE_REJECT logger.info("This kind of nas is not registered in the database!") return radiusd.RLM_MODULE_OK