mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
refactoring
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user