Add trusted_users in trusted networks auth provider (#22478)
This commit is contained in:
parent
26726af689
commit
6ba2891604
5 changed files with 318 additions and 12 deletions
|
@ -8,6 +8,7 @@ from datetime import (timedelta, datetime as datetime_sys,
|
|||
from socket import _GLOBAL_DEFAULT_TIMEOUT
|
||||
from typing import Any, Union, TypeVar, Callable, Sequence, Dict, Optional
|
||||
from urllib.parse import urlparse
|
||||
from uuid import UUID
|
||||
|
||||
import voluptuous as vol
|
||||
from pkg_resources import parse_version
|
||||
|
@ -532,6 +533,20 @@ def x10_address(value):
|
|||
return str(value).lower()
|
||||
|
||||
|
||||
def uuid4_hex(value):
|
||||
"""Validate a v4 UUID in hex format."""
|
||||
try:
|
||||
result = UUID(value, version=4)
|
||||
except (ValueError, AttributeError, TypeError) as error:
|
||||
raise vol.Invalid('Invalid Version4 UUID', error_message=str(error))
|
||||
|
||||
if result.hex != value.lower():
|
||||
# UUID() will create a uuid4 if input is invalid
|
||||
raise vol.Invalid('Invalid Version4 UUID')
|
||||
|
||||
return result.hex
|
||||
|
||||
|
||||
def ensure_list_csv(value: Any) -> Sequence:
|
||||
"""Ensure that input is a list or make one from comma-separated string."""
|
||||
if isinstance(value, str):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue