modular auth

This commit is contained in:
Devaev Maxim
2019-04-01 10:30:30 +03:00
parent 70e526b773
commit 73e04b71ed
4 changed files with 48 additions and 13 deletions

View File

@@ -129,6 +129,15 @@ def _as_string_list(values: Union[str, Sequence]) -> List[str]:
return list(map(str, values))
def _as_auth_type(auth_type: str) -> str:
if not isinstance(auth_type, str):
raise ValueError("Invalid auth type")
auth_type = str(auth_type).strip()
if auth_type not in ["basic"]:
raise ValueError("Invalid auth type")
return auth_type
def _get_config_scheme() -> Dict:
return {
"kvmd": {
@@ -144,7 +153,10 @@ def _get_config_scheme() -> Dict:
},
"auth": {
"htpasswd": Option("/etc/kvmd/htpasswd", type=_as_path, rename="htpasswd_path"),
"type": Option("basic", type=_as_auth_type, rename="auth_type"),
"basic": {
"htpasswd": Option("/etc/kvmd/htpasswd", type=_as_path, rename="htpasswd_path"),
},
},
"info": {