Merge pull request #293 from gyptazy/feature/290-validate-token-input-from-config-file

feature: Add validation for provided API user token id to avoid confusions
This commit is contained in:
gyptazy
2025-08-25 08:11:56 +02:00
committed by GitHub
2 changed files with 10 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
added:
- Add validation for provided API user token id to avoid confusions (@gyptazy). [#291]

View File

@@ -135,6 +135,14 @@ class ProxmoxApi:
proxlb_credentials = proxlb_config["proxmox_api"]
present_auth_pass = "pass" in proxlb_credentials
present_auth_secret = "token_secret" in proxlb_credentials
token_id = proxlb_credentials.get("token_id", None)
if token_id:
non_allowed_chars = ["@", "!"]
for char in non_allowed_chars:
if char in token_id:
logger.error(f"Wrong user/token format defined. User and token id must be splitted! Please see: https://github.com/gyptazy/ProxLB/blob/main/docs/03_configuration.md#required-permissions-for-a-user")
sys.exit(1)
if present_auth_pass and present_auth_secret:
logger.critical(f"Username/password and API token authentication are mutal exclusive. Please use only one!")