Commit a798ad4
authored
feat: admin whitelist API (#313)
* feat(api): admin whitelist API
Add admin endpoints to manage the registration whitelist, gated by a
static bearer token (Authorization: Bearer), enabled via the `admin`
config block with the token supplied through ADMIN_API_KEY.
Endpoints (under /admin):
- POST /admin/whitelist add/upsert an address (idempotent)
- DELETE /admin/whitelist/{address} remove (404 when not whitelisted)
- GET /admin/whitelist cursor-paginated list
Details:
- New whitelist domain in pkg/user/whitelist: a Service providing the
authorization gate (Checker) plus admin add/remove/list (Manager),
with EIP-55 validation/normalization. The admin HTTP handlers and
bearer middleware live here.
- userstore: RemoveFromWhitelist reports rows-affected (for 404);
ListWhitelist is cursor-based (ORDER BY evm_address, the unique PK);
whitelist lookups (IsWhitelisted/Remove) are case-insensitive via
LOWER(evm_address), backed by a functional index (migration 15).
- config: optional AdminAPI block; api_key required_if enabled.
- e2e: whitelisting now goes through the admin endpoint instead of a
direct DB insert; adds full lifecycle + pagination tests.
* fix(api): address review feedback on whitelist
- ListWhitelist: order and compare the cursor on LOWER(evm_address) so
cursor pagination is case-insensitive and stable for mixed-case (EIP-55)
addresses, consistent with the IsWhitelisted/Remove lookups and the
LOWER(evm_address) functional index. Uses OrderExpr so the LOWER(...)
is emitted as raw SQL rather than quoted as a column. Adds a mixed-case
cursor test.
- writeJSON: marshal the payload before writing the status line so a
serialization failure returns 500 instead of a 200 with a truncated
body (whitelist admin + registration handlers).
* fix(api): make admin opt-in via ADMIN_API_ENABLED
admin.enabled was hardcoded true in the default configs, so every process
that loads the api-server config — including the bootstrap (bootstrap-demo
/ bootstrap-bridge call config.LoadAPIServer) — required ADMIN_API_KEY to
pass required_if validation. The bootstrap container has no such token, so
its config load failed and the DEMO TokenConfig / bridge TransferFactory
were never created, breaking the transfer/balance/registry e2e tests.
Make admin opt-in: enabled is now driven by ${ADMIN_API_ENABLED} (default
off, mirroring skip_canton_sig_verify). The api-server service sets it to
true in compose; the bootstrap leaves it unset, so its config load no
longer needs a token. Also keeps admin off-by-default for mainnet.1 parent e23ed70 commit a798ad4
34 files changed
Lines changed: 1732 additions & 144 deletions
File tree
- pkg
- app/api
- config
- defaults
- tests
- ethrpc/service
- userstore
- user
- service
- mocks
- whitelist
- mocks
- tests/e2e
- devstack
- dsl
- shim
- stack
- tests/api
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
302 | 308 | | |
303 | 309 | | |
304 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
164 | 175 | | |
165 | 176 | | |
166 | 177 | | |
| |||
364 | 375 | | |
365 | 376 | | |
366 | 377 | | |
367 | | - | |
| 378 | + | |
368 | 379 | | |
369 | 380 | | |
370 | | - | |
| 381 | + | |
371 | 382 | | |
| 383 | + | |
372 | 384 | | |
373 | 385 | | |
374 | 386 | | |
| |||
392 | 404 | | |
393 | 405 | | |
394 | 406 | | |
395 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
396 | 413 | | |
397 | 414 | | |
398 | 415 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
85 | 97 | | |
86 | 98 | | |
87 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
260 | 272 | | |
261 | 273 | | |
262 | 274 | | |
| |||
409 | 421 | | |
410 | 422 | | |
411 | 423 | | |
| 424 | + | |
412 | 425 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
137 | 144 | | |
138 | 145 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
128 | 135 | | |
129 | 136 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
102 | 109 | | |
103 | 110 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
148 | 156 | | |
149 | 157 | | |
150 | | - | |
151 | | - | |
152 | | - | |
| 158 | + | |
153 | 159 | | |
0 commit comments