mirror of
https://github.com/home-assistant/core.git
synced 2026-04-17 23:53:49 +01:00
Co-authored-by: Norbert Rittel <norbert@rittel.de> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
25 lines
670 B
Python
25 lines
670 B
Python
"""Common methods for Proxmox VE integration."""
|
|
|
|
from collections.abc import Mapping
|
|
from typing import Any
|
|
|
|
from homeassistant.const import CONF_USERNAME
|
|
|
|
from .const import AUTH_OTHER, CONF_AUTH_METHOD, CONF_REALM
|
|
|
|
|
|
def sanitize_config_entry(input_data: Mapping[str, Any]) -> dict[str, Any]:
|
|
"""Sanitize the user ID and realm in config_entry data."""
|
|
data = dict(input_data)
|
|
username = data[CONF_USERNAME].split("@")[0]
|
|
provider = data[CONF_AUTH_METHOD]
|
|
|
|
realm = provider.lower()
|
|
if provider == AUTH_OTHER:
|
|
realm = data[CONF_REALM].lower()
|
|
|
|
data[CONF_REALM] = realm
|
|
data[CONF_USERNAME] = f"{username}@{realm}"
|
|
|
|
return data
|