Skip to content

Replication (host-level)

Host-level MySQL replication status and setup.

All endpoints below are mounted under /api. Authentication: Authorization: Bearer <token> unless noted as public.

Endpoint count: 2

Endpoints

Method Path Handler Guards
GET /api/replication/check-user/:username checkUserExists AuthWithDB(cfg.JWTSecret, db)
POST /api/replication/install-ssh-key/:username installUserSSHKey AuthWithDB(cfg.JWTSecret, db)

Source

Handlers for this section live in api/routes/handlers_*.go in the StarkOne source. Each handler binds its request body with gin.ShouldBindJSON(&req) and responds with the standard envelope:

{ "data": { ... } }

On error:

{ "error": { "code": "string", "message": "string" } }

Reference

GET /api/replication/check-user/:username

Reports whether a given username exists, checking first the panel database and then the system user table.

Guards: AuthWithDB(cfg.JWTSecret, db)

Path parameters

Name Type Description
username string Username to check for existence in the panel DB and on the host system.

Response - 200 OK

This handler returns a flat (non-enveloped) body, not the standard { "data": ... } wrapper. exists is true if the username is found in the users table or resolves via a system user lookup, otherwise false.

{ "exists": true }

Errors

This handler always responds 200 OK. The database query and system lookup errors are swallowed; a missing user simply yields { "exists": false }.

Example

curl https://panel.example.com:2087/api/replication/check-user/user1 \
  -H "Authorization: Bearer $TOKEN"

POST /api/replication/install-ssh-key/:username

Appends a supplied SSH public key to the target system user's ~/.ssh/authorized_keys file (used to authorize replication sync access).

Guards: AuthWithDB(cfg.JWTSecret, db)

Path parameters

Name Type Description
username string System user whose authorized_keys file the key is added to.

Request body

{ "public_key": "string (required)" }
Field Type Required Description
public_key string yes The SSH public key line to append to the user's authorized_keys.

Response - 200 OK

{ "data": { "success": true } }

Errors

Status Code Meaning
400 - Request body failed binding (e.g. public_key missing); error.message carries the binding error.
404 - System user lookup failed; error.message is "User not found".
500 - Could not open the authorized_keys file for writing; error.message carries the OS error.

Error bodies use { "error": { "message": "..." } } and do not include a code field.

Side effects

  • Creates /home/<username>/.ssh with mode 0700 if missing (os.MkdirAll).
  • Appends the public key (plus a newline) to /home/<username>/.ssh/authorized_keys, creating it with mode 0600 if missing.
  • Runs chown -R <username>:<username> /home/<username>/.ssh to fix ownership.

Example

curl -X POST https://panel.example.com:2087/api/replication/install-ssh-key/user1 \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"public_key": "ssh-ed25519 AAAA... [email protected]"}'