Certificates: profile modal with notes, note tooltip; async PKI init

- Profiler: UserProfile.note (nullable, startup migration), PUT
  /profiles/{id}/note (max 1000 chars); add missing `requests`
  dependency (client creation failed without Public IP set).
- UI: clickable rows on Certificates open a compact profile details
  modal with an editable note; tooltip with the note on the client
  name (v-note-tooltip) and a note icon.
- PKI init runs in a background thread: POST /system/init returns 202,
  GET /system/init/status, 409 for a second start, Clear PKI and client
  creation are blocked while it runs. A marker file identifies an
  interrupted run (only such a PKI is wiped on the next Init).
- PKI Configuration page: state from the server, progress spinner and
  step text, polling, Init/Clear/Save locked while running, Init locked
  once initialized.
- Tests: one pytest each for notes and async init (requirements-dev.txt).
- Docs: plans and summaries in DOCS/Changes, API reference, README, Index.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-04 20:56:36 +03:00
1 parent 3836049230
commit d251ec73d0
24 files changed
+722 -39

No files matched your search

+15 -1
View File
@@ -5,7 +5,7 @@ from sqlalchemy.orm import Session
from database import get_db
from utils.auth import verify_token
from models import UserProfile
from schemas import UserProfile as UserProfileSchema, UserProfileCreate
from schemas import UserProfile as UserProfileSchema, UserProfileCreate, UserProfileNoteUpdate
from services import pki, generator
from datetime import datetime
@@ -74,6 +74,9 @@ def create_profile(
profile_in: UserProfileCreate,
db: Session = Depends(get_db)
):
if pki.is_init_running():
raise HTTPException(status_code=409, detail="PKI initialization is running")
# Check existing
existing = db.query(UserProfile).filter(UserProfile.username == profile_in.username).first()
if existing:
@@ -116,6 +119,17 @@ def create_profile(
db.refresh(new_profile)
return new_profile
@router.put("/profiles/{profile_id}/note", response_model=UserProfileSchema)
def update_profile_note(profile_id: int, body: UserProfileNoteUpdate, db: Session = Depends(get_db)):
profile = db.query(UserProfile).filter(UserProfile.id == profile_id).first()
if not profile:
raise HTTPException(status_code=404, detail="Profile not found")
profile.note = body.note
db.commit()
db.refresh(profile)
return profile
@router.delete("/profiles/{profile_id}")
def revoke_profile(profile_id: int, db: Session = Depends(get_db)):
profile = db.query(UserProfile).filter(UserProfile.id == profile_id).first()
+11 -5
View File
@@ -36,15 +36,21 @@ def update_pki_config(
):
return config.update_pki_settings(db, settings)
@router.post("/system/init")
@router.post("/system/init", status_code=202)
def init_system_pki(db: Session = Depends(get_db)):
try:
msg = pki.init_pki(db)
return {"message": msg}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
pki.start_init_async(db)
except pki.InitConflict as e:
raise HTTPException(status_code=409, detail=str(e))
return {"state": "running"}
@router.get("/system/init/status")
def get_init_status(db: Session = Depends(get_db)):
return pki.init_status(db)
@router.delete("/system/pki")
def clear_system_pki(db: Session = Depends(get_db)):
if pki.is_init_running():
raise HTTPException(status_code=409, detail="PKI initialization is running")
msg = pki.clear_pki(db)
return {"message": msg}