diff options
author | Devaev Maxim <[email protected]> | 2019-04-16 00:08:55 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-04-16 00:08:55 +0300 |
commit | b1e2d5967a938c62fe47b784565b5bdc5ed55cb2 (patch) | |
tree | 21c52a43f9fe439939ad8b7e7b2ef5a2ff76b8fc /kvmd | |
parent | bc0deaee5f487ec2bb752a9dbe78ffe51d2559e5 (diff) |
test for auth manager
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/apps/__init__.py | 4 | ||||
-rw-r--r-- | kvmd/apps/kvmd/__init__.py | 4 | ||||
-rw-r--r-- | kvmd/apps/kvmd/auth.py | 10 |
3 files changed, 10 insertions, 8 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index 745a20e9..eea8ea71 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -153,11 +153,11 @@ def _get_config_scheme() -> Dict: }, "auth": { - "internal_users": Option([], type=valid_users_list), "internal_type": Option("htpasswd"), - "external_type": Option(""), # "internal": {}, + "external_type": Option(""), # "external": {}, + "internal_users": Option([], type=valid_users_list), }, "info": { diff --git a/kvmd/apps/kvmd/__init__.py b/kvmd/apps/kvmd/__init__.py index 7f5c320e..36ac871d 100644 --- a/kvmd/apps/kvmd/__init__.py +++ b/kvmd/apps/kvmd/__init__.py @@ -46,11 +46,11 @@ def main(argv: Optional[List[str]]=None) -> None: # pylint: disable=protected-access Server( auth_manager=AuthManager( - internal_users=config.auth.internal_users, internal_type=config.auth.internal_type, - external_type=config.auth.external_type, internal=config.auth.internal._unpack(), + external_type=config.auth.external_type, external=(config.auth.external._unpack() if config.auth.external_type else {}), + internal_users=config.auth.internal_users, ), info_manager=InfoManager(**config.info._unpack()), log_reader=LogReader(), diff --git a/kvmd/apps/kvmd/auth.py b/kvmd/apps/kvmd/auth.py index c90f10b5..22724421 100644 --- a/kvmd/apps/kvmd/auth.py +++ b/kvmd/apps/kvmd/auth.py @@ -36,16 +36,16 @@ from ...plugins.auth import get_auth_service_class class AuthManager: def __init__( self, - internal_users: List[str], internal_type: str, - external_type: str, - internal: Dict, + + external_type: str, external: Dict, + + internal_users: List[str], ) -> None: - self.__internal_users = internal_users self.__internal_service = get_auth_service_class(internal_type)(**internal) get_logger().info("Using internal login service %r", self.__internal_service.PLUGIN_NAME) @@ -54,6 +54,8 @@ class AuthManager: self.__external_service = get_auth_service_class(external_type)(**external) get_logger().info("Using external login service %r", self.__external_service.PLUGIN_NAME) + self.__internal_users = internal_users + self.__tokens: Dict[str, str] = {} # {token: user} async def login(self, user: str, passwd: str) -> Optional[str]: |