mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 02:00:46 +08:00
Add capability RBAC, Alembic bootstrap, optional worker schedulers, and close public docs by default so lab installs stay usable without shared signing keys. Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""Pydantic schemas for auth / users / audit / API tokens."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class LoginRequest(BaseModel):
|
|
username: str = Field(min_length=1, max_length=64)
|
|
password: str = Field(min_length=1, max_length=256)
|
|
|
|
|
|
class ChangePasswordRequest(BaseModel):
|
|
old_password: str = Field(min_length=1, max_length=256)
|
|
new_password: str = Field(min_length=6, max_length=256)
|
|
|
|
|
|
class UserCreateRequest(BaseModel):
|
|
username: str = Field(min_length=2, max_length=64)
|
|
password: str = Field(min_length=6, max_length=256)
|
|
role: str = Field(default="user")
|
|
scopes: list[str] | None = None
|
|
|
|
|
|
class UserUpdateRequest(BaseModel):
|
|
is_active: bool | None = None
|
|
role: str | None = None
|
|
password: str | None = Field(default=None, min_length=6, max_length=256)
|
|
scopes: list[str] | None = None
|
|
|
|
|
|
class ApiTokenCreateRequest(BaseModel):
|
|
name: str = Field(default="default", max_length=128)
|
|
# Days until expiry; 0 / null = never expires.
|
|
expires_in_days: int | None = Field(default=90, ge=0, le=3650)
|
|
# Admin may create a token for another user; others ignored / forced to self.
|
|
user_id: str | None = None
|
|
# Capability subset; empty inherits owner scopes.
|
|
scopes: list[str] | None = None
|