refactoring

This commit is contained in:
Maxim Devaev
2024-09-18 04:37:43 +03:00
parent 45270a09d7
commit 7a53f14456
83 changed files with 517 additions and 516 deletions

View File

@@ -85,8 +85,8 @@ class Plugin(BaseAuthService):
"User-Agent": htclient.make_user_agent("KVMD"),
"X-KVMD-User": user,
},
) as response:
htclient.raise_not_200(response)
) as resp:
htclient.raise_not_200(resp)
return True
except Exception:
get_logger().exception("Failed HTTP auth request for user %r", user)

View File

@@ -100,10 +100,10 @@ class Plugin(BaseAuthService):
return True
except ldap.INVALID_CREDENTIALS:
pass
except ldap.SERVER_DOWN as err:
get_logger().error("LDAP server is down: %s", tools.efmt(err))
except Exception as err:
get_logger().error("Unexpected LDAP error: %s", tools.efmt(err))
except ldap.SERVER_DOWN as ex:
get_logger().error("LDAP server is down: %s", tools.efmt(ex))
except Exception as ex:
get_logger().error("Unexpected LDAP error: %s", tools.efmt(ex))
finally:
if conn is not None:
try:

View File

@@ -435,10 +435,10 @@ class Plugin(BaseAuthService):
timeout=self.__timeout,
dict=dct,
)
request = client.CreateAuthPacket(code=pyrad.packet.AccessRequest, User_Name=user)
request["User-Password"] = request.PwCrypt(passwd)
response = client.SendPacket(request)
return (response.code == pyrad.packet.AccessAccept)
req = client.CreateAuthPacket(code=pyrad.packet.AccessRequest, User_Name=user)
req["User-Password"] = req.PwCrypt(passwd)
resp = client.SendPacket(req)
return (resp.code == pyrad.packet.AccessAccept)
except Exception:
get_logger().exception("Failed RADIUS auth request for user %r", user)
return False