Skip to content

[Admin][API] Moderation — suspend user, unpublish/delete agent, cancel instance, roles/keys #34

Description

@serge-ivo

[Admin][API] Moderation — suspend user, unpublish/delete agent, cancel instance, manage roles/keys

Why

There is no operator lever to act on abuse or breakage. Every mutation here must be gated by requireAdmin and written to admin_audit_log.

Scope

  • Users:POST /v1/admin/users/:id/suspend + /unsuspend (a suspended flag on users, enforced in requireUser so a suspended user can't call the API). PUT /v1/admin/users/:id/roles (grant/revoke creator/admin).
  • Agents:POST /v1/admin/agents/:id/unpublish (set visibility=draft) and admin DELETE /v1/admin/agents/:id (reuse owner-or-admin delete already in agents.ts).
  • Instances:POST /v1/admin/instances/:id/cancel (operator cancel of a runaway/abusive instance).
  • Keys:POST /v1/admin/users/:id/keys/revoke (delete a stored provider key by provider — never reveal it).
  • Every action → admin_audit_log row.

Acceptance criteria

  • Suspended user is blocked at requireUser (401/403) until unsuspended; verified by test.
  • Unpublish flips visibility; admin delete works; instance cancel works.
  • Role changes reflect in the user's next session.
  • Every mutation writes exactly one audit row; non-admin → 403.

Relevant code

  • lib/auth.ts (requireUser suspension check), routes/agents.ts (delete), routes/instances.ts (cancel), user_api_keys
  • admin_audit_log (from Foundation issue)

References

  • FAS deprovision + FGS delist/archive + comp-grant revoke; PAS has no moderation (gap we close).

Part of the PAGS Admin Portal epic. Depends on Foundation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    admin-portalPAGS admin/operator portalenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions