Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## unreleased

- Development error pages show the failing SQL, its location, and a copyable diagnostic report. Production error pages give visitors a reference to share with the site owner.
- A table row action without a link leaves its cell empty. ([#1709](https://github.com/sqlpage/SQLPage/pull/1709))
- SQLPage reports syntax errors before running any statements in the affected SQL file. ([#1706](https://github.com/sqlpage/SQLPage/discussions/1706))
- OIDC logs focus on configuration and failures. SQLPage omits tokens, cookie values, user claims, and callback and logout query strings from OIDC diagnostics.
Expand Down
14 changes: 13 additions & 1 deletion configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Here are the available configuration options and their default values:
| `https_certificate_email` | contact@<https_domain> | The email address to use when requesting a certificate. |
| `https_certificate_cache_dir` | ./sqlpage/https | A writeable directory where to cache the certificates, so that SQLPage can serve https traffic immediately when it restarts. The default ignores `web_root` and `configuration_directory`. |
| `https_acme_directory_url` | https://acme-v02.api.letsencrypt.org/directory | The URL of the ACME directory to use when requesting a certificate. |
| `environment` | development | The environment in which SQLPage is running. Can be either `development` or `production`. In `production` mode, SQLPage will hide error messages and stack traces from the user, and will cache sql files in memory to avoid reloading them from disk. |
| `development_report_key_sha256` | none | Base64-encoded SHA-256 digest of a developer key. In development, requests bearing the matching `X-SQLPage-Report-Key` include Cookie, Authorization and Proxy-Authorization values in the copied report. Set this header only on your own diagnostic requests over HTTPS or loopback. SQLPage consumes the key before executing SQL. See [copying a development report](#copying-a-development-report). |
| `environment` | development | The environment in which SQLPage is running. Can be either `development` or `production`. Development HTML error reports include SQL source, request parameters, form values or request body, and request headers. The copy action includes each request header. Credential values are redacted unless the request supplies the configured developer key. Uploaded files are identified by field, name, and size. Production error pages show a support reference you can look up in the server logs. Production also caches SQL files in memory to avoid reloading them from disk. |
| `cache_stale_duration_ms` | 1000 (prod), 0 (dev) | The duration in milliseconds that a file can be cached before its freshness is checked against the filesystem. Defaults to 1000ms (1 second) in production and 0ms in development. |
| `content_security_policy` | `script-src 'self' 'nonce-{NONCE}'` | The [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) to set in the HTTP headers. If you get CSP errors in the browser console, you can set this to the empty string to disable CSP. If you want a custom CSP that contains a nonce, include the `'nonce-{NONCE}'` directive in your configuration string and it will be populated with a random value per request. |
| `smtp_host` | | SMTP server host used by the `sqlpage.send_mail` function. Set with `SMTP_HOST` in the environment. |
Expand Down Expand Up @@ -189,6 +190,17 @@ DATABASE_PASSWORD="my_secure_password"
SQLITE_EXTENSIONS="mod_spatialite crypto define regexp"
```

## Copying a development report

To include credential headers on a developer request, generate a random key and configure its digest before starting SQLPage.

```sh
key=$(openssl rand -hex 32)
export SQLPAGE_DEVELOPMENT_REPORT_KEY_SHA256=$(printf %s "$key" | openssl dgst -sha256 -binary | openssl base64 -A)
```

Send `X-SQLPage-Report-Key` with the original key on the request you are debugging. You can also configure a reverse proxy to supply this header on an authenticated developer route. **Copy report** includes the credential values and the original form body, including uploaded files. Binary bodies use base64. Form capture is bounded to twice `max_uploaded_file_size`. Larger form bodies are marked as omitted. Review the report before sharing it.

## Custom components

SQLPage allows you to create custom components in addition to or instead of the default ones.
Expand Down
16 changes: 8 additions & 8 deletions examples/CRUD - Authentication/test.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ HTTP 200
[Asserts]
header "Content-Type" contains "text/html"
body contains "Demo/Template CRUD with Authentication"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

# The currencies CRUD page is protected.
GET http://localhost:8080/currencies_list.sql
Expand All @@ -18,7 +18,7 @@ HTTP 200
body contains "Login"
body contains "Username"
body contains "Password"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

POST http://localhost:8080/create_session.sql?path=/currencies_list.sql
[FormParams]
Expand Down Expand Up @@ -52,23 +52,23 @@ body contains "Currencies"
body contains "New Record"
body contains "RUR"
body contains "USD"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/currencies_item_form.sql?id=1
HTTP 200
[Asserts]
body contains "Currency"
body contains "Exchange Rate to RUR"
body contains "RUR"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/currencies_item_form.sql?action=INSERT
HTTP 200
[Asserts]
body contains "Currency"
body contains "Exchange Rate to RUR"
body contains "BROWSE"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

POST http://localhost:8080/currencies_item_dml.sql?path=currencies_list.sql&action=UPDATE
[FormParams]
Expand All @@ -88,7 +88,7 @@ HTTP 200
body contains "HURLTEST"
body contains "7.89"
body htmlUnescape contains "currencies_item_form.sql?&path=/currencies_list.sql&id={{currency_id}}"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

POST http://localhost:8080/currencies_item_dml.sql?path=currencies_list.sql&action=UPDATE
[FormParams]
Expand All @@ -106,7 +106,7 @@ HTTP 200
[Asserts]
body contains "HURLEDITED"
body contains "8.91"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

POST http://localhost:8080/currencies_item_dml.sql?path=currencies_list.sql&action=DELETE
[FormParams]
Expand All @@ -122,7 +122,7 @@ GET http://localhost:8080/currencies_list.sql
HTTP 200
[Asserts]
body not contains "HURLEDITED"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/logout.sql?path=currencies_list.sql
HTTP 302
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HTTP 200
[Asserts]
body contains "Points of interest"
body contains "Add a point"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

POST http://localhost:8080/add_point.sql
[FormParams]
Expand Down Expand Up @@ -31,7 +31,7 @@ paris_id: xpath "substring-after(string(//a[normalize-space(.)='Hurl Paris']/@hr
body contains "Hurl Paris"
body contains "Hurl Lyon"
body htmlUnescape contains "point.sql?id={{paris_id}}"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/point.sql?id={{paris_id}}
HTTP 200
Expand All @@ -42,12 +42,12 @@ body contains "First Hurl point"
body contains "Closest points"
body contains "Hurl Lyon"
body htmlUnescape contains "edition_form.sql?id={{paris_id}}"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

POST http://localhost:8080/edition_form.sql?id={{paris_id}}
[FormParams]
Text: Updated Hurl point
HTTP 200
[Asserts]
body contains "Updated Hurl point"
body not contains "An error occurred"
body not contains "data-sqlpage-error"
14 changes: 7 additions & 7 deletions examples/SQLPage developer user interface/test.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ body contains "Create new file"
body contains "Database tables"
body contains "sqlpage_files"
body htmlUnescape contains "view_table.sql?table%5Fname=sqlpage%5Ffiles"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/edit.sql
HTTP 200
[Asserts]
body contains "New page"
body contains "insert_file.sql"
body contains "code-editor"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

POST http://localhost:8080/insert_file.sql
[FormParams]
Expand All @@ -29,29 +29,29 @@ GET http://localhost:8080/hurl_test.sql
HTTP 200
[Asserts]
body contains "Hello from Hurl"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/
HTTP 200
[Asserts]
body contains "hurl_test.sql"
body htmlUnescape contains "edit.sql?path=hurl%5Ftest%2Esql"
body htmlUnescape contains "delete.sql?path=hurl%5Ftest%2Esql"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/view_table.sql?table_name=sqlpage_files
HTTP 200
[Asserts]
body contains "sqlpage_files"
body contains "hurl_test.sql"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/delete.sql?path=hurl_test.sql
HTTP 200
[Asserts]
body contains "Delete hurl_test.sql ?"
body htmlUnescape contains "delete.sql?path=hurl%5Ftest%2Esql&confirm=yes"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/delete.sql?path=hurl_test.sql&confirm=yes
HTTP 302
Expand All @@ -62,4 +62,4 @@ GET http://localhost:8080/
HTTP 200
[Asserts]
body not contains "hurl_test.sql"
body not contains "An error occurred"
body not contains "data-sqlpage-error"
8 changes: 4 additions & 4 deletions examples/cards-with-remote-content/test.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ body contains "<strong>Markdown</strong>"
body htmlUnescape contains "/chart-example.sql?_sqlpage_embed"
body htmlUnescape contains "/map-example.sql?_sqlpage_embed"
body htmlUnescape contains "/table-example.sql?_sqlpage_embed"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/chart-example.sql?_sqlpage_embed
HTTP 200
[Asserts]
xpath "normalize-space(//*[contains(., 'Quarterly Revenue')])" contains "Quarterly Revenue"
body contains "2023-07-01T00:00:00Z"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/map-example.sql?_sqlpage_embed
HTTP 200
[Asserts]
body contains "New Delhi"
body contains "28.6139"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/table-example.sql?_sqlpage_embed
HTTP 200
[Asserts]
xpath "normalize-space(//*[contains(., 'Forename')])" contains "Forename"
body contains "Ophir"
body contains "Torvalds"
body not contains "An error occurred"
body not contains "data-sqlpage-error"
10 changes: 5 additions & 5 deletions examples/corporate-conundrum/test.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HTTP 200
[Asserts]
body contains "Welcome to Corporate Conundrum"
body contains "Start a New Game"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/New%20Game.sql
HTTP 302
Expand All @@ -18,7 +18,7 @@ HTTP 200
body contains "Players"
body contains "Alice"
body contains "Add a new player"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/next-question.sql?game_id={{game_id}}&player=Alice
HTTP 302
Expand All @@ -33,13 +33,13 @@ HTTP 200
[Asserts]
body contains "Submit your answer"
body contains "Your answer"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/wait.sql?game_id={{game_id}}&question_id={{question_id}}&player=Alice&answer=42
HTTP 200
[Asserts]
body contains "Waiting for other players to answer"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/next-question.sql?game_id={{game_id}}&player=Alice
HTTP 302
Expand All @@ -52,4 +52,4 @@ HTTP 200
body contains "The game is over"
body contains "Scores"
body contains "Alice"
body not contains "An error occurred"
body not contains "data-sqlpage-error"
4 changes: 2 additions & 2 deletions examples/custom form component/test.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ body contains "Available Items"
body contains "Selected Items"
body contains "John Smith"
body contains "Jane Doe"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

POST http://localhost:8080/form_action.sql
[FormParams]
Expand All @@ -20,4 +20,4 @@ body contains "sarah@email.com"
body contains "Lisa Anderson"
body contains "lisa@email.com"
body not contains "John Smith"
body not contains "An error occurred"
body not contains "data-sqlpage-error"
4 changes: 2 additions & 2 deletions examples/forms with a variable number of fields/test.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ body contains "Pass an order"
body contains "Quantity of Invisible Umbrella"
body contains "Quantity of Silent Alarm Clock"
body contains "Quantity of Pet Rock 2.0"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

POST http://localhost:8080/order_insert.sql
[FormParams]
Expand All @@ -31,4 +31,4 @@ body contains "1 x Silent Alarm Clock"
body contains "Subtotal: 1 x 49.95"
body contains "Total: 249.93 €"
body not contains "Pet Rock 2.0"
body not contains "An error occurred"
body not contains "data-sqlpage-error"
4 changes: 2 additions & 2 deletions examples/handle-404/test.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ HTTP 200
[Asserts]
body contains "Welcome to the API"
body contains "Back home"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/api/does/not/actually/exist
HTTP 200
[Asserts]
body htmlUnescape contains "\"serving_file\":\"api/404.sql\""
body htmlUnescape contains "\"request_path\":\"/api/does/not/actually/exist\""
body contains "Back home"
body not contains "An error occurred"
body not contains "data-sqlpage-error"
8 changes: 4 additions & 4 deletions examples/image gallery with user uploads/test.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ HTTP 200
header "Content-Type" contains "text/html"
body contains "My image gallery"
body contains "Upload a new image"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

# Upload form is protected.
GET http://localhost:8080/upload_form.sql
Expand All @@ -19,7 +19,7 @@ HTTP 200
body contains "Login"
body contains "Username"
body contains "Password"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

# Demo credentials from the example migration: admin/admin.
POST http://localhost:8080/create_session.sql
Expand All @@ -39,7 +39,7 @@ body contains "Upload a new image"
body contains "Title"
body contains "Description"
body contains "Image"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

POST http://localhost:8080/upload.sql
[Multipart]
Expand All @@ -58,4 +58,4 @@ HTTP 200
body contains "Hurl test image"
body contains "Uploaded by Hurl"
body contains "/images/"
body not contains "An error occurred"
body not contains "data-sqlpage-error"
4 changes: 2 additions & 2 deletions examples/light-dark-toggle/test.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ HTTP 200
body contains "Toggle Light / Dark Mode"
body contains "Categories"
body contains "☀"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/toggle.sql
Referer: http://localhost:8080/
Expand All @@ -19,7 +19,7 @@ HTTP 200
body contains "Biography"
body contains "Morbi fermentum"
body contains "data-bs-theme=\"dark\""
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/toggle.sql
Referer: http://localhost:8080/biography.sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HTTP 200
[Asserts]
body contains "Points of interest"
body contains "Add a point"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

POST http://localhost:8080/add_point.sql
[FormParams]
Expand Down Expand Up @@ -31,7 +31,7 @@ paris_id: xpath "substring-after(string(//a[normalize-space(.)='Hurl Paris']/@hr
body contains "Hurl Paris"
body contains "Hurl Lyon"
body htmlUnescape contains "point.sql?id={{paris_id}}"
body not contains "An error occurred"
body not contains "data-sqlpage-error"

GET http://localhost:8080/point.sql?id={{paris_id}}
HTTP 200
Expand All @@ -41,4 +41,4 @@ body contains "2.3522"
body contains "First Hurl point"
body contains "Closest points"
body contains "Hurl Lyon"
body not contains "An error occurred"
body not contains "data-sqlpage-error"
Loading
Loading