@geolonia/geonicdb-cli 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -26
- package/dist/index.js +332 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,14 +193,37 @@ Displays the current authenticated user, token expiry, and active profile.
|
|
|
193
193
|
|---|---|
|
|
194
194
|
| `me oauth-clients list` | List your OAuth clients |
|
|
195
195
|
| `me oauth-clients create [json]` | Create a new OAuth client |
|
|
196
|
+
| `me oauth-clients update <clientId> [json]` | Update an OAuth client |
|
|
197
|
+
| `me oauth-clients regenerate-secret <clientId>` | Regenerate client secret |
|
|
196
198
|
| `me oauth-clients delete <id>` | Delete an OAuth client |
|
|
197
199
|
|
|
200
|
+
`me oauth-clients create` supports flag options: `--name`, `--policy`, `--save`. Use `--save` to store client credentials in config for automatic re-authentication.
|
|
201
|
+
|
|
202
|
+
`me oauth-clients update` supports: `--name`, `--description`, `--policy-id` (use `null` to unbind), `--active`, `--inactive`.
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Create with flags
|
|
206
|
+
geonic me oauth-clients create --name my-ci-bot --policy <policy-id>
|
|
207
|
+
|
|
208
|
+
# Create from JSON (note: field is "name", not "clientName")
|
|
209
|
+
geonic me oauth-clients create '{"name":"my-bot","policyId":"<policy-id>"}'
|
|
210
|
+
|
|
211
|
+
# Attach a personal policy
|
|
212
|
+
geonic me oauth-clients update <client-id> --policy-id my-readonly
|
|
213
|
+
|
|
214
|
+
# Unbind policy
|
|
215
|
+
geonic me oauth-clients update <client-id> --policy-id null
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Note**: `--policy-id` on update accepts only policies created by yourself (`/me/policies`). Policies created via `admin policies` cannot be bound here.
|
|
219
|
+
|
|
198
220
|
#### me api-keys
|
|
199
221
|
|
|
200
222
|
| Subcommand | Description |
|
|
201
223
|
|---|---|
|
|
202
224
|
| `me api-keys list` | List your API keys |
|
|
203
225
|
| `me api-keys create [json]` | Create a new API key |
|
|
226
|
+
| `me api-keys update <keyId> [json]` | Update an API key |
|
|
204
227
|
| `me api-keys delete <keyId>` | Delete an API key |
|
|
205
228
|
|
|
206
229
|
`me api-keys create` supports flag options:
|
|
@@ -208,27 +231,61 @@ Displays the current authenticated user, token expiry, and active profile.
|
|
|
208
231
|
| Flag | Description |
|
|
209
232
|
|---|---|
|
|
210
233
|
| `--name <name>` | Key name |
|
|
211
|
-
| `--
|
|
234
|
+
| `--policy <policyId>` | Policy ID to attach (XACML policy) |
|
|
212
235
|
| `--origins <origins>` | Allowed origins (comma-separated, at least 1 required) |
|
|
213
|
-
| `--entity-types <types>` | Allowed entity types (comma-separated) |
|
|
214
236
|
| `--rate-limit <n>` | Rate limit (requests per minute) |
|
|
215
237
|
| `--dpop-required` | Require DPoP token binding (RFC 9449) |
|
|
216
|
-
| `--permissions <perms>` | Permissions for auto-generated XACML policy (comma-separated) |
|
|
217
238
|
| `--save` | Save the API key to profile config |
|
|
218
239
|
|
|
219
|
-
|
|
220
|
-
# Create an API key and save to config
|
|
221
|
-
geonic me api-keys create --name my-app --scopes read:entities --save
|
|
240
|
+
`me api-keys update` supports: `--name`, `--policy-id` (use `null` to unbind), `--origins`, `--rate-limit`, `--dpop-required` / `--no-dpop-required`, `--active`, `--inactive`.
|
|
222
241
|
|
|
223
|
-
|
|
224
|
-
|
|
242
|
+
```bash
|
|
243
|
+
# Create an API key with a policy and save to config
|
|
244
|
+
geonic me api-keys create --name my-app --policy <policy-id> --save
|
|
225
245
|
|
|
226
246
|
# Create from JSON
|
|
227
|
-
geonic me api-keys create '{"name":"my-app","
|
|
247
|
+
geonic me api-keys create '{"name":"my-app","policyId":"<policy-id>"}'
|
|
248
|
+
|
|
249
|
+
# Attach a personal policy
|
|
250
|
+
geonic me api-keys update <key-id> --policy-id my-readonly
|
|
251
|
+
|
|
252
|
+
# Unbind policy
|
|
253
|
+
geonic me api-keys update <key-id> --policy-id null
|
|
228
254
|
```
|
|
229
255
|
|
|
230
256
|
`me api-keys list` output includes a `dpopRequired` field (boolean).
|
|
231
257
|
|
|
258
|
+
**Note**: `--policy-id` on update accepts only policies created by yourself (`/me/policies`). Policies created via `admin policies` cannot be bound here.
|
|
259
|
+
|
|
260
|
+
#### me policies
|
|
261
|
+
|
|
262
|
+
| Subcommand | Description |
|
|
263
|
+
|---|---|
|
|
264
|
+
| `me policies list` | List your personal policies |
|
|
265
|
+
| `me policies get <policyId>` | Get a personal policy by ID |
|
|
266
|
+
| `me policies create [json]` | Create a personal policy |
|
|
267
|
+
| `me policies update <policyId> [json]` | Update a personal policy |
|
|
268
|
+
| `me policies delete <policyId>` | Delete a personal policy |
|
|
269
|
+
|
|
270
|
+
Personal policies (`scope: personal`) are created by `user` role accounts for self-service access control. They can be bound to your own API keys and OAuth clients.
|
|
271
|
+
|
|
272
|
+
**Constraints (enforced server-side)**:
|
|
273
|
+
- `priority` is fixed at 100 (user role minimum — cannot escalate)
|
|
274
|
+
- `scope` is always `personal` — not applied tenant-wide
|
|
275
|
+
- `target` is required
|
|
276
|
+
- Data API paths only (`/v2/**`, `/ngsi-ld/**` etc.) — admin/me paths are not allowed
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
# Create a GET-only policy
|
|
280
|
+
geonic me policies create @readonly-policy.json
|
|
281
|
+
|
|
282
|
+
# Bind to an API key
|
|
283
|
+
geonic me api-keys update <key-id> --policy-id my-readonly
|
|
284
|
+
|
|
285
|
+
# Bind to an OAuth client
|
|
286
|
+
geonic me oauth-clients update <client-id> --policy-id my-readonly
|
|
287
|
+
```
|
|
288
|
+
|
|
232
289
|
### entities — Manage context entities
|
|
233
290
|
|
|
234
291
|
| Subcommand | Description |
|
|
@@ -396,15 +453,24 @@ Temporal entityOperations query supports: `--aggr-methods`, `--aggr-period`.
|
|
|
396
453
|
| `admin policies activate <id>` | Activate a policy |
|
|
397
454
|
| `admin policies deactivate <id>` | Deactivate a policy |
|
|
398
455
|
|
|
399
|
-
**XACML Authorization Model**: All authorization is unified under XACML policies. Default role policies
|
|
456
|
+
**XACML Authorization Model**: All authorization is unified under XACML policies. Default role policies:
|
|
400
457
|
|
|
401
|
-
| Role | Default Behavior |
|
|
402
|
-
|
|
403
|
-
| `user` |
|
|
404
|
-
| `api_key` | All Deny |
|
|
405
|
-
| `anonymous` | All Deny |
|
|
458
|
+
| Role | Default Behavior | Default priority |
|
|
459
|
+
|---|---|---|
|
|
460
|
+
| `user` | `/v2/**` and `/ngsi-ld/**` — all methods (CRUD) Permit. Other data APIs (`/catalog`, `/rules`, etc.) — GET only. | 100 |
|
|
461
|
+
| `api_key` | All Deny | 100 |
|
|
462
|
+
| `anonymous` | All Deny | 100 |
|
|
406
463
|
|
|
407
|
-
|
|
464
|
+
**Priority**: Smaller `priority` value = higher precedence (e.g. `priority: 10` overrides the user default at `priority: 100`).
|
|
465
|
+
|
|
466
|
+
| priority range | Who creates | Notes |
|
|
467
|
+
|---|---|---|
|
|
468
|
+
| -1 | System | deny-fence (e.g. super_admin data API block) — cannot be overridden |
|
|
469
|
+
| 0 | System | super_admin default — tenant_admin and below cannot override |
|
|
470
|
+
| 10–99 | `tenant_admin` | Custom tenant-wide policies |
|
|
471
|
+
| 100 | System / `user` (self-service via `/me/policies`) | `user` / `api_key` / `anonymous` defaults and personal policies — server fixes personal policy priority at 100 |
|
|
472
|
+
|
|
473
|
+
Custom `tenant_admin` policies (priority 10–99) override the user defaults. Target resource attributes include: `path`, `entityType`, `entityId`, `entityOwner`, `tenantService`, `servicePath`. The `servicePath` attribute supports glob patterns (e.g. `/opendata/**`) and regex matching.
|
|
408
474
|
|
|
409
475
|
#### admin oauth-clients
|
|
410
476
|
|
|
@@ -426,11 +492,11 @@ Custom policies with higher priority (e.g. 100) override defaults. Target resour
|
|
|
426
492
|
| `admin api-keys update <keyId> [json]` | Update an API key |
|
|
427
493
|
| `admin api-keys delete <keyId>` | Delete an API key |
|
|
428
494
|
|
|
429
|
-
`admin api-keys list` supports `--tenant-id` to filter by tenant. `admin api-keys create` supports flag options: `--name`, `--
|
|
495
|
+
`admin api-keys list` supports `--tenant-id` to filter by tenant. `admin api-keys create` supports flag options: `--name`, `--policy`, `--origins`, `--rate-limit`, `--dpop-required`, `--tenant-id`, `--save`. `admin api-keys update` supports `--name`, `--policy`, `--origins`, `--rate-limit`, `--dpop-required` / `--no-dpop-required`.
|
|
430
496
|
|
|
431
|
-
**
|
|
497
|
+
**Policy**: Use `--policy <policyId>` to attach an existing XACML policy to the API key. Manage policies with `geonic admin policies` commands.
|
|
432
498
|
|
|
433
|
-
**Note**: `allowedOrigins` must contain at least 1 item when specified. Use `*` to allow all origins. `
|
|
499
|
+
**Note**: `allowedOrigins` must contain at least 1 item when specified. Use `*` to allow all origins. `admin api-keys list` / `admin api-keys get` output includes a `dpopRequired` field (boolean).
|
|
434
500
|
|
|
435
501
|
#### admin cadde
|
|
436
502
|
|
|
@@ -578,17 +644,16 @@ GDB_API_KEY=gdb_your_api_key_here geonic entities list
|
|
|
578
644
|
|
|
579
645
|
When both a Bearer token and an API key are configured, headers are sent exclusively — the API key takes precedence when present.
|
|
580
646
|
|
|
581
|
-
###
|
|
582
|
-
|
|
583
|
-
`read:entities`, `write:entities`, `read:subscriptions`, `write:subscriptions`, `read:registrations`, `write:registrations`, `read:rules`, `write:rules`, `read:custom-data-models`, `write:custom-data-models`, `admin:users`, `admin:tenants`, `admin:policies`, `admin:oauth-clients`, `admin:api-keys`, `admin:metrics`
|
|
647
|
+
### Authorization Model
|
|
584
648
|
|
|
585
|
-
|
|
649
|
+
All authorization for API keys and OAuth clients is controlled via XACML policies. Use `--policy <policyId>` when creating API keys or OAuth clients to attach an existing policy.
|
|
586
650
|
|
|
587
|
-
|
|
651
|
+
- **Tenant admins**: manage tenant-wide policies with `geonic admin policies` commands.
|
|
652
|
+
- **Users**: manage personal policies with `geonic me policies` commands and bind them to your own API keys / OAuth clients with `--policy-id`.
|
|
588
653
|
|
|
589
|
-
|
|
654
|
+
See the [admin policies](#admin-policies) section for details on the XACML authorization model, default role policies, and target resource attributes.
|
|
590
655
|
|
|
591
|
-
|
|
656
|
+
**Note**: `--policy-id` on `me api-keys update` / `me oauth-clients update` accepts only policies where `createdBy` matches your own user ID (i.e. policies created via `me policies create`). Policies created via `admin policies` cannot be bound to personal resources.
|
|
592
657
|
|
|
593
658
|
## Development
|
|
594
659
|
|