mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 09:01:54 +08:00
single-shot auth using headers
This commit is contained in:
@@ -28,7 +28,7 @@ from .. import get_plugin_class
|
||||
|
||||
# =====
|
||||
class BaseAuthService(BasePlugin):
|
||||
async def login(self, user: str, passwd: str) -> bool:
|
||||
async def authorize(self, user: str, passwd: str) -> bool:
|
||||
raise NotImplementedError # pragma: nocover
|
||||
|
||||
async def cleanup(self) -> None:
|
||||
|
||||
@@ -44,6 +44,6 @@ class Plugin(BaseAuthService):
|
||||
"file": Option("/etc/kvmd/htpasswd", type=valid_abs_path_exists, unpack_as="path"),
|
||||
}
|
||||
|
||||
async def login(self, user: str, passwd: str) -> bool:
|
||||
async def authorize(self, user: str, passwd: str) -> bool:
|
||||
htpasswd = passlib.apache.HtpasswdFile(self.__path)
|
||||
return htpasswd.check_password(user, passwd)
|
||||
|
||||
@@ -69,7 +69,7 @@ class Plugin(BaseAuthService):
|
||||
"timeout": Option(5.0, type=valid_float_f01),
|
||||
}
|
||||
|
||||
async def login(self, user: str, passwd: str) -> bool:
|
||||
async def authorize(self, user: str, passwd: str) -> bool:
|
||||
session = self.__ensure_session()
|
||||
try:
|
||||
async with session.request(
|
||||
|
||||
Reference in New Issue
Block a user