Skip to content
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions CODEOWNERS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions homeassistant/auth/mfa_modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import types
from typing import Any

import voluptuous as vol
from voluptuous.humanize import humanize_error
import probatio
from probatio.humanize import humanize_error

from homeassistant import data_entry_flow, requirements
from homeassistant.const import CONF_ID, CONF_NAME, CONF_TYPE
Expand All @@ -18,14 +18,14 @@

MULTI_FACTOR_AUTH_MODULES: Registry[str, type[MultiFactorAuthModule]] = Registry()

MULTI_FACTOR_AUTH_MODULE_SCHEMA = vol.Schema(
MULTI_FACTOR_AUTH_MODULE_SCHEMA = probatio.Schema(
{
vol.Required(CONF_TYPE): str,
vol.Optional(CONF_NAME): str,
probatio.Required(CONF_TYPE): str,
probatio.Optional(CONF_NAME): str,
# Specify ID if you have two mfa auth module for same type.
vol.Optional(CONF_ID): str,
probatio.Optional(CONF_ID): str,
},
extra=vol.ALLOW_EXTRA,
extra=probatio.ALLOW_EXTRA,
)

DATA_REQS: HassKey[set[str]] = HassKey("mfa_auth_module_reqs_processed")
Expand Down Expand Up @@ -65,8 +65,8 @@ def name(self) -> str:
# Implement by extending class

@property
def input_schema(self) -> vol.Schema:
"""Return a voluptuous schema to define mfa auth module's input."""
def input_schema(self) -> probatio.Schema:
"""Return a schema to define mfa auth module's input."""
raise NotImplementedError

async def async_setup_flow(self, user_id: str) -> SetupFlow[Any]:
Expand Down Expand Up @@ -101,7 +101,7 @@ class SetupFlow[_MultiFactorAuthModuleT: MultiFactorAuthModule = MultiFactorAuth
def __init__(
self,
auth_module: _MultiFactorAuthModuleT,
setup_schema: vol.Schema,
setup_schema: probatio.Schema,
user_id: str,
) -> None:
"""Initialize the setup flow."""
Expand Down Expand Up @@ -137,7 +137,7 @@ async def auth_mfa_module_from_config(

try:
config = module.CONFIG_SCHEMA(config)
except vol.Invalid as err:
except probatio.Invalid as err:
_LOGGER.error(
"Invalid configuration for multi-factor module %s: %s",
module_name,
Expand Down
18 changes: 10 additions & 8 deletions homeassistant/auth/mfa_modules/insecure_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any, override

import voluptuous as vol
import probatio

from homeassistant.core import HomeAssistant

Expand All @@ -15,11 +15,13 @@

CONFIG_SCHEMA = MULTI_FACTOR_AUTH_MODULE_SCHEMA.extend(
{
vol.Required("data"): [
vol.Schema({vol.Required("user_id"): str, vol.Required("pin"): str})
probatio.Required("data"): [
probatio.Schema(
{probatio.Required("user_id"): str, probatio.Required("pin"): str}
)
]
},
extra=vol.PREVENT_EXTRA,
extra=probatio.PREVENT_EXTRA,
)


Expand All @@ -36,14 +38,14 @@ def __init__(self, hass: HomeAssistant, config: dict[str, Any]) -> None:

@property
@override
def input_schema(self) -> vol.Schema:
def input_schema(self) -> probatio.Schema:
"""Validate login flow input data."""
return vol.Schema({vol.Required("pin"): str})
return probatio.Schema({probatio.Required("pin"): str})

@property
def setup_schema(self) -> vol.Schema:
def setup_schema(self) -> probatio.Schema:
"""Validate async_setup_user input data."""
return vol.Schema({vol.Required("pin"): str})
return probatio.Schema({probatio.Required("pin"): str})

@override
async def async_setup_flow(self, user_id: str) -> SetupFlow:
Expand Down
26 changes: 15 additions & 11 deletions homeassistant/auth/mfa_modules/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Any, cast, override

import attr
import voluptuous as vol
import probatio

from homeassistant.const import CONF_EXCLUDE, CONF_INCLUDE
from homeassistant.core import HomeAssistant, callback
Expand All @@ -30,11 +30,13 @@

CONFIG_SCHEMA = MULTI_FACTOR_AUTH_MODULE_SCHEMA.extend(
{
vol.Optional(CONF_INCLUDE): vol.All(cv.ensure_list, [cv.string]),
vol.Optional(CONF_EXCLUDE): vol.All(cv.ensure_list, [cv.string]),
vol.Optional(CONF_MESSAGE, default="{} is your Home Assistant login code"): str,
probatio.Optional(CONF_INCLUDE): probatio.All(cv.ensure_list, [cv.string]),
probatio.Optional(CONF_EXCLUDE): probatio.All(cv.ensure_list, [cv.string]),
probatio.Optional(
CONF_MESSAGE, default="{} is your Home Assistant login code"
): str,
},
extra=vol.PREVENT_EXTRA,
extra=probatio.PREVENT_EXTRA,
)

STORAGE_VERSION = 1
Expand Down Expand Up @@ -108,9 +110,9 @@ def __init__(self, hass: HomeAssistant, config: dict[str, Any]) -> None:

@property
@override
def input_schema(self) -> vol.Schema:
def input_schema(self) -> probatio.Schema:
"""Validate login flow input data."""
return vol.Schema({vol.Required(INPUT_FIELD_CODE): str})
return probatio.Schema({probatio.Required(INPUT_FIELD_CODE): str})

async def _async_load(self) -> None:
"""Load stored data."""
Expand Down Expand Up @@ -277,7 +279,7 @@ class NotifySetupFlow(SetupFlow[NotifyAuthModule]):
def __init__(
self,
auth_module: NotifyAuthModule,
setup_schema: vol.Schema,
setup_schema: probatio.Schema,
user_id: str,
available_notify_services: list[str],
) -> None:
Expand Down Expand Up @@ -308,10 +310,12 @@ async def async_step_init(
if not self._available_notify_services:
return self.async_abort(reason="no_available_service")

schema = vol.Schema(
schema = probatio.Schema(
{
vol.Required("notify_service"): vol.In(self._available_notify_services),
vol.Optional("target"): str,
probatio.Required("notify_service"): probatio.In(
self._available_notify_services
),
probatio.Optional("target"): str,
}
)

Expand Down
12 changes: 6 additions & 6 deletions homeassistant/auth/mfa_modules/totp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from io import BytesIO
from typing import Any, cast, override

import voluptuous as vol
import probatio

from homeassistant.auth.models import User
from homeassistant.core import HomeAssistant
Expand All @@ -20,7 +20,7 @@

REQUIREMENTS = ["pyotp==2.9.0", "PyQRCode==1.2.1"]

CONFIG_SCHEMA = MULTI_FACTOR_AUTH_MODULE_SCHEMA.extend({}, extra=vol.PREVENT_EXTRA)
CONFIG_SCHEMA = MULTI_FACTOR_AUTH_MODULE_SCHEMA.extend({}, extra=probatio.PREVENT_EXTRA)

STORAGE_VERSION = 1
STORAGE_KEY = "auth_module.totp"
Expand Down Expand Up @@ -88,9 +88,9 @@ def __init__(self, hass: HomeAssistant, config: dict[str, Any]) -> None:

@property
@override
def input_schema(self) -> vol.Schema:
def input_schema(self) -> probatio.Schema:
"""Validate login flow input data."""
return vol.Schema({vol.Required(INPUT_FIELD_CODE): str})
return probatio.Schema({probatio.Required(INPUT_FIELD_CODE): str})

async def _async_load(self) -> None:
"""Load stored data."""
Expand Down Expand Up @@ -163,7 +163,7 @@ async def async_validate(self, user_id: str, user_input: dict[str, Any]) -> bool
await self._async_load()

# user_input has been validate in caller
# set INPUT_FIELD_CODE as vol.Required is not user friendly
# set INPUT_FIELD_CODE as probatio.Required is not user friendly
return await self.hass.async_add_executor_job(
self._validate_2fa, user_id, user_input.get(INPUT_FIELD_CODE, "")
)
Expand All @@ -189,7 +189,7 @@ class TotpSetupFlow(SetupFlow[TotpAuthModule]):
_image: str

def __init__(
self, auth_module: TotpAuthModule, setup_schema: vol.Schema, user: User
self, auth_module: TotpAuthModule, setup_schema: probatio.Schema, user: User
) -> None:
"""Initialize the setup flow."""
super().__init__(auth_module, setup_schema, user.id)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/auth/permissions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections.abc import Callable, Iterable
from typing import TYPE_CHECKING, override

import voluptuous as vol
import probatio

from .const import CAT_ENTITIES
from .entities import ENTITY_POLICY_SCHEMA, compile_entities
Expand All @@ -15,7 +15,7 @@
if TYPE_CHECKING:
from ..models import User

POLICY_SCHEMA = vol.Schema({vol.Optional(CAT_ENTITIES): ENTITY_POLICY_SCHEMA})
POLICY_SCHEMA = probatio.Schema({probatio.Optional(CAT_ENTITIES): ENTITY_POLICY_SCHEMA})

__all__ = [
"POLICY_SCHEMA",
Expand Down
28 changes: 14 additions & 14 deletions homeassistant/auth/permissions/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import OrderedDict
from collections.abc import Callable

import voluptuous as vol
import probatio

from homeassistant.helpers import device_registry as dr

Expand All @@ -12,13 +12,13 @@
from .types import CategoryType, SubCategoryDict, ValueType
from .util import SubCatLookupType, compile_policy, lookup_all

SINGLE_ENTITY_SCHEMA = vol.Any(
SINGLE_ENTITY_SCHEMA = probatio.Any(
True,
vol.Schema(
probatio.Schema(
{
vol.Optional(POLICY_READ): True,
vol.Optional(POLICY_CONTROL): True,
vol.Optional(POLICY_EDIT): True,
probatio.Optional(POLICY_READ): True,
probatio.Optional(POLICY_CONTROL): True,
probatio.Optional(POLICY_EDIT): True,
}
),
)
Expand All @@ -28,17 +28,17 @@
ENTITY_DEVICE_IDS = "device_ids"
ENTITY_ENTITY_IDS = "entity_ids"

ENTITY_VALUES_SCHEMA = vol.Any(True, vol.Schema({str: SINGLE_ENTITY_SCHEMA}))
ENTITY_VALUES_SCHEMA = probatio.Any(True, probatio.Schema({str: SINGLE_ENTITY_SCHEMA}))

ENTITY_POLICY_SCHEMA = vol.Any(
ENTITY_POLICY_SCHEMA = probatio.Any(
True,
vol.Schema(
probatio.Schema(
{
vol.Optional(SUBCAT_ALL): SINGLE_ENTITY_SCHEMA,
vol.Optional(ENTITY_AREAS): ENTITY_VALUES_SCHEMA,
vol.Optional(ENTITY_DEVICE_IDS): ENTITY_VALUES_SCHEMA,
vol.Optional(ENTITY_DOMAINS): ENTITY_VALUES_SCHEMA,
vol.Optional(ENTITY_ENTITY_IDS): ENTITY_VALUES_SCHEMA,
probatio.Optional(SUBCAT_ALL): SINGLE_ENTITY_SCHEMA,
probatio.Optional(ENTITY_AREAS): ENTITY_VALUES_SCHEMA,
probatio.Optional(ENTITY_DEVICE_IDS): ENTITY_VALUES_SCHEMA,
probatio.Optional(ENTITY_DOMAINS): ENTITY_VALUES_SCHEMA,
probatio.Optional(ENTITY_ENTITY_IDS): ENTITY_VALUES_SCHEMA,
}
),
)
Expand Down
20 changes: 10 additions & 10 deletions homeassistant/auth/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import types
from typing import Any

import voluptuous as vol
from voluptuous.humanize import humanize_error
import probatio
from probatio.humanize import humanize_error

from homeassistant import requirements
from homeassistant.const import CONF_ID, CONF_NAME, CONF_TYPE
Expand Down Expand Up @@ -34,14 +34,14 @@

AUTH_PROVIDERS: Registry[str, type[AuthProvider]] = Registry()

AUTH_PROVIDER_SCHEMA = vol.Schema(
AUTH_PROVIDER_SCHEMA = probatio.Schema(
{
vol.Required(CONF_TYPE): str,
vol.Optional(CONF_NAME): str,
probatio.Required(CONF_TYPE): str,
probatio.Optional(CONF_NAME): str,
# Specify ID if you have two auth providers for same type.
vol.Optional(CONF_ID): str,
probatio.Optional(CONF_ID): str,
},
extra=vol.ALLOW_EXTRA,
extra=probatio.ALLOW_EXTRA,
)


Expand Down Expand Up @@ -148,7 +148,7 @@ async def auth_provider_from_config(

try:
config = module.CONFIG_SCHEMA(config)
except vol.Invalid as err:
except probatio.Invalid as err:
_LOGGER.error(
"Invalid configuration for auth provider %s: %s",
provider_name,
Expand Down Expand Up @@ -237,8 +237,8 @@ async def async_step_select_mfa_module(

return self.async_show_form(
step_id="select_mfa_module",
data_schema=vol.Schema(
{"multi_factor_auth_module": vol.In(self.available_mfa_modules)}
data_schema=probatio.Schema(
{"multi_factor_auth_module": probatio.In(self.available_mfa_modules)}
),
errors=errors,
)
Expand Down
18 changes: 10 additions & 8 deletions homeassistant/auth/providers/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
from typing import Any, override

import voluptuous as vol
import probatio

from homeassistant.const import CONF_COMMAND
from homeassistant.exceptions import HomeAssistantError
Expand All @@ -19,13 +19,15 @@

CONFIG_SCHEMA = AUTH_PROVIDER_SCHEMA.extend(
{
vol.Required(CONF_COMMAND): vol.All(
probatio.Required(CONF_COMMAND): probatio.All(
str, os.path.normpath, msg="must be an absolute path"
),
vol.Optional(CONF_ARGS, default=None): vol.Any(vol.DefaultTo(list), [str]),
vol.Optional(CONF_META, default=False): bool,
probatio.Optional(CONF_ARGS, default=None): probatio.Any(
probatio.DefaultTo(list), [str]
),
probatio.Optional(CONF_META, default=False): bool,
},
extra=vol.PREVENT_EXTRA,
extra=probatio.PREVENT_EXTRA,
)

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -161,10 +163,10 @@ async def async_step_init(

return self.async_show_form(
step_id="init",
data_schema=vol.Schema(
data_schema=probatio.Schema(
{
vol.Required("username"): str,
vol.Required("password"): str,
probatio.Required("username"): str,
probatio.Required("password"): str,
}
),
errors=errors,
Expand Down
Loading
Loading