[radius_auth.py] Appartements de l'ENS
Ignore-this: b874519e007921c54c55e2b354d2a2cc darcs-hash:20090302140219-bd074-e3ea8cc4f3b6080e4b7bddb0af18d95cb374ce9e.gz
This commit is contained in:
parent
a8446f5f27
commit
091981f029
1 changed files with 18 additions and 14 deletions
|
@ -11,11 +11,11 @@ from config import ann_scol, dat, vlans
|
||||||
|
|
||||||
def chap_ok(password, challenge, clear_pass) :
|
def chap_ok(password, challenge, clear_pass) :
|
||||||
""" Test l'authentification chap fournie
|
""" Test l'authentification chap fournie
|
||||||
password et chalenge doivent être données
|
password et chalenge doivent être données
|
||||||
en hexa (avec ou sans le 0x devant)
|
en hexa (avec ou sans le 0x devant)
|
||||||
|
|
||||||
retourne True si l'authentification est OK
|
retourne True si l'authentification est OK
|
||||||
retourne False sinon
|
retourne False sinon
|
||||||
"""
|
"""
|
||||||
try :
|
try :
|
||||||
challenge = binascii.a2b_hex(challenge.replace('0x',''))
|
challenge = binascii.a2b_hex(challenge.replace('0x',''))
|
||||||
|
@ -24,7 +24,7 @@ def chap_ok(password, challenge, clear_pass) :
|
||||||
return True
|
return True
|
||||||
except :
|
except :
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def do_auth(mac):
|
def do_auth(mac):
|
||||||
|
@ -34,7 +34,7 @@ def do_auth(mac):
|
||||||
prise."""
|
prise."""
|
||||||
|
|
||||||
global ann_scol
|
global ann_scol
|
||||||
|
|
||||||
if not chap_ok(os.getenv('CHAP_PASSWORD'), os.getenv('CHAP_CHALLENGE'), mac):
|
if not chap_ok(os.getenv('CHAP_PASSWORD'), os.getenv('CHAP_CHALLENGE'), mac):
|
||||||
return (-1, "Échec test CHAP", "")
|
return (-1, "Échec test CHAP", "")
|
||||||
|
|
||||||
|
@ -45,32 +45,36 @@ def do_auth(mac):
|
||||||
elif len(m) > 1:
|
elif len(m) > 1:
|
||||||
return (-1, "Pb recherche mac (nb résultat %d!=1)" % len(m), "")
|
return (-1, "Pb recherche mac (nb résultat %d!=1)" % len(m), "")
|
||||||
|
|
||||||
# N'appartient pas au Crans et n'a pas de prise attribuée
|
# N'appartient pas au Crans et n'a pas de prise attribuée
|
||||||
# donc sur uplink ou switch non filtré
|
# donc sur uplink ou switch non filtré
|
||||||
# But : éviter le spoof d'une mac d'une machine clef
|
# But : éviter le spoof d'une mac d'une machine clef
|
||||||
proprio = m[0].proprietaire()
|
proprio = m[0].proprietaire()
|
||||||
if proprio.__class__ == AssociationCrans and m[0].prise() == u'N/A':
|
if proprio.__class__ == AssociationCrans and m[0].prise() == u'N/A':
|
||||||
return (-1, "Machine du crans", "")
|
return (-1, "Machine du crans", "")
|
||||||
|
|
||||||
# blockliste bloq
|
# blockliste bloq
|
||||||
if 'bloq' in m[0].blacklist_actif():
|
if 'bloq' in m[0].blacklist_actif():
|
||||||
return (-1, "Bloquage total des services pour cette machine", "")
|
return (-1, "Bloquage total des services pour cette machine", "")
|
||||||
|
|
||||||
# L'adherent ne paie pas, on le met sur le vlan radin
|
# L'adherent ne paie pas, on le met sur le vlan radin
|
||||||
if not isinstance(proprio, Club) and not proprio.adherentPayant():
|
if not isinstance(proprio, Club) and not proprio.adherentPayant():
|
||||||
return (0, "Ne paie pas", "radin")
|
return (0, "Ne paie pas", "gratuit")
|
||||||
|
|
||||||
# Paiment ok ?
|
# Paiment ok ?
|
||||||
paid = max(proprio.paiement() + [0])
|
paid = max(proprio.paiement() + [0])
|
||||||
if dat[1] in (8, 9):
|
if dat[1] in (8, 9):
|
||||||
# En septembre les anciennes adhésions sont OK
|
# En septembre les anciennes adhésions sont OK
|
||||||
ann_scol -= 1
|
ann_scol -= 1
|
||||||
elif dat[1] == 10 and dat[2] in (1,2,3):
|
elif dat[1] == 10 and dat[2] in (1,2,3):
|
||||||
# On laisse 3 jours ou les gens ont une page sur squid
|
# On laisse 3 jours ou les gens ont une page sur squid
|
||||||
ann_scol -= 1
|
ann_scol -= 1
|
||||||
if ann_scol > paid:
|
if ann_scol > paid:
|
||||||
return (0, "N'a pas payé", "accueil")
|
return (0, "N'a pas payé", "accueil")
|
||||||
|
|
||||||
|
# Cas des personnels logés dans les appartements de l'ENS
|
||||||
|
if proprio.etudes(0) == 'Personnel ENS':
|
||||||
|
return (0, "Personnel ENS", "appts")
|
||||||
|
|
||||||
# C'est bon
|
# C'est bon
|
||||||
return (0, "Accès adhérent OK", "adherent")
|
return (0, "Accès adhérent OK", "adherent")
|
||||||
|
|
||||||
|
@ -80,7 +84,7 @@ if __name__ == '__main__' :
|
||||||
|
|
||||||
# On vérifie si la mac est autorisée
|
# On vérifie si la mac est autorisée
|
||||||
(r, msg, vlan) = do_auth(mac)
|
(r, msg, vlan) = do_auth(mac)
|
||||||
|
|
||||||
# On logue la prise sur laquelle a lieu la tentative
|
# On logue la prise sur laquelle a lieu la tentative
|
||||||
openlog("radius_auth.py")
|
openlog("radius_auth.py")
|
||||||
switch = os.getenv("NAS_IDENTIFIER", "").replace('"', '')
|
switch = os.getenv("NAS_IDENTIFIER", "").replace('"', '')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue