You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.2 KiB
3.2 KiB
Regenerate Service Token
Tujuan
Membuat token baru untuk service token yang sudah ada. Token lama langsung direvoke. Digunakan saat token hilang, bocor, atau perlu dirotasi.
Business Rule
- Token lama direvoke terlebih dahulu (is_active = false)
- Token baru dibuat dengan name dan service yang sama
- Token baru disinkronkan ke
geonetagent_dev.agent_tokens - Token lama di-revoke di
geonetagent_dev.agent_tokens - Downtime window: antara revoke token lama dan distribusi token baru ke microservice
- Token plain text ditampilkan sekali — harus disimpan saat itu juga
URL
POST https://console.gisportal.id/api/v1/service-tokens/{id}/regenerate
HTTP Method
POST
Authentication
Authorization: Bearer <jwt_token_atau_api_token>
Request Parameter
| Parameter | Tipe | Keterangan |
|---|---|---|
id |
UUID | ID service token yang akan di-regenerate |
Request Body (opsional)
{
"expires_in_days": 90
}
Jika tidak disertakan, token baru tidak expire (null).
Response Success
HTTP 200
{
"data": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "GeoNetAgent-Production",
"service": "GeoNetAgent",
"token_prefix": "Xk9mPqR2nLvWsJhY",
"token": "Xk9mPqR2nLvWsJhYaB7cDeFgHiJkLmNoPqRsTuVwXyZ",
"is_active": true,
"expires_at": null,
"created_by": "admin",
"created_at": "2026-06-23T10:00:00+07:00"
},
"message": "Service token regenerated successfully. Save the new token securely as it will not be shown again."
}
Response Error
HTTP 404:
{
"error": {
"code": "NOT_FOUND",
"message": "Service token not found"
}
}
Status Code
| Code | Kondisi |
|---|---|
| 200 | Token berhasil di-regenerate |
| 401 | Tidak terautentikasi |
| 404 | Token ID tidak ditemukan |
Contoh Request
curl -s -X POST \
https://console.gisportal.id/api/v1/service-tokens/065eb796-ecb5-4d95-b4cd-9ca6244cf13f/regenerate \
-H "Authorization: Bearer <jwt_token>" \
-H "Content-Type: application/json"
Sequence Flow
sequenceDiagram
Client->>API: POST /service-tokens/{id}/regenerate
API->>DB(databaselist_app): Ambil token lama
API->>DB(databaselist_app): Revoke token lama (is_active=false)
API->>DB(geonetagent_dev): Revoke di agent_tokens (sync)
API->>API: Generate token baru
API->>DB(databaselist_app): INSERT service_tokens baru
API->>DB(geonetagent_dev): INSERT agent_tokens baru (sync)
API->>AuditLog: log service_token_regenerated
API-->>Client: 200 {token_baru (sekali tampil)}
Dampak ke Microservice GeoNetAgent
Setelah regenerate, agent yang masih menggunakan token lama akan mendapat 401 dari collector.
Langkah yang diperlukan:
- Copy token baru dari response
- Update
config.jsondi semua PC client agent:{ "agent_token": "<token_baru>" } - Distribusikan via GPO atau manual
- Agent akan menggunakan token baru pada posting berikutnya
Audit Log
Event: service_token_regenerated
Idempotent
Tidak — setiap regenerate menghasilkan token baru.
Changelog
| Tanggal | Perubahan |
|---|---|
| 2026-06-23 | Endpoint dibuat |