feat(ui): replace configuration editors with graphical forms
This commit is contained in:
+15
-3
@@ -1,9 +1,9 @@
|
||||
from typing import Any, Literal
|
||||
from typing import Annotated, Any, Literal
|
||||
from ipaddress import ip_interface
|
||||
import re
|
||||
import uuid
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
from pydantic import BaseModel, ConfigDict, Field, StringConstraints, ValidationInfo, field_validator
|
||||
|
||||
|
||||
class Model(BaseModel):
|
||||
@@ -156,7 +156,19 @@ class UserCreate(Model):
|
||||
|
||||
class SecretCreate(Model):
|
||||
name: str = Field(min_length=1, max_length=120)
|
||||
value: str = Field(min_length=1, max_length=16384)
|
||||
kind: Literal["value", "root_password"] = "value"
|
||||
value: Annotated[str, StringConstraints(strip_whitespace=False)] = Field(min_length=1, max_length=16384)
|
||||
|
||||
@field_validator("value", mode="before")
|
||||
@classmethod
|
||||
def secret_value(cls, value, info: ValidationInfo):
|
||||
if not isinstance(value, str):
|
||||
return value
|
||||
if info.data.get("kind") == "root_password":
|
||||
if not 12 <= len(value) <= 1024 or "\x00" in value:
|
||||
raise ValueError("Root-Passwörter benötigen 12 bis 1024 Zeichen ohne Nullzeichen.")
|
||||
return value
|
||||
return value.strip()
|
||||
|
||||
|
||||
class Enroll(Model):
|
||||
|
||||
Reference in New Issue
Block a user