@codyswann/lisa 2.168.0 → 2.170.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/package.json +1 -1
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/skills/harper-auth/SKILL.md +320 -0
- package/plugins/lisa-harper-fabric/skills/harper-auth/agents/openai.yaml +4 -0
- package/plugins/lisa-harper-fabric/skills/harper-operations/SKILL.md +239 -0
- package/plugins/lisa-harper-fabric/skills/harper-operations/agents/openai.yaml +4 -0
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/skills/harper-auth/SKILL.md +320 -0
- package/plugins/lisa-harper-fabric-agy/skills/harper-operations/SKILL.md +239 -0
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/skills/harper-auth/SKILL.md +320 -0
- package/plugins/lisa-harper-fabric-copilot/skills/harper-operations/SKILL.md +239 -0
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/skills/harper-auth/SKILL.md +320 -0
- package/plugins/lisa-harper-fabric-cursor/skills/harper-operations/SKILL.md +239 -0
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/src/harper-fabric/skills/harper-auth/SKILL.md +320 -0
- package/plugins/src/harper-fabric/skills/harper-operations/SKILL.md +239 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: harper-operations
|
|
3
|
+
description: This skill should be used when operating, monitoring, or debugging a Harper (HarperDB/Fabric) component after it builds or deploys - Operations API calls, component inventory, log retrieval, health checks, job lookup, local 500 debugging, and escalation boundaries. Pairs with harper-build-and-deploy, harper-config-yaml, harper-resources, and harper-rest-queries.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Harper Operations
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Use Harper's Operations API when the app built or deployed but runtime behavior is
|
|
11
|
+
unknown: a REST endpoint returns 500, a component did not load, logs show worker
|
|
12
|
+
errors, a table shape differs from the expected schema, or a deploy job needs to be
|
|
13
|
+
checked. The Operations API is the administrative surface; application REST
|
|
14
|
+
endpoints are the user-facing data/resource surface.
|
|
15
|
+
|
|
16
|
+
Cross-check deploy packaging and Fabric topology in [[harper-build-and-deploy]].
|
|
17
|
+
Cross-check active extensions and config replacement behavior in
|
|
18
|
+
[[harper-config-yaml]]. Cross-check custom Resource method ownership in
|
|
19
|
+
[[harper-resources]] and query shape in [[harper-rest-queries]].
|
|
20
|
+
|
|
21
|
+
## Endpoint, auth, and request shape
|
|
22
|
+
|
|
23
|
+
Operations API requests are JSON `POST` requests to the operations endpoint. Harper
|
|
24
|
+
listens on port `9925` at the root path by default:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
curl -sS http://<harper-host>:9925/ \
|
|
28
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
29
|
+
-H 'Content-Type: application/json' \
|
|
30
|
+
--data '{"operation":"system_information"}'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
For local development:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
curl -sS http://localhost:9925/ \
|
|
37
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
38
|
+
-H 'Content-Type: application/json' \
|
|
39
|
+
--data '{"operation":"get_components"}'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Authentication options:
|
|
43
|
+
|
|
44
|
+
- Basic auth: `Authorization: Basic ...`, or `curl -u "$USER:$PASS"`.
|
|
45
|
+
- JWT operation token: `Authorization: Bearer <token>` from
|
|
46
|
+
`create_authentication_tokens`.
|
|
47
|
+
- CLI: `harper login <target>` for persistent remote auth, or environment
|
|
48
|
+
credentials such as `HARPER_CLI_USERNAME` / `HARPER_CLI_PASSWORD`.
|
|
49
|
+
|
|
50
|
+
Most operational reads require a `super_user` or a role explicitly allowed to run
|
|
51
|
+
the named operation. If an operation is denied, check role `operations` permissions
|
|
52
|
+
before assuming the endpoint or component is broken.
|
|
53
|
+
|
|
54
|
+
## High-value operations
|
|
55
|
+
|
|
56
|
+
| Operation | Use it for | Example |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| `get_components` | Confirm component names, files, and configuration loaded from `harper-config.yaml`. | `{"operation":"get_components"}` |
|
|
59
|
+
| `describe_all` | See all database/table definitions and record counts visible to the caller. | `{"operation":"describe_all"}` |
|
|
60
|
+
| `describe_table` | Confirm table/database names, attributes, and primary key shape. | `{"operation":"describe_table","database":"data","table":"Product"}` |
|
|
61
|
+
| `system_information` | Capture runtime, host, and process information for health/debug reports. | `{"operation":"system_information"}` |
|
|
62
|
+
| `read_log` | Read Harper's primary `hdb.log` with level/time/filter controls. | `{"operation":"read_log","level":"error","limit":50,"order":"desc"}` |
|
|
63
|
+
| `search_jobs_by_start_date` | Find background jobs when deploys, imports, or long operations are involved. | `{"operation":"search_jobs_by_start_date","from_date":"2026-06-16T00:00:00.000+0000","to_date":"2026-06-17T00:00:00.000+0000"}` |
|
|
64
|
+
| `get_job` | Inspect one known job id returned by a search or operation response. | `{"operation":"get_job","id":"<job-id>"}` |
|
|
65
|
+
| `get_configuration` | Find runtime paths such as `rootPath`, `componentsRoot`, ports, and logging config. | `{"operation":"get_configuration"}` |
|
|
66
|
+
|
|
67
|
+
Use CLI shortcuts when the operation only needs flat key/value arguments:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
harper get_components target="$HARPER_TARGET" json=true
|
|
71
|
+
harper describe_all target="$HARPER_TARGET" json=true
|
|
72
|
+
harper read_log target="$HARPER_TARGET" level=error limit=50 order=desc json=true
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
If the CLI cannot represent the nested request body, use `curl` against the
|
|
76
|
+
Operations API directly.
|
|
77
|
+
|
|
78
|
+
## Reading logs
|
|
79
|
+
|
|
80
|
+
`read_log` reads the primary Harper log (`hdb.log`) and is restricted to
|
|
81
|
+
`super_user` roles unless a custom role grants it. Useful parameters include
|
|
82
|
+
`level`, `from`, `until`, `limit`, `order`, and `filter`.
|
|
83
|
+
|
|
84
|
+
Recent errors:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
curl -sS "$HARPER_TARGET" \
|
|
88
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
89
|
+
-H 'Content-Type: application/json' \
|
|
90
|
+
--data '{
|
|
91
|
+
"operation": "read_log",
|
|
92
|
+
"level": "error",
|
|
93
|
+
"limit": 50,
|
|
94
|
+
"order": "desc"
|
|
95
|
+
}'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Filter by component, route, or correlation id:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
curl -sS "$HARPER_TARGET" \
|
|
102
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
103
|
+
-H 'Content-Type: application/json' \
|
|
104
|
+
--data '{
|
|
105
|
+
"operation": "read_log",
|
|
106
|
+
"filter": "orders",
|
|
107
|
+
"from": "2026-06-16 00:00:00",
|
|
108
|
+
"limit": 100,
|
|
109
|
+
"order": "desc"
|
|
110
|
+
}'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
In local `harper dev`, also watch the terminal output. The dev command restarts
|
|
114
|
+
worker threads on file changes and prints console/log output close to the failing
|
|
115
|
+
request. Use `harper run` or a deployed local instance when you need to restart the
|
|
116
|
+
main thread, not only workers.
|
|
117
|
+
|
|
118
|
+
## Logging from Resources
|
|
119
|
+
|
|
120
|
+
For Resource methods, log enough to identify the request path, authenticated user
|
|
121
|
+
or tenant id, and failing branch without emitting secrets or whole request bodies.
|
|
122
|
+
Prefer structured, searchable messages:
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
export class Orders extends tables.Orders {
|
|
126
|
+
static async post(data, context) {
|
|
127
|
+
const input = await data;
|
|
128
|
+
console.info('orders.post received', {
|
|
129
|
+
orderId: input.id,
|
|
130
|
+
userId: context.user?.id,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
return await super.post(input, context);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console.error('orders.post failed', {
|
|
137
|
+
orderId: input.id,
|
|
138
|
+
message: error?.message,
|
|
139
|
+
});
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Guidance:
|
|
147
|
+
|
|
148
|
+
- Use `console.info` or `console.debug` for normal trace points, and
|
|
149
|
+
`console.warn` / `console.error` for actionable failures.
|
|
150
|
+
- Never log passwords, tokens, cookies, API keys, raw Authorization headers, or
|
|
151
|
+
full personal data payloads.
|
|
152
|
+
- Include a request id or deterministic entity id when the caller can provide one.
|
|
153
|
+
- Remove noisy temporary logs once the root cause is fixed, or lower them to debug.
|
|
154
|
+
|
|
155
|
+
## Debugging a 500 endpoint
|
|
156
|
+
|
|
157
|
+
When a deployed REST endpoint returns 500, follow this path before changing code:
|
|
158
|
+
|
|
159
|
+
1. Identify the exact endpoint, method, payload, authenticated user, target URL,
|
|
160
|
+
and timestamp. Save a reproducible `curl` command with headers scrubbed.
|
|
161
|
+
2. Confirm the component is installed and named as expected:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
harper get_components target="$HARPER_TARGET" json=true
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
3. Read recent errors around the failing timestamp:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
harper read_log target="$HARPER_TARGET" level=error limit=100 order=desc json=true
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
4. Check table/resource shape when the failure mentions a missing table, attribute,
|
|
174
|
+
index, relationship, or schema directive:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
curl -sS "$HARPER_TARGET" \
|
|
178
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
179
|
+
-H 'Content-Type: application/json' \
|
|
180
|
+
--data '{"operation":"describe_all"}'
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
5. Reproduce locally with the same built artifact path:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
bun run build
|
|
187
|
+
harper dev harper-app
|
|
188
|
+
curl -i http://localhost:9926/<project>/<resource-path>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
6. Isolate the smallest Resource method or table call involved. If the route uses a
|
|
192
|
+
custom Resource, call its underlying table/search operation directly when safe,
|
|
193
|
+
then add one temporary log at the branch boundary that chooses the failing path.
|
|
194
|
+
7. Fix source files, not generated deploy artifacts. Rebuild and repeat the same
|
|
195
|
+
local `curl`, then repeat the deployed smoke path after redeploy.
|
|
196
|
+
|
|
197
|
+
Treat the incident as unresolved until the same request path returns the expected
|
|
198
|
+
status and the logs no longer show the error.
|
|
199
|
+
|
|
200
|
+
## Health and deploy checks
|
|
201
|
+
|
|
202
|
+
After deploy or restart, check:
|
|
203
|
+
|
|
204
|
+
- Component inventory: `get_components` includes the expected project and files.
|
|
205
|
+
- System/runtime info: `system_information` returns from the target node.
|
|
206
|
+
- Configuration: `get_configuration` shows the expected operations/API ports,
|
|
207
|
+
`rootPath`, `componentsRoot`, and logging configuration.
|
|
208
|
+
- Schema/data shape: `describe_all` or `describe_table` matches the expected
|
|
209
|
+
database/table definitions and exported tables.
|
|
210
|
+
- Logs: `read_log` has no new error entries for the deploy/restart window.
|
|
211
|
+
- Jobs: `search_jobs_by_start_date` and `get_job` show background work completed
|
|
212
|
+
when deploy, import, backup, or long-running data operations were involved.
|
|
213
|
+
- Public smoke: the project-specific HTTP smoke command passes from the same route
|
|
214
|
+
users will hit. For Fabric, verify through the public route and any direct
|
|
215
|
+
node/region route the project exposes.
|
|
216
|
+
|
|
217
|
+
## What is not available
|
|
218
|
+
|
|
219
|
+
Do not invent observability that the target does not expose:
|
|
220
|
+
|
|
221
|
+
- If there is no Fabric credential or operations role, you cannot prove remote
|
|
222
|
+
component state; ask for credentials or a trusted operator readback.
|
|
223
|
+
- If the app does not emit a request id, logs may not be attributable to one HTTP
|
|
224
|
+
request. Reproduce in a narrow time window or add a safe correlation id first.
|
|
225
|
+
- If a Fabric project hides direct node/region URLs, verify through the public
|
|
226
|
+
route and record that node-level proof is unavailable.
|
|
227
|
+
- If Harper returns an auth/permission denial for `read_log`,
|
|
228
|
+
`system_information`, or component operations, treat it as an access blocker,
|
|
229
|
+
not as evidence that logs or components are empty.
|
|
230
|
+
- Third-party APM, trace collection, and performance tuning are outside this
|
|
231
|
+
skill. Capture Harper-native facts first, then escalate to the project's
|
|
232
|
+
runbook or platform owner.
|
|
233
|
+
|
|
234
|
+
## Sources
|
|
235
|
+
|
|
236
|
+
- [Operations API Overview](https://docs.harperdb.io/reference/v5/operations-api/overview)
|
|
237
|
+
- [Operations Reference](https://docs.harperdb.io/reference/v5/operations-api/operations)
|
|
238
|
+
- [Logging Operations](https://docs.harperdb.io/reference/v5/logging/operations)
|
|
239
|
+
- [Applications / Component Operations](https://docs.harperdb.io/reference/v5/components/applications)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
display_name: "Harper Operations"
|
|
2
|
+
short_description: "operating, monitoring, or debugging a Harper (HarperDB/Fabric) component after it builds or deploys - Operations API calls, component…"
|
|
3
|
+
default_prompt:
|
|
4
|
+
- "Use $harper-operations: operating, monitoring, or debugging a Harper (HarperDB/Fabric) component after it builds or deploys - Operations API calls, component…."
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: harper-auth
|
|
3
|
+
description: This skill should be used when adding or debugging Harper (HarperDB/Fabric) authentication and authorization - roles.yaml, user and role Operations API calls, Basic auth, JWT operation tokens, exported-resource permissions, and Resource context.user checks. Pairs with harper-config-yaml, harper-resources, harper-rest-queries, and harper-operations.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Harper Auth
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Harper uses role-based access control. Every user has one role, and that role
|
|
11
|
+
decides which databases, tables, attributes, and operations the user can access.
|
|
12
|
+
Use declarative `roles.yaml` for application-owned roles and the Operations API
|
|
13
|
+
for environment-owned users, password changes, role audits, and token issuance.
|
|
14
|
+
|
|
15
|
+
Cross-check extension wiring in [[harper-config-yaml]] before editing roles:
|
|
16
|
+
custom `config.yaml` files replace Harper's default config, so `roles` must be
|
|
17
|
+
re-declared alongside `rest`, `graphqlSchema`, and `jsResource` when the app needs
|
|
18
|
+
all of them. Cross-check endpoint/resource behavior in [[harper-resources]] and
|
|
19
|
+
query filters in [[harper-rest-queries]].
|
|
20
|
+
|
|
21
|
+
## Role model
|
|
22
|
+
|
|
23
|
+
Harper has built-in roles and custom roles:
|
|
24
|
+
|
|
25
|
+
| Role type | Use it for | Notes |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| `super_user` | Operators, deploy automation, emergency admin work | Full access to operations and data. Do not use for app clients. |
|
|
28
|
+
| `structure_user` | Schema/database administration without full data access | Scope narrowly when used; normal app users usually should not need it. |
|
|
29
|
+
| Custom role | Application clients, readers, editors, service accounts | Permissions are explicit. Missing database/table entries mean no access. |
|
|
30
|
+
|
|
31
|
+
Prefer least-privilege custom roles for application traffic. A public read client,
|
|
32
|
+
an editor/admin client, and a deploy/operator client should normally be separate
|
|
33
|
+
users with separate roles.
|
|
34
|
+
|
|
35
|
+
## Enable role files
|
|
36
|
+
|
|
37
|
+
Keep roles in the component root, typically `harper-app/roles.yaml`, and enable
|
|
38
|
+
the built-in `roles` extension in `harper-app/config.yaml`:
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
rest: true
|
|
42
|
+
graphqlSchema:
|
|
43
|
+
files: 'schema.graphql'
|
|
44
|
+
roles:
|
|
45
|
+
files: 'roles.yaml'
|
|
46
|
+
jsResource:
|
|
47
|
+
files: 'resources.js'
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Because `config.yaml` is not merged with Harper's defaults, keep every extension
|
|
51
|
+
the component needs in this file. Removing `roles` silently stops role-file
|
|
52
|
+
reconciliation; removing `rest` or `jsResource` can make the secured endpoint
|
|
53
|
+
disappear while the role still exists.
|
|
54
|
+
|
|
55
|
+
## Declare roles in `roles.yaml`
|
|
56
|
+
|
|
57
|
+
Use `roles.yaml` for roles that should be versioned with the app. On startup,
|
|
58
|
+
Harper creates missing declared roles and updates existing declared roles to match
|
|
59
|
+
the file.
|
|
60
|
+
|
|
61
|
+
Example: public readers can read orders, but only admins can write:
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
public_reader:
|
|
65
|
+
super_user: false
|
|
66
|
+
app:
|
|
67
|
+
Orders:
|
|
68
|
+
read: true
|
|
69
|
+
insert: false
|
|
70
|
+
update: false
|
|
71
|
+
delete: false
|
|
72
|
+
attributes:
|
|
73
|
+
id:
|
|
74
|
+
read: true
|
|
75
|
+
status:
|
|
76
|
+
read: true
|
|
77
|
+
publicTotal:
|
|
78
|
+
read: true
|
|
79
|
+
|
|
80
|
+
order_admin:
|
|
81
|
+
super_user: false
|
|
82
|
+
app:
|
|
83
|
+
Orders:
|
|
84
|
+
read: true
|
|
85
|
+
insert: true
|
|
86
|
+
update: true
|
|
87
|
+
delete: false
|
|
88
|
+
attributes:
|
|
89
|
+
internalNotes:
|
|
90
|
+
read: true
|
|
91
|
+
insert: true
|
|
92
|
+
update: true
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Rules:
|
|
96
|
+
|
|
97
|
+
- Database keys such as `app` must match the database names in `schema.graphql`.
|
|
98
|
+
- Table keys such as `Orders` must match the table type names, not necessarily the
|
|
99
|
+
exported REST path.
|
|
100
|
+
- Table-level `read`, `insert`, `update`, and `delete` are the outer gate.
|
|
101
|
+
- Attribute permissions narrow field-level access. They cannot grant a capability
|
|
102
|
+
that the table-level permission denies.
|
|
103
|
+
- If a database or table is omitted from the role, that role has no access to it.
|
|
104
|
+
|
|
105
|
+
Use role files for stable app permissions. Use Operations API calls when changing
|
|
106
|
+
users, rotating credentials, or inspecting what the deployed system actually has.
|
|
107
|
+
|
|
108
|
+
## Manage users and roles with Operations API
|
|
109
|
+
|
|
110
|
+
User and role mutations require a `super_user` caller. Send JSON `POST` requests
|
|
111
|
+
to the Operations API, usually port `9925` locally:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
curl -sS http://localhost:9925/ \
|
|
115
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
116
|
+
-H 'Content-Type: application/json' \
|
|
117
|
+
--data '{"operation":"list_roles"}'
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Create a user for a declared role:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
curl -sS http://localhost:9925/ \
|
|
124
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
125
|
+
-H 'Content-Type: application/json' \
|
|
126
|
+
--data '{
|
|
127
|
+
"operation": "add_user",
|
|
128
|
+
"username": "public-client",
|
|
129
|
+
"password": "replace-with-generated-secret",
|
|
130
|
+
"role": "public_reader",
|
|
131
|
+
"active": true
|
|
132
|
+
}'
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Change a user's role or password:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
curl -sS http://localhost:9925/ \
|
|
139
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
140
|
+
-H 'Content-Type: application/json' \
|
|
141
|
+
--data '{
|
|
142
|
+
"operation": "alter_user",
|
|
143
|
+
"username": "public-client",
|
|
144
|
+
"role": "order_admin",
|
|
145
|
+
"active": true
|
|
146
|
+
}'
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Remove a user before removing a role:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
curl -sS http://localhost:9925/ \
|
|
153
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
154
|
+
-H 'Content-Type: application/json' \
|
|
155
|
+
--data '{"operation":"drop_user","username":"public-client"}'
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Avoid committing real passwords, tokens, or generated secrets. For local examples,
|
|
159
|
+
use environment variables or throwaway development credentials.
|
|
160
|
+
|
|
161
|
+
## Basic auth and JWT operation tokens
|
|
162
|
+
|
|
163
|
+
Harper accepts Basic auth for Operations API and secured REST calls:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
curl -i http://localhost:9926/app/orders/ \
|
|
167
|
+
-u "$PUBLIC_USERNAME:$PUBLIC_PASSWORD"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
For clients that should not send Basic auth on every request, create JWT tokens
|
|
171
|
+
with `create_authentication_tokens`. This operation is intentionally unauthenticated
|
|
172
|
+
but requires the target username and password:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
tokens="$(
|
|
176
|
+
curl -sS http://localhost:9925/ \
|
|
177
|
+
-H 'Content-Type: application/json' \
|
|
178
|
+
--data '{
|
|
179
|
+
"operation": "create_authentication_tokens",
|
|
180
|
+
"username": "'"$PUBLIC_USERNAME"'",
|
|
181
|
+
"password": "'"$PUBLIC_PASSWORD"'"
|
|
182
|
+
}'
|
|
183
|
+
)"
|
|
184
|
+
|
|
185
|
+
operation_token="$(jq -r '.operation_token' <<<"$tokens")"
|
|
186
|
+
refresh_token="$(jq -r '.refresh_token' <<<"$tokens")"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Use the operation token as a bearer token:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
curl -i http://localhost:9926/app/orders/ \
|
|
193
|
+
-H "Authorization: Bearer $operation_token"
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Refresh an expired operation token with the refresh token:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
curl -sS http://localhost:9925/ \
|
|
200
|
+
-H 'Content-Type: application/json' \
|
|
201
|
+
-H "Authorization: Bearer $refresh_token" \
|
|
202
|
+
--data '{"operation": "refresh_operation_token"}'
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Treat operation tokens and refresh tokens as credentials. Never log them, commit
|
|
206
|
+
them, paste them into tickets, or store them in browser-accessible app config.
|
|
207
|
+
|
|
208
|
+
## Exported resources and `context.user`
|
|
209
|
+
|
|
210
|
+
Exported tables and custom Resources inherit the caller's role permissions.
|
|
211
|
+
If a role cannot read or write the underlying table, Harper should deny the REST
|
|
212
|
+
or GraphQL request before app logic treats it as successful.
|
|
213
|
+
|
|
214
|
+
Use custom Resource checks when the rule depends on request identity, tenant
|
|
215
|
+
ownership, or business state that is not expressible in `roles.yaml`:
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
218
|
+
export class Orders extends tables.Orders {
|
|
219
|
+
static async post(target, data, context) {
|
|
220
|
+
const user = context.user;
|
|
221
|
+
if (!user) {
|
|
222
|
+
const error = new Error('Authentication required');
|
|
223
|
+
error.statusCode = 401;
|
|
224
|
+
throw error;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (user.role !== 'order_admin') {
|
|
228
|
+
const error = new Error('Forbidden');
|
|
229
|
+
error.statusCode = 403;
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return super.post(target, await data, context);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Pass `context` through when delegating to tables or other resources:
|
|
239
|
+
|
|
240
|
+
```javascript
|
|
241
|
+
await tables.OrderEvents.post(
|
|
242
|
+
target,
|
|
243
|
+
{
|
|
244
|
+
orderId,
|
|
245
|
+
type: 'created',
|
|
246
|
+
createdBy: context.user?.username,
|
|
247
|
+
},
|
|
248
|
+
context,
|
|
249
|
+
);
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Guidance:
|
|
253
|
+
|
|
254
|
+
- Use `roles.yaml` for coarse table/attribute access and Resource logic for
|
|
255
|
+
request-specific policy.
|
|
256
|
+
- Do not trust client-provided role, user id, tenant id, or permission claims.
|
|
257
|
+
Read identity from `context.user`.
|
|
258
|
+
- Do not put `context` in module-level state; it belongs to one request.
|
|
259
|
+
- Do not use `requestWithoutAuthentication` for normal application routes. If a
|
|
260
|
+
webhook must bypass Harper auth, verify its signature first and keep its table
|
|
261
|
+
writes narrowly scoped.
|
|
262
|
+
|
|
263
|
+
## Verification matrix
|
|
264
|
+
|
|
265
|
+
Run the local app, create the test users, and check unauthenticated, reader, and
|
|
266
|
+
admin behavior against the same endpoint:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
harper dev harper-app
|
|
270
|
+
|
|
271
|
+
# Unauthenticated request should be denied.
|
|
272
|
+
curl -i http://localhost:9926/app/orders/
|
|
273
|
+
|
|
274
|
+
# Reader can read.
|
|
275
|
+
curl -i http://localhost:9926/app/orders/ \
|
|
276
|
+
-u "$PUBLIC_USERNAME:$PUBLIC_PASSWORD"
|
|
277
|
+
|
|
278
|
+
# Reader cannot write.
|
|
279
|
+
curl -i -X POST http://localhost:9926/app/orders/ \
|
|
280
|
+
-u "$PUBLIC_USERNAME:$PUBLIC_PASSWORD" \
|
|
281
|
+
-H 'Content-Type: application/json' \
|
|
282
|
+
--data '{"id":"ord_1","status":"new"}'
|
|
283
|
+
|
|
284
|
+
# Admin can write.
|
|
285
|
+
curl -i -X POST http://localhost:9926/app/orders/ \
|
|
286
|
+
-u "$ADMIN_USERNAME:$ADMIN_PASSWORD" \
|
|
287
|
+
-H 'Content-Type: application/json' \
|
|
288
|
+
--data '{"id":"ord_1","status":"new"}'
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Expected results:
|
|
292
|
+
|
|
293
|
+
| Caller | Read | Write |
|
|
294
|
+
| --- | --- | --- |
|
|
295
|
+
| No credentials | `401` or auth denial | `401` or auth denial |
|
|
296
|
+
| `public_reader` | `200` | `403` or permission denial |
|
|
297
|
+
| `order_admin` | `200` | `200` or expected validation response |
|
|
298
|
+
|
|
299
|
+
Also verify metadata with a restricted user when debugging permissions:
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
curl -sS http://localhost:9925/ \
|
|
303
|
+
-u "$PUBLIC_USERNAME:$PUBLIC_PASSWORD" \
|
|
304
|
+
-H 'Content-Type: application/json' \
|
|
305
|
+
--data '{"operation":"user_info"}'
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
If the status code is unexpected, check in this order:
|
|
309
|
+
|
|
310
|
+
1. `config.yaml` still enables `roles`, `rest`, `graphqlSchema`, and `jsResource`.
|
|
311
|
+
2. `roles.yaml` database/table names match the schema.
|
|
312
|
+
3. The user is active and assigned to the intended role.
|
|
313
|
+
4. The route being tested is the exported table/resource path you meant to secure.
|
|
314
|
+
5. Resource code passes `context` through to `super` and nested table calls.
|
|
315
|
+
|
|
316
|
+
## Sources
|
|
317
|
+
|
|
318
|
+
- [Users & Roles Configuration](https://docs.harperdb.io/reference/v5/users-and-roles/configuration)
|
|
319
|
+
- [Operations Reference](https://docs.harperdb.io/reference/v5/operations-api/operations)
|
|
320
|
+
- [Components Overview](https://docs.harperdb.io/reference/v5/components/overview)
|