freeradius/auth.py: fix auth filaire
This commit is contained in:
parent
4984b11021
commit
4d3581f2a8
1 changed files with 23 additions and 18 deletions
|
@ -109,10 +109,6 @@ def get_machines(data, conn):
|
|||
if username is None:
|
||||
radiusd.radlog(radiusd.L_ERR, 'Cannot read client User-Name !')
|
||||
|
||||
# Sanitize all the things
|
||||
mac = escape_ldap(mac)
|
||||
username = escape_ldap(username)
|
||||
|
||||
# Liste de filtres ldap à essayer
|
||||
search_strats = [
|
||||
# Case 1: Search by mac (reported by AP)
|
||||
|
@ -135,7 +131,7 @@ def get_prise_chbre(data):
|
|||
majuscule, tandis que la prise correspondante commence par une miniscule.
|
||||
"""
|
||||
## Filaire: NAS-Identifier => contient le nom du switch (batm-3.adm.crans.org)
|
||||
## Nas-Port => port du switch (ex 42)
|
||||
## NAS-Port => port du switch (ex 42)
|
||||
|
||||
# Lettre du bâtiment (C, B, A, etc, en majuscule)
|
||||
bat_name = None
|
||||
|
@ -146,18 +142,18 @@ def get_prise_chbre(data):
|
|||
# Port sur le switch
|
||||
port = None
|
||||
|
||||
nas = data.get('Nas-Identifier', None)
|
||||
nas = data.get('NAS-Identifier', None)
|
||||
if nas:
|
||||
if nas.startswith('bat'):
|
||||
nas = value.split('.', 1)[0]
|
||||
nas = nas.split('.', 1)[0]
|
||||
try:
|
||||
bat_name = nas[3].upper()
|
||||
bat_num = int(nas.split('-', 1)[1])
|
||||
except IndexError, ValueError:
|
||||
pass
|
||||
port = data.get('Nas-Port', None)
|
||||
port = data.get('NAS-Port', None)
|
||||
if port:
|
||||
port = int(value)
|
||||
port = int(port)
|
||||
|
||||
if bat_num is not None and bat_name and port:
|
||||
prise = bat_name.lower() + "%01d%02d" % (bat_num, port)
|
||||
|
@ -166,6 +162,7 @@ def get_prise_chbre(data):
|
|||
except IndexError:
|
||||
chbre = None
|
||||
return prise, chbre
|
||||
return None
|
||||
|
||||
@use_ldap_admin
|
||||
def register_mac(data, machine, conn):
|
||||
|
@ -252,7 +249,12 @@ def authorize_fil(data):
|
|||
TODO: check bl_reject.
|
||||
TODO: check chap auth
|
||||
"""
|
||||
return radiusd.RLM_MODULE_OK
|
||||
return (radiusd.RLM_MODULE_UPDATED,
|
||||
(),
|
||||
(
|
||||
("Auth-Type", "crans_fil"),
|
||||
),
|
||||
)
|
||||
|
||||
@radius_event
|
||||
def post_auth_wifi(data):
|
||||
|
@ -296,7 +298,7 @@ def post_auth_fil(data):
|
|||
(
|
||||
("Tunnel-Type", "VLAN"),
|
||||
("Tunnel-Medium-Type", "IEEE-802"),
|
||||
("Tunnel-Private-Group-Id", '%d' % vlan),
|
||||
("Tunnel-Private-Group-Id", '%d' % vlan_id),
|
||||
),
|
||||
()
|
||||
)
|
||||
|
@ -345,21 +347,24 @@ def decide_vlan(data, is_wifi, conn):
|
|||
# Si l'adhérent n'est pas membre actif, il doit se brancher depuis la
|
||||
# prise d'un autre adhérent à jour de cotisation
|
||||
force_ma = False
|
||||
if chbre is None and not proprio['droits']:
|
||||
is_ma = proprio.has_key('droits')
|
||||
if chbre is None and is_ma:
|
||||
decision = "accueil", u"Chambre inconnue"
|
||||
elif chbre is not None:
|
||||
chbre = escape_ldap(chbre)
|
||||
hebergeurs = conn.search(u'(&(chambre=%s)(cid=*)(aid=*))' % chbre)
|
||||
hebergeurs = conn.search(u'(&(chbre=%s)(|(cid=*)(aid=*)))' % chbre)
|
||||
for hebergeur in hebergeurs:
|
||||
if not hebergeur.blacklist_actif():
|
||||
# Si on est hébergé par un adhérent ok, ou que c'est notre
|
||||
# chambre, pas de problème
|
||||
if hebergeur.dn == proprio.dn or not hebergeur.blacklist_actif():
|
||||
break
|
||||
else:
|
||||
# Si tous les hebergeurs sont blacklistés, autorisé
|
||||
# Si tous les hebergeurs sont blacklistés, autoriser
|
||||
# uniquement si MA
|
||||
if not proprio['droits']:
|
||||
decision = "accueil", "Hébergeur blacklisté"
|
||||
else:
|
||||
if is_ma:
|
||||
force_ma = True
|
||||
else:
|
||||
decision = "accueil", u"Hébergeur blacklisté"
|
||||
else:
|
||||
force_ma = True
|
||||
if force_ma:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue