-
Notifications
You must be signed in to change notification settings - Fork 9
docs: fixes from skills#81 #662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,8 +39,8 @@ rest: | |
|
|
||
| This section describes the **default table Resource** — the endpoints Harper registers automatically for a table, with no handler code of your own. Harper serves that default Resource only when **both** of the following are true: | ||
|
|
||
| 1. The table is exported in a schema definition with [`@export`](../database/schema.md#export). | ||
| 2. REST is enabled for the application — normally `rest: true` in `config.yaml` (see [Configuration](#configuration)); a component directory with **no configuration file at all** gets it from Harper's built-in default instead, as described below. | ||
| 1. The table is exported in a schema definition with [`@export`](../database/schema.md#export). This is always required. | ||
| 2. REST is enabled for the application. `rest: true` must be present in `config.yaml` **whenever a configuration file exists** (see [Configuration](#configuration)); a component directory with no configuration file at all inherits `rest` from Harper's built-in default instead, as described below. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fallback behavior of inheriting For example: 2. REST is enabled for the application. `rest: true` must be present in `config.yaml` **whenever a configuration file exists** (see [Configuration](#configuration)). A component directory with no configuration file at all inherits `rest` from Harper's built-in default instead, as described below.References
|
||
|
|
||
| ```graphql | ||
| # schema.graphql | ||
|
|
@@ -58,7 +58,7 @@ graphqlSchema: | |
| rest: true | ||
| ``` | ||
|
|
||
| Neither half is sufficient on its own. Without `@export` Harper registers no default Resource for the table, so it has no REST route and callers get `404`. Without REST enabled the REST handler is never registered for the application, so even an exported table does not respond to HTTP requests. | ||
| Neither half is sufficient on its own. Without `@export` Harper registers no default Resource for the table, so it has no REST route and callers get `404`. Without REST enabled the REST handler is never registered for the application, so even an exported table does not respond to HTTP requests. Writing `rest: true` is what enables it in a `config.yaml` — the only way REST is enabled without that line is the no-configuration-file case below. | ||
|
|
||
| `@export` is how the **table itself** claims the URL. When a JavaScript subclass of `tables.MyTable` should own that URL instead, omit `@export` from the schema and export the class — the class claims the route and serves whatever it implements, and REST still has to be enabled. Leaving `@export` on the schema while also exporting a same-named subclass produces conflicting endpoints. See [Extending a Table](../resources/overview.md#extending-a-table). | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ JWT authentication uses two token types: | |
|
|
||
| ## Create Authentication Tokens | ||
|
|
||
| Call `create_authentication_tokens` with your Harper credentials. No `Authorization` header is required for this operation. | ||
| Call `create_authentication_tokens` with your Harper credentials. When the request carries a `username` and `password` in the body, no `Authorization` header is required — the operation authenticates from the body. Other shapes of this operation do need an authenticated caller: sending no credentials at all mints tokens for the user the request is already authenticated as, and [minting a scoped token](#scoped-tokens-inline-role) requires an authenticated `super_user`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fallback behavior regarding sending no credentials is combined with other concepts in a single sentence. To ensure readers scanning the documentation can easily find it, please present this fallback behavior in separate, distinct sentences. For example: Call `create_authentication_tokens` with your Harper credentials. When the request carries a `username` and `password` in the body, no `Authorization` header is required — the operation authenticates from the body. Other shapes of this operation do need an authenticated caller. Sending no credentials at all mints tokens for the user the request is already authenticated as. Minting a scoped token (#scoped-tokens-inline-role) requires an authenticated `super_user`.References
|
||
|
|
||
| ```json | ||
| { | ||
|
|
@@ -95,7 +95,7 @@ Available since: v5.2.0 | |
|
|
||
| A super user can mint a **scoped token**: a single JWT whose permissions are embedded in the token itself, so the bearer needs no pre-existing user or role record. This is useful for handing a limited credential (for example, read-only access) to an external service or script without provisioning it in `hdb_user`. | ||
|
|
||
| Pass `role` as an inline role-shaped object (the same `permission` structure used by [`add_role`](../users-and-roles/overview.md), including the `operations` allowlist). The request must be authenticated as a `super_user`; no `password` may be included: | ||
| Pass `role` as an inline role-shaped object (the same `permission` structure used by [`add_role`](../users-and-roles/overview.md), including the `operations` allowlist). Unlike the username/password flow above, this shape carries no credentials of its own — the **minter** must be authenticated as a `super_user`, and no `password` may be included in the body: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The critical security requirement that the minter must be authenticated as a For example: Pass `role` as an inline role-shaped object (the same `permission` structure used by [`add_role`](../users-and-roles/overview.md), including the `operations` allowlist). Unlike the username/password flow above, this shape carries no credentials of its own. The **minter** must be authenticated as a `super_user`. No `password` may be included in the body:References
|
||
|
|
||
| ```json | ||
| { | ||
|
|
@@ -115,6 +115,22 @@ Pass `role` as an inline role-shaped object (the same `permission` structure use | |
| } | ||
| ``` | ||
|
|
||
| Authenticate that request the way you would any other privileged operation — Basic Auth with a `super_user`'s credentials, or a `Bearer` `operation_token` already held by one: | ||
|
|
||
| ```bash | ||
| curl --location --request POST 'http://localhost:9925' \ | ||
| --header 'Content-Type: application/json' \ | ||
| --header 'Authorization: Basic <base64 of super_user:password>' \ | ||
| --data-raw '{ | ||
| "operation": "create_authentication_tokens", | ||
| "username": "reporting-service", | ||
| "role": { "permission": { "operations": ["read_only"] } }, | ||
| "expires_in": "7d" | ||
| }' | ||
| ``` | ||
|
|
||
| Without an authenticated `super_user` the mint is rejected with `403 Only super_user can create a token with an inline role`. From inside a component, pass the request context and `authorize: true` to [`server.operation()`](../http/api.md#serveroperationoperation-context-authorize) so the mint is attributed to — and permission-checked against — the calling user. | ||
|
|
||
| Response: | ||
|
|
||
| ```json | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code example uses
logger.errorin the catch block, butloggeris not imported from'harper'. Sinceloggeris a package export of'harper', omitting it will result in aReferenceErrorat runtime when an error is caught. Please addloggerto the imported members.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger is available in the globals, though