Allow group updates
This commit is contained in:
@ -97,7 +97,7 @@ def create_router(dependencies: FrontendDependencies) -> APIRouter:
|
||||
):
|
||||
"""Get partial secret detail."""
|
||||
secret = await admin.get_secret(name)
|
||||
groups = await admin.get_secret_groups()
|
||||
groups = await admin.get_secret_groups(flat=True)
|
||||
events = await admin.get_audit_log_detailed(limit=10, secret_name=name)
|
||||
|
||||
if not secret:
|
||||
@ -183,6 +183,49 @@ def create_router(dependencies: FrontendDependencies) -> APIRouter:
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
@app.put("/secrets/set-group/{name}")
|
||||
async def set_secret_group(
|
||||
request: Request,
|
||||
name: str,
|
||||
admin: Annotated[AdminBackend, Depends(dependencies.get_admin_backend)],
|
||||
group_name: Annotated[str, Form()],
|
||||
):
|
||||
"""Move a secret to a group."""
|
||||
secret = await admin.get_secret(name)
|
||||
if not secret:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND, detail="Secret not found"
|
||||
)
|
||||
|
||||
if group_name == "__ROOT":
|
||||
await admin.set_secret_group(name, None)
|
||||
|
||||
else:
|
||||
group = await admin.get_secret_group(group_name)
|
||||
if not group:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND, detail="Group not found"
|
||||
)
|
||||
await admin.set_secret_group(name, group_name)
|
||||
|
||||
groups = await admin.get_secret_groups()
|
||||
events = await admin.get_audit_log_detailed(limit=10, secret_name=secret.name)
|
||||
|
||||
secret = await admin.get_secret(name)
|
||||
|
||||
headers = {"Hx-Refresh": "true"}
|
||||
|
||||
return templates.TemplateResponse(
|
||||
request,
|
||||
"secrets/partials/tree_detail.html.j2",
|
||||
{
|
||||
"secret": secret,
|
||||
"groups": groups,
|
||||
"events": events,
|
||||
},
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
@app.put("/secrets/partial/group/{name}/description")
|
||||
async def update_group_description(
|
||||
request: Request,
|
||||
|
||||
Reference in New Issue
Block a user