@harperfast/template-vue-studio 1.13.6 → 1.13.7
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/.agents/skills/harper-best-practices/AGENTS.md +1260 -1113
- package/.agents/skills/harper-best-practices/rules/automatic-apis.md +118 -83
- package/.agents/skills/harper-best-practices/rules/checking-authentication.md +244 -256
- package/.agents/skills/harper-best-practices/rules/custom-resources.md +37 -42
- package/.agents/skills/harper-best-practices/rules/defining-relationships.md +86 -49
- package/.agents/skills/harper-best-practices/rules/deploying-from-ci.md +163 -170
- package/.agents/skills/harper-best-practices/rules/deploying-to-harper-fabric.md +128 -88
- package/.agents/skills/harper-best-practices/rules/load-env.md +27 -30
- package/.agents/skills/harper-best-practices/rules/programmatic-table-requests.md +184 -155
- package/.agents/skills/harper-best-practices/rules/querying-rest-apis.md +146 -94
- package/.agents/skills/harper-best-practices/rules/schema-design-tooling.md +60 -77
- package/.agents/skills/harper-best-practices/rules/v5-upgrade.md +52 -63
- package/.agents/skills/harper-best-practices/rules/vector-indexing.md +77 -68
- package/.agents/skills/harper-mcp/AGENTS.md +228 -155
- package/.agents/skills/harper-mcp/rules/custom-mcp-tools.md +35 -41
- package/.agents/skills/harper-mcp/rules/enabling-mcp.md +104 -92
- package/.agents/skills/harper-mcp/rules/rate-limiting.md +95 -28
- package/agent/skills/harper-best-practices/AGENTS.md +1260 -1113
- package/agent/skills/harper-best-practices/rules/automatic-apis.md +118 -83
- package/agent/skills/harper-best-practices/rules/checking-authentication.md +244 -256
- package/agent/skills/harper-best-practices/rules/custom-resources.md +37 -42
- package/agent/skills/harper-best-practices/rules/defining-relationships.md +86 -49
- package/agent/skills/harper-best-practices/rules/deploying-from-ci.md +163 -170
- package/agent/skills/harper-best-practices/rules/deploying-to-harper-fabric.md +128 -88
- package/agent/skills/harper-best-practices/rules/load-env.md +27 -30
- package/agent/skills/harper-best-practices/rules/programmatic-table-requests.md +184 -155
- package/agent/skills/harper-best-practices/rules/querying-rest-apis.md +146 -94
- package/agent/skills/harper-best-practices/rules/schema-design-tooling.md +60 -77
- package/agent/skills/harper-best-practices/rules/v5-upgrade.md +52 -63
- package/agent/skills/harper-best-practices/rules/vector-indexing.md +77 -68
- package/agent/skills/harper-mcp/AGENTS.md +228 -155
- package/agent/skills/harper-mcp/rules/custom-mcp-tools.md +35 -41
- package/agent/skills/harper-mcp/rules/enabling-mcp.md +104 -92
- package/agent/skills/harper-mcp/rules/rate-limiting.md +95 -28
- package/package.json +1 -1
- package/skills-lock.json +2 -2
|
@@ -19,8 +19,8 @@ metadata:
|
|
|
19
19
|
- reference/v5/security/jwt-authentication.md#Token Expiry Configuration
|
|
20
20
|
- reference/v5/security/jwt-authentication.md#When to Use JWT Auth
|
|
21
21
|
- reference/v5/security/jwt-authentication.md#Security Notes
|
|
22
|
-
sourceCommit:
|
|
23
|
-
inputHash:
|
|
22
|
+
sourceCommit: 9628b6ae7649c6f6ba4d65465e83cf75d7a9b2bd
|
|
23
|
+
inputHash: e8b7023b3a3ba2b5
|
|
24
24
|
---
|
|
25
25
|
|
|
26
26
|
# Checking Authentication
|
|
@@ -31,250 +31,248 @@ Instructions for the agent to handle user authentication, sessions, and JWT toke
|
|
|
31
31
|
|
|
32
32
|
## When to Use
|
|
33
33
|
|
|
34
|
-
Apply this rule when implementing
|
|
34
|
+
Apply this rule when implementing sign-in/sign-out flows, reading the current authenticated user, issuing or refreshing JWT tokens, or minting scoped tokens from a custom Resource. Use it whenever a Resource must inspect, establish, or delegate authentication state. See [custom-resources.md](custom-resources.md) for the broader Resource authoring context.
|
|
35
35
|
|
|
36
36
|
## How It Works
|
|
37
37
|
|
|
38
|
-
###
|
|
39
|
-
|
|
40
|
-
**
|
|
41
|
-
|
|
42
|
-
**
|
|
43
|
-
|
|
44
|
-
```javascript
|
|
45
|
-
static async get(_target, context) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
- `username` is attribution only and must not name an existing user.
|
|
208
|
-
- No refresh token is issued; no user record is created.
|
|
209
|
-
- Scoped tokens cannot be revoked before expiry —
|
|
210
|
-
- `super_user` and `cluster_user` are always forced to `false` in the embedded role.
|
|
211
|
-
- In **mixed-version** clusters, only nodes with scoped-token support accept these tokens; older nodes reject them with 401.
|
|
212
|
-
|
|
213
|
-
###
|
|
214
|
-
|
|
215
|
-
Use `server.operation()` to mint tokens programmatically
|
|
216
|
-
|
|
217
|
-
```javascript
|
|
218
|
-
import { Resource, server } from 'harper';
|
|
219
|
-
|
|
220
|
-
export class IssueTokens extends Resource {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export class RefreshJWT extends Resource {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
Valid duration strings follow the `jsonwebtoken` package format (e.g., `1d`, `12h`, `60m`). The `expires_in` field on scoped token minting accepts the same format.
|
|
38
|
+
### Reading the Current User
|
|
39
|
+
|
|
40
|
+
1. **Use `getCurrentUser()` in instance methods**: Call `getCurrentUser()` on a Resource instance to get the current authenticated user, or `undefined` if no user is authenticated. The returned object exposes `username`, `role`, and `role.permission` flags.
|
|
41
|
+
|
|
42
|
+
2. **Use `context.user` in static verbs**: Static verbs receive the context as a trailing argument. Read the current authenticated user from `context?.user`:
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
static async get(_target, context) {
|
|
46
|
+
const user = context?.user;
|
|
47
|
+
if (!user) return new Response(null, { status: 401 });
|
|
48
|
+
return { username: user.username, role: user.role };
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
3. **Use `getContext()` for dual-path static methods**: `getContext()` is a Resource instance method. For static methods that must work both via HTTP and direct server-side calls, import `getContext()` from the `harper` module. Static verbs receive context as the trailing argument — `(target, context)` for `get`/`delete`, `(target, data, context)` for `put`/`patch`/`post`.
|
|
53
|
+
|
|
54
|
+
4. **Access HTTP-specific context properties**: When triggered by HTTP, the context is the `Request` object with additional properties. Use these to read request metadata or set response headers:
|
|
55
|
+
|
|
56
|
+
| Property | Description |
|
|
57
|
+
| ----------------- | -------------------------------------------------------------------------------- |
|
|
58
|
+
| `url` | Full local path including query string |
|
|
59
|
+
| `method` | HTTP method |
|
|
60
|
+
| `headers` | Request headers (`context.headers.get(name)`) |
|
|
61
|
+
| `responseHeaders` | Response headers (`context.responseHeaders.set(name, value)`) |
|
|
62
|
+
| `pathname` | Path without query string |
|
|
63
|
+
| `host` | Host from the `Host` header |
|
|
64
|
+
| `ip` | Client IP address |
|
|
65
|
+
| `body` | Raw Node.js `Readable` stream (if a request body exists) |
|
|
66
|
+
| `data` | Promise resolving to the deserialized request body |
|
|
67
|
+
| `lastModified` | Controls `ETag`/`Last-Modified` response header |
|
|
68
|
+
| `requestContext` | (Source resources only) Context of the upstream resource making the data request |
|
|
69
|
+
| `transaction` | Current transaction |
|
|
70
|
+
|
|
71
|
+
When triggered by HTTP, the context also exposes `url`, `method`, `headers`, `responseHeaders`, `pathname`, `host`, `ip`, `body`, `data`, `lastModified`, and `requestContext`.
|
|
72
|
+
|
|
73
|
+
### Session-Based Login and Logout
|
|
74
|
+
|
|
75
|
+
5. **Enable sessions in config**: Set `authentication.enableSessions: true` in `harperdb-config.yaml` before using `context.login` or `context.session`.
|
|
76
|
+
|
|
77
|
+
6. **Implement sign-in with `context.login`**: Call `context.login(username, password)` in a static `post` verb. It verifies credentials and establishes the session cookie on success:
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
export class SignIn extends Resource {
|
|
81
|
+
static async post(_target, data, context) {
|
|
82
|
+
const { username, password } = (await data) ?? {};
|
|
83
|
+
try {
|
|
84
|
+
await context.login(username, password);
|
|
85
|
+
} catch {
|
|
86
|
+
return new Response('Invalid credentials', { status: 403 });
|
|
87
|
+
}
|
|
88
|
+
return new Response('Logged in', { status: 200 });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
7. **Implement sign-out by clearing the session user**: Use `context.session.update({ user: null })` — `update` is the session's only mutator. Test `context?.session?.user` to detect an established session, because `context.session` is an empty object (not `undefined`) when sessions are enabled and no session cookie is present:
|
|
94
|
+
|
|
95
|
+
```javascript
|
|
96
|
+
export class SignOut extends Resource {
|
|
97
|
+
static async post(_target, _data, context) {
|
|
98
|
+
if (!context?.session?.user) return new Response(null, { status: 401 });
|
|
99
|
+
await context.session.update({ user: null });
|
|
100
|
+
return new Response('Logged out', { status: 200 });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Cookie-based sessions are intended for browser clients. For non-browser clients, use JWT issuance.
|
|
106
|
+
|
|
107
|
+
### JWT Token Issuance
|
|
108
|
+
|
|
109
|
+
8. **Call `create_authentication_tokens` with credentials**: Send `username` and `password` in the request body. No `Authorization` header is required when credentials are in the body:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"operation": "create_authentication_tokens",
|
|
114
|
+
"username": "username",
|
|
115
|
+
"password": "password"
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Response:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"operation_token": "<jwt-operation-token>",
|
|
124
|
+
"refresh_token": "<jwt-refresh-token>"
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
9. **Pass the `operation_token` as a Bearer token** on subsequent requests:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
curl --location --request POST 'http://localhost:9925' \
|
|
132
|
+
--header 'Content-Type: application/json' \
|
|
133
|
+
--header 'Authorization: Bearer <operation_token>' \
|
|
134
|
+
--data-raw '{
|
|
135
|
+
"operation": "search_by_hash",
|
|
136
|
+
"schema": "dev",
|
|
137
|
+
"table": "dog",
|
|
138
|
+
"hash_values": [1],
|
|
139
|
+
"get_attributes": ["*"]
|
|
140
|
+
}'
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
10. **Refresh an expired `operation_token`** using `refresh_operation_token`. Pass the `refresh_token` as `Bearer <refresh_token>`:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
curl --location --request POST 'http://localhost:9925' \
|
|
147
|
+
--header 'Content-Type: application/json' \
|
|
148
|
+
--header 'Authorization: Bearer <refresh_token>' \
|
|
149
|
+
--data-raw '{
|
|
150
|
+
"operation": "refresh_operation_token"
|
|
151
|
+
}'
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Response:
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"operation_token": "<new-jwt-operation-token>"
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
When both tokens have expired, call `create_authentication_tokens` again with username and password.
|
|
163
|
+
|
|
164
|
+
### Scoped Tokens (Inline Role)
|
|
165
|
+
|
|
166
|
+
11. **Mint a scoped token as a `super_user`**: Pass `role` as an inline role-shaped object using the same `permission` structure as `add_role`. The minter must be authenticated as a `super_user`; no `password` may be included in the body. Use `expires_in` to set the token lifetime:
|
|
167
|
+
|
|
168
|
+
```json
|
|
169
|
+
{
|
|
170
|
+
"operation": "create_authentication_tokens",
|
|
171
|
+
"username": "reporting-service",
|
|
172
|
+
"role": {
|
|
173
|
+
"permission": {
|
|
174
|
+
"operations": ["read_only"],
|
|
175
|
+
"dev": {
|
|
176
|
+
"tables": {
|
|
177
|
+
"dog": {
|
|
178
|
+
"read": true,
|
|
179
|
+
"insert": false,
|
|
180
|
+
"update": false,
|
|
181
|
+
"delete": false,
|
|
182
|
+
"attribute_permissions": []
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"expires_in": "7d"
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Authenticate the mint request with Basic Authentication or an existing `super_user` `operation_token`:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
curl --location --request POST 'http://localhost:9925' \
|
|
196
|
+
--header 'Content-Type: application/json' \
|
|
197
|
+
--header 'Authorization: Basic <base64 of super_user:password>' \
|
|
198
|
+
--data-raw '{
|
|
199
|
+
"operation": "create_authentication_tokens",
|
|
200
|
+
"username": "reporting-service",
|
|
201
|
+
"role": { "permission": { "operations": ["read_only"] } },
|
|
202
|
+
"expires_in": "7d"
|
|
203
|
+
}'
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Key constraints:
|
|
207
|
+
- `username` is attribution only and must not name an existing user.
|
|
208
|
+
- No refresh token is issued; no user record is created.
|
|
209
|
+
- Scoped tokens cannot be revoked before expiry — prefer short lifetimes.
|
|
210
|
+
- `super_user` and `cluster_user` are always forced to `false` in the embedded role.
|
|
211
|
+
- In **mixed-version** clusters, only nodes with scoped-token support accept these tokens; older nodes reject them with a 401.
|
|
212
|
+
|
|
213
|
+
### Issuing Tokens from a Custom Resource
|
|
214
|
+
|
|
215
|
+
12. **Use `server.operation()` to mint tokens programmatically**: Import `server` from `harper` and call `server.operation(operation, context, authorize)`. Pass `authorize: true` as the **third argument** when the operation should run as the current authenticated user; omit it or pass `false` when the operation supplies its own credentials:
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
218
|
+
import { Resource, server } from 'harper';
|
|
219
|
+
|
|
220
|
+
export class IssueTokens extends Resource {
|
|
221
|
+
static async get(_target, context) {
|
|
222
|
+
// Caller is already authenticated — issue tokens for the current authenticated user.
|
|
223
|
+
const { operation_token, refresh_token } = await server.operation(
|
|
224
|
+
{ operation: 'create_authentication_tokens' },
|
|
225
|
+
context,
|
|
226
|
+
true,
|
|
227
|
+
);
|
|
228
|
+
return { operation_token, refresh_token };
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
static async post(_target, data) {
|
|
232
|
+
// Caller provides credentials in the body.
|
|
233
|
+
const { username, password } = await data;
|
|
234
|
+
if (!username || !password) {
|
|
235
|
+
return new Response('username and password required', { status: 400 });
|
|
236
|
+
}
|
|
237
|
+
const { operation_token, refresh_token } = await server.operation({
|
|
238
|
+
operation: 'create_authentication_tokens',
|
|
239
|
+
username,
|
|
240
|
+
password,
|
|
241
|
+
});
|
|
242
|
+
return { operation_token, refresh_token };
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export class RefreshJWT extends Resource {
|
|
247
|
+
static async post(_target, data) {
|
|
248
|
+
const { refresh_token } = await data;
|
|
249
|
+
if (!refresh_token) {
|
|
250
|
+
return new Response('refresh_token required', { status: 400 });
|
|
251
|
+
}
|
|
252
|
+
const { operation_token } = await server.operation({
|
|
253
|
+
operation: 'refresh_operation_token',
|
|
254
|
+
refresh_token,
|
|
255
|
+
});
|
|
256
|
+
return { operation_token };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Token Expiry Configuration
|
|
262
|
+
|
|
263
|
+
13. **Configure token timeouts** in `harper-config.yaml` under the `authentication` section:
|
|
264
|
+
|
|
265
|
+
```yaml
|
|
266
|
+
authentication:
|
|
267
|
+
operationTokenTimeout: 1d # Default: 1 day
|
|
268
|
+
refreshTokenTimeout: 30d # Default: 30 days
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Valid duration strings follow the `jsonwebtoken` package format (e.g., `1d`, `12h`, `60m`).
|
|
274
272
|
|
|
275
273
|
## Examples
|
|
276
274
|
|
|
277
|
-
### Full
|
|
275
|
+
### Full sign-in/sign-out Resource pair
|
|
278
276
|
|
|
279
277
|
```javascript
|
|
280
278
|
export class SignIn extends Resource {
|
|
@@ -298,17 +296,7 @@ export class SignOut extends Resource {
|
|
|
298
296
|
}
|
|
299
297
|
```
|
|
300
298
|
|
|
301
|
-
###
|
|
302
|
-
|
|
303
|
-
```javascript
|
|
304
|
-
static async get(_target, context) {
|
|
305
|
-
const user = context?.user;
|
|
306
|
-
if (!user) return new Response(null, { status: 401 });
|
|
307
|
-
return { username: user.username, role: user.role };
|
|
308
|
-
}
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
### Minting Tokens via cURL
|
|
299
|
+
### Minting tokens via the Operations API
|
|
312
300
|
|
|
313
301
|
```bash
|
|
314
302
|
curl --location --request POST 'http://localhost:9925' \
|
|
@@ -322,9 +310,9 @@ curl --location --request POST 'http://localhost:9925' \
|
|
|
322
310
|
|
|
323
311
|
## Notes
|
|
324
312
|
|
|
325
|
-
- JWT
|
|
313
|
+
- **JWT is preferred over Basic Auth** for clients that can store tokens, want to avoid sending credentials on every request, or make multiple sequential requests. For simple or **server-to-server** scenarios, use Basic Authentication.
|
|
326
314
|
- Always use **HTTPS** in production to protect tokens in transit.
|
|
327
|
-
- Treat tokens like passwords.
|
|
328
|
-
-
|
|
329
|
-
-
|
|
330
|
-
-
|
|
315
|
+
- Treat tokens like passwords. Because scoped tokens cannot be revoked before expiry, set short `expires_in` values in high-security environments and consider lowering `operationTokenTimeout`.
|
|
316
|
+
- A caller authenticated by a Bearer validator cannot mint tokens via the passwordless form — it must supply `username` and `password`.
|
|
317
|
+
- `enableSessions` is required in `harperdb-config.yaml` for `context.login` and `context.session` to be available.
|
|
318
|
+
- The **third argument** (`authorize: true`) to `server.operation()` attributes the operation to — and permission-checks against — the calling user.
|