fix: Fix mutal exclusive authentication based on secrets.

Fixes: #142
This commit is contained in:
gyptazy
2025-03-31 06:42:12 +02:00
parent b55b4ea7a0
commit 6da54c1255
2 changed files with 6 additions and 5 deletions

View File

@@ -44,10 +44,11 @@ pveum acl modify / --roles proxlb --users proxlb@pve
pveum user token add proxlb@pve proxlb
```
Afterwards, you get the token secret returned. You can now add those entries to your ProxLB config.
Afterwards, you get the token secret returned. You can now add those entries to your ProxLB config. Make sure, that you also keep the `user` parameter, next to the new API parameters. The fiel `pass` then needs to be **absent**.
| Proxmox API | ProxLB Config | Example |
|---|---|---|
| Username | [user](https://github.com/gyptazy/ProxLB/blob/main/config/proxlb_example.yaml#L4) | proxlb@pve |
| Token ID | [token_id](https://github.com/gyptazy/ProxLB/blob/main/config/proxlb_example.yaml#L6) | proxlb |
| Secret | [token_secret](https://github.com/gyptazy/ProxLB/blob/main/config/proxlb_example.yaml#L7) | 430e308f-1337-1337-beef-1337beefcafe |

View File

@@ -115,7 +115,7 @@ class ProxmoxApi:
"token_id" and "token_secret" keys for API token authentication.
Raises:
SystemExit: If both username/password and API token authentication methods are
SystemExit: If both pass/token_secret and API token authentication methods are
provided, the function will log a critical error message and terminate
the program.
@@ -130,10 +130,10 @@ class ProxmoxApi:
sys.exit(1)
proxlb_credentials = proxlb_config["proxmox_api"]
present_auth_user = "user" in proxlb_credentials
present_auth_token = "token_id" in proxlb_credentials
present_auth_pass = "pass" in proxlb_credentials
present_auth_secret = "token_secret" in proxlb_credentials
if present_auth_user and present_auth_token:
if present_auth_pass and present_auth_secret:
logger.critical(f"Username/password and API token authentication are mutal exclusive. Please use only one!")
print(f"Username/password and API token authentication are mutal exclusive. Please use only one!")
sys.exit(1)