@geolonia/geonicdb-cli 0.6.4 → 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 +96 -15
- package/dist/index.js +359 -50
- 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,23 +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
238
|
| `--save` | Save the API key to profile config |
|
|
217
239
|
|
|
240
|
+
`me api-keys update` supports: `--name`, `--policy-id` (use `null` to unbind), `--origins`, `--rate-limit`, `--dpop-required` / `--no-dpop-required`, `--active`, `--inactive`.
|
|
241
|
+
|
|
218
242
|
```bash
|
|
219
|
-
# Create an API key and save to config
|
|
220
|
-
geonic me api-keys create --name my-app --
|
|
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
|
|
221
245
|
|
|
222
246
|
# Create from JSON
|
|
223
|
-
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
|
|
224
254
|
```
|
|
225
255
|
|
|
226
256
|
`me api-keys list` output includes a `dpopRequired` field (boolean).
|
|
227
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
|
+
|
|
228
289
|
### entities — Manage context entities
|
|
229
290
|
|
|
230
291
|
| Subcommand | Description |
|
|
@@ -392,6 +453,25 @@ Temporal entityOperations query supports: `--aggr-methods`, `--aggr-period`.
|
|
|
392
453
|
| `admin policies activate <id>` | Activate a policy |
|
|
393
454
|
| `admin policies deactivate <id>` | Deactivate a policy |
|
|
394
455
|
|
|
456
|
+
**XACML Authorization Model**: All authorization is unified under XACML policies. Default role policies:
|
|
457
|
+
|
|
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 |
|
|
463
|
+
|
|
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.
|
|
474
|
+
|
|
395
475
|
#### admin oauth-clients
|
|
396
476
|
|
|
397
477
|
| Subcommand | Description |
|
|
@@ -412,9 +492,11 @@ Temporal entityOperations query supports: `--aggr-methods`, `--aggr-period`.
|
|
|
412
492
|
| `admin api-keys update <keyId> [json]` | Update an API key |
|
|
413
493
|
| `admin api-keys delete <keyId>` | Delete an API key |
|
|
414
494
|
|
|
415
|
-
`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`.
|
|
496
|
+
|
|
497
|
+
**Policy**: Use `--policy <policyId>` to attach an existing XACML policy to the API key. Manage policies with `geonic admin policies` commands.
|
|
416
498
|
|
|
417
|
-
**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).
|
|
418
500
|
|
|
419
501
|
#### admin cadde
|
|
420
502
|
|
|
@@ -560,19 +642,18 @@ geonic entities list --api-key gdb_your_api_key_here
|
|
|
560
642
|
GDB_API_KEY=gdb_your_api_key_here geonic entities list
|
|
561
643
|
```
|
|
562
644
|
|
|
563
|
-
When both a Bearer token and an API key are configured,
|
|
564
|
-
|
|
565
|
-
### Valid Scopes
|
|
645
|
+
When both a Bearer token and an API key are configured, headers are sent exclusively — the API key takes precedence when present.
|
|
566
646
|
|
|
567
|
-
|
|
647
|
+
### Authorization Model
|
|
568
648
|
|
|
569
|
-
|
|
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.
|
|
570
650
|
|
|
571
|
-
|
|
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`.
|
|
572
653
|
|
|
573
|
-
|
|
654
|
+
See the [admin policies](#admin-policies) section for details on the XACML authorization model, default role policies, and target resource attributes.
|
|
574
655
|
|
|
575
|
-
|
|
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.
|
|
576
657
|
|
|
577
658
|
## Development
|
|
578
659
|
|