Commit de61a52a authored by Gabriel Detraz's avatar Gabriel Detraz

Legacy pour gestion des anciens mdp

parent 7add2507
......@@ -39,6 +39,7 @@ import os
import sys
import logging
import radiusd # Module magique freeradius ( is dummy)
import json
from django.core.wsgi import get_wsgi_application
from django.db.models import Q
......@@ -68,6 +69,7 @@ RADIUS_POLICY = options.radius_general_policy
#: Serveur radius de test (pas la prod)
TEST_SERVER = bool(os.getenv('DBG_FREERADIUS', False))
LEGACY_WIFI_PASSWORDS = json.load(open('/etc/freeradius/3.0/wifi_passwords', 'r'))
# Logging
class RadiusdHandler(logging.Handler):
......@@ -156,6 +158,34 @@ def authorize(data):
user = data.get('User-Name', '').decode('utf-8', errors='replace')
user = user.split('@', 1)[0]
mac = data.get('Calling-Station-Id', '')
#### Legacy, anciens login/mdp des machines
if user in LEGACY_WIFI_PASSWORDS:"Legacy auth for login %s" % user.encode('utf-8'))
interface = Interface.objects.filter(domain__name=user, mac_address=mac).first()
if not interface:"Rejet, Interface introuvable, mac et user login differents")
return radiusd.RLM_MODULE_REJECT
if not interface.is_active:"Rejet, interface desactivee")
return radiusd.RLM_MODULE_REJECT
user_object = interface.machine.user
if not user_object.has_access():"Adherent non connecte/cotisant")
return radiusd.RLM_MODULE_REJECT
return (
(str("Cleartext-Password"), str(LEGACY_WIFI_PASSWORDS[user])),
result, log, password = check_user_machine_and_register(
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment