Skip to content

Add Admin Endpoint (Superadmin Only) #47

Description

@codebestia

Background

The only way to create an Admin row so far is one-time bootstrap script. This issue adds the normal, ongoing way: an existing superadmin adding another admin through the API. Per the request, this does not touch the smart contract at all — it's a backend-only concept, deliberately decoupled from the contract's own Admin/Manager/Operator role system, which is a separate on-chain authorization concern this backend doesn't currently drive.

Proposed Steps

  1. POST /admin/admins (requireSuperAdmin) — body { address: string, name: string, isSuperAdmin?: boolean }.
  2. Validate address with StrKey.isValidEd25519PublicKey; 400 if invalid.
  3. Reject if an Admin row for that address already exists — 409, matching the same non-overwrite discipline as the one-time bootstrap script.
  4. Create the row with createdBy: req.admin.id (the acting superadmin) and isSuperAdmin: Boolean(body.isSuperAdmin) (defaults to false — a superadmin creating another admin does not implicitly grant superadmin unless explicitly requested; a superadmin can choose to grant it, since restricting that further isn't something the request asked for).
  5. Record a admin.created audit log entry with actorId: req.admin.id, targetId: <new admin id>.
  6. Return the created admin record (no keypair or secret involved anywhere in this flow — admins authenticate with their own existing Stellar wallet.

Acceptance Criteria

  • POST /admin/admins requires requireSuperAdmin — a non-superadmin admin gets 403
  • Valid new address + name → 201 with the created admin (no isSuperAdmin in body → defaults to false)
  • Duplicate address → 409, no row created or modified
  • Invalid Stellar address → 400
  • Created row's createdBy is set to the acting superadmin's id
  • No smart contract call is made anywhere in this flow
  • Exactly one AdminLog entry (admin.created) is produced per successful call

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions