You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Backend/frontend deployments use `RollingUpdate` with `maxUnavailable: 0`.
41
41
- HPA scales backend pods between 2 and 8 replicas based on CPU utilization.
42
+
43
+
## Secret Rotation
44
+
45
+
Regularly rotate all long-lived secrets to limit the blast radius of a credential leak. Below is a per-secret rotation guide for the entries in `k8s/base/secret-template.yaml`.
|`JWT_SECRET_KEY`| Every 90 days or on compromise | All active sessions invalidated; users must re-authenticate. | 1. Generate new key: `openssl rand -hex 64`<br>2. Update the Secret and rollout the backend.<br>3. Old tokens are rejected immediately — warn users before rotation. |
50
+
|`DATABASE_URL`| On credential leak only | Brief connection drain; in-flight queries fail and must be retried. | 1. Update `POSTGRES_PASSWORD` first (see below).<br>2. Apply new Secret; backend pods will reconnect via pooled connections.<br>3. Monitor for `FATAL: password authentication failed` during the window. |
51
+
|`STELLAR_ADMIN_SECRET`| Every 180 days or on compromise | No direct user impact; contract admin operations may fail until updated. | 1. Generate a new Stellar keypair: `stellar keys generate --fund testnet`.<br>2. Update the Secret and rollout.<br>3. Transfer contract ownership or update admin reference in the contract if the address changed. |
52
+
|`STELLAR_ADMIN_PUBLIC`| In lockstep with `STELLAR_ADMIN_SECRET`| None — derived from the secret. | Update alongside the secret above. |
53
+
|`STELLAR_CONTRACT_ID`| On contract upgrade or re-deployment | Operations targeting the old contract ID fail until clients refresh. | 1. Deploy new contract and verify.<br>2. Update the Secret and rollout backend.<br>3. Announce the new contract ID to downstream consumers. |
54
+
|`STORAGE_SECRET_KEY`| Every 90 days | Stored files remain accessible; new uploads signed with old key fail silently. | 1. Generate new key: `openssl rand -hex 32`.<br>2. Apply new Secret; backend rotates signing key at next startup.<br>3. Verify upload / download flows in staging first. |
55
+
|`WEBHOOK_SECRET_KEY`| Every 90 days or on compromise | Webhook payloads signed with the old key fail HMAC verification on the consumer side. | 1. Generate new key: `openssl rand -hex 32`.<br>2. Coordinate with webhook consumers to accept both old and new signatures during a transition window.<br>3. Apply new Secret and remove old consumer key after one week. |
56
+
|`POSTGRES_PASSWORD`| Every 180 days or on credential leak | Active connections drain; brief read/write failures while pods reconnect. | 1. Update the password in PostgreSQL first: `ALTER USER postgres PASSWORD 'new-password';`<br>2. Update the Secret and rollout backend.<br>3. **Staging → Production** — always test the rotation on staging first.<br>4. ⚠️ **WARNING** — Rotating the database password will briefly interrupt all services that depend on the database. Plan during a maintenance window. |
57
+
|`REDIS_PASSWORD`| Every 180 days or on compromise | Cache entries are lost if Redis restarts; brief increase in backend latency. | 1. Update Redis password: `CONFIG SET requirepass "new-password"`.<br>2. Apply new Secret; backend caches will reconnect transparently.<br>3. If enabled for sessions, expect all users to be logged out. |
58
+
59
+
### General rotation procedure
60
+
61
+
1.**Generate** the new secret value using a secure random source (openssl, `stellar keys`, or your vault).
62
+
2.**Apply** the updated manifest: `kubectl apply -k k8s/overlays/<environment>`.
63
+
3.**Rollout** the affected pods: `kubectl rollout restart deployment/<name>`.
64
+
4.**Verify** the deployment is healthy and the new secret is picked up.
65
+
5.**Invalidate** old secrets when the rotation window closes.
66
+
67
+
> **⚠️ HIGH IMPACT** — Database and Redis password rotations affect all connected services. Always test in staging before production and schedule outside business hours.
Copy file name to clipboardExpand all lines: docs/SMARTCONTRACT.md
+150Lines changed: 150 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,3 +57,153 @@ The risk pool contract manages liquidity-provider balances and yield distributio
57
57
-`("pool", "withdraw")`
58
58
-`("pool", "yield")`
59
59
-`("pool", "claim")`
60
+
61
+
## Initialization Runbook
62
+
63
+
This runbook describes the ordered steps to deploy and initialize the StellarInsure smart contracts on a Soroban-compatible testnet (e.g. Futurenet / Testnet).
64
+
65
+
### Prerequisites
66
+
67
+
| Item | Requirement |
68
+
|---|---|
69
+
| Soroban CLI |`soroban` version 21+ installed and configured |
| Contract deploy fails (insufficient balance) | Fund the admin account with more XLM and retry the deploy. |
197
+
|`init` returns `AlreadyInitialized`| The contract was already initialized — skip to step 4. This is safe. |
198
+
|`set_premium_token` fails with `Unauthorized`| Verify the admin address and secret match the account used in `init`. |
199
+
| RiskPool not linked | Invoking `pay_premium` will work but premiums will not flow to the pool. Run step 6 to link. |
200
+
| Oracle registration fails | The contract can operate without oracles; manual claim processing still works. Retry after fixing the oracle address. |
201
+
| Any step fails mid-way | Steps are **not** transactional — you can safely retry any step individually. No partial state is left behind that blocks re-execution. |
202
+
| Wrong network | Ensure `--rpc-url` and `--network-passphrase` match. Deploy on the wrong network means starting over with the correct RPC. |
203
+
204
+
### Network assumptions
205
+
206
+
- The admin keypair must be **funded** with sufficient XLM to cover deploy fees and contract storage rent.
207
+
- The premium token **must** be a pre-deployed Stellar Asset Contract (SAC). Classic assets are not directly supported.
208
+
- The risk pool contract **should** be initialized before it receives token transfers from the main contract. If it receives tokens before `init`, they may be unrecoverable.
209
+
- Oracle contracts must conform to the `OracleProvider` trait defined in `oracle.rs`. Stub oracles (`WeatherOracle`, `FlightOracle`, etc.) are built into the contract for development use and do not require external registration.
0 commit comments