904 Commits

Author SHA1 Message Date
Ophir LOJKINE 083593d927 Implement secure oidc logout endpoint and sql function (#1141)
* Checkpoint before follow-up message

Co-authored-by: contact <contact@ophir.dev>

* Checkpoint before follow-up message

Co-authored-by: contact <contact@ophir.dev>

* Checkpoint before follow-up message

Co-authored-by: contact <contact@ophir.dev>

* Checkpoint before follow-up message

Co-authored-by: contact <contact@ophir.dev>

* feat: Add OIDC logout functionality

This commit introduces the `oidc_logout_url` function, allowing users to securely log out of OIDC-authenticated applications. It includes CSRF protection and handles redirection to the OIDC provider's logout endpoint.

Co-authored-by: contact <contact@ophir.dev>

* Refactor OIDC logout cookie removal

Co-authored-by: contact <contact@ophir.dev>

* feat: Implement OIDC logout with CSRF protection

This commit implements secure OIDC logout by:

- Using sqlpage.oidc_logout_url() to generate the logout URL.
- Ensuring CSRF protection during the logout process.
- Redirecting to the OIDC provider's logout endpoint.
- Redirecting back to the homepage after logout.
- Adding absolute URI for post logout redirect URI.

* refactor: Enhance build_absolute_uri function to accept scheme parameter

This commit modifies the build_absolute_uri function to include a scheme parameter, allowing for more flexible URL construction. The function now dynamically sets the URL scheme based on the request context, improving compatibility with different environments.

* refactor: Simplify OIDC logout processing and enhance logout token handling

This commit refactors the OIDC logout process by introducing a new function, `parse_logout_params`, to streamline the extraction of logout parameters from the request. It also updates the logout token creation and verification logic, improving security by ensuring the signature is computed correctly. Additionally, the `create_logout_url` function is modified to include a timestamp and signature in the generated URL, enhancing the logout flow's integrity.

* refactor: Improve logout URL generation and parameter parsing

This commit refines the `create_logout_url` function to utilize a query string builder for constructing the logout URL, enhancing readability and maintainability. Additionally, the `parse_logout_params` function is updated to use `Query::into_inner`, streamlining the extraction of logout parameters from the request.

* refactor: Streamline cookie removal in OIDC logout process

This commit simplifies the removal of authentication and nonce cookies during the OIDC logout process by consolidating the cookie removal logic into a single method call for each cookie, enhancing code clarity and maintainability.

* refactor: Enhance cookie removal logic in OIDC logout process

This commit updates the cookie removal process during OIDC logout by utilizing the `Cookie::build` method to specify cookie attributes, improving clarity and ensuring proper cookie handling.

* chore: Update CHANGELOG for version 0.40.1

- Added new function `sqlpage.oidc_logout_url(redirect_uri)` to generate secure logout URLs for OIDC users, supporting RP-Initiated Logout.
- Fixed compatibility issues with Auth0 for OpenID-Connect authentication.
2025-12-07 01:06:52 +01:00
Ophir LOJKINE 747cc78a91 sqlpage.fetch(null) = null (#1131)
* Fix: fetch(null) and fetch_with_meta(null) return null

Co-authored-by: contact <contact@ophir.dev>

* clean up implementation

* update docs

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-11-26 22:02:51 +01:00
Ophir LOJKINE 2af95a041f Accept header JSON responses (#1127)
* Support JSON responses via Accept header

* no update in migrations

* No UPDATE in official site migrations

- Updated the JSON component description to clarify its integration with external services and the ability to serve both HTML and JSON based on the HTTP Accept header.
- Added examples demonstrating how to request JSON responses using `curl`.
- Removed the obsolete migration file that documented the JSON response format feature, consolidating information into the main documentation.

* revert stupid docs example change

stupid bot

* simplify tests

* avoid string then json in tests, parse as json directly

* changelog
2025-11-24 23:17:19 +01:00
DofSekai 24d6057649 add delay property (#1126) 2025-11-24 12:56:06 +01:00
Ophir LOJKINE e93056e6d8 Add sqlpage.set_variable(name, value) function and update docs (#1124)
* feat: Add sqlpage.set_variable function

Co-authored-by: contact <contact@ophir.dev>

* Refactor: Fix set_variable serialization and update tests

Co-authored-by: contact <contact@ophir.dev>

* fix tests: no json_extract on mssql

* Refactor: Update URLParameters handling in set_variable function

- Replaced serde_json::Map with a custom URLParameters struct for better management of URL parameters.
- Introduced methods for handling single and vector values in URLParameters.
- Updated tests to reflect changes in the set_variable function's behavior.

* cargo fmt

* clippy

* retsore set var test

* remove redundant test

* ensure set_variable only takes into account GET variables, not SET

* factor url parameter setting code

* v0.40

* sqlpage.set_variable links to "?" when no parameter is present

- Renamed URLParameters module for clarity and removed the deprecated url_parameter_deserializer.
- Updated the set_variable function to return parameters directly instead of appending to a URL.
- Adjusted related function calls to reflect changes in URL parameter management.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-11-24 12:55:32 +01:00
olivierauverlot 8289bc69ba Pagination (#1093)
* Pagination component

* New pagination component

* Some changes

* Adding a warning about the use of LIMIT and OFFSET in the blog post

* Use icon_img for icons

* Correction of the icons size

* enhance pagination docs examples

* update pagination docs

---------

Co-authored-by: Olivier Auverlot <olivier.auverlot@icloud.com>
Co-authored-by: lovasoa <contact@ophir.dev>
2025-11-23 00:40:37 +01:00
olivierauverlot 17d892584f Adding an alias named contents to the html property of the shell-empty component (#1122)
* Adding an alias named contents to the html property of the shell-empty component

* Changes for the shell-empty documentation

* improve shell comoonent description

* shell-empty docs clarification

---------

Co-authored-by: Olivier Auverlot <olivier.auverlot@icloud.com>
Co-authored-by: lovasoa <contact@ophir.dev>
2025-11-22 23:46:52 +01:00
lovasoa 215170e6ff clear up the docs for the login component 2025-11-21 16:57:47 +01:00
lovasoa 25fe2e66b6 clarify login footer docs 2025-11-19 23:53:37 +01:00
lovasoa 20ae45f2b4 fix missing parameter from login component docs
see https://github.com/sqlpage/SQLPage/discussions/1114
2025-11-19 23:51:00 +01:00
Ophir LOJKINE 34f5d7f4ae Refactor spy function documentation for clarity (#1112)
fixes https://github.com/sqlpage/SQLPage/discussions/1108#discussioncomment-15007105
2025-11-19 03:13:40 +01:00
Ophir LOJKINE b11e7bf0ff Make URL and POST parameters immutable (#1109)
* Make URL and POST parameters immutable, separate from SET variables

- URL and POST parameters are now immutable after request initialization
- SET command creates user-defined variables in separate namespace
- Variable lookup: SET variables shadow request parameters
- Added sqlpage.variables('set') to inspect user-defined variables
- Simplified API: most functions now use &RequestInfo instead of &mut
- All tests passing (151 total)

* Restore deprecation warning for SET on POST variable names

* Restore deprecation warnings for $var accessing POST variables

- Warn when both URL and POST have same variable name
- Warn when $var is used for POST-only variable (should use :var)

* Simplify run_sql: always use clone_without_variables

No need to branch on whether variables are provided since we clone in both cases anyway.

* Revert "Simplify run_sql: always use clone_without_variables"

This reverts commit 60f5a05446.

* Fix cross-database test compatibility for immutable variables

Renamed test to run only on SQLite since json_extract() is SQLite-specific.
Other databases (PostgreSQL, MySQL, MSSQL) have different JSON functions.

* Fix test to work across all databases without json_extract

PostgreSQL doesn't have json_extract, so compare the full JSON string instead.

* Document variable system improvements in CHANGELOG

* Make CHANGELOG more explicit about breaking changes with examples

* Fix CHANGELOG: SET overwrites GET parameters, not POST

* Add database-specific examples for accessing original URL parameters
2025-11-19 03:10:54 +01:00
lovasoa 3276b5a786 Add a visual identity page to the website 2025-11-13 12:12:13 +01:00
Ophir LOJKINE 97c2e4a0ed wip: perf guide (#1077)
* wip: perf guide

* update guide

* Add materialized views section to performance guide

- Introduced a new section on materialized views, explaining their purpose and benefits for optimizing analytical queries.
- Added an example SQL statement for creating a materialized view to compute total sales per store.
- Provided guidance on refreshing materialized views manually or via external scripts.

* Document nginx streaming and compression for sqlpage (#1080)

* Docs: Add Nginx streaming and compression configuration

Co-authored-by: contact <contact@ophir.dev>

* Add NGINX streaming and compression configuration

Co-authored-by: contact <contact@ophir.dev>

* Refactor NGINX proxy settings documentation for clarity

Co-authored-by: contact <contact@ophir.dev>

* Refine NGINX proxy buffering recommendations for streaming

Co-authored-by: contact <contact@ophir.dev>

* Update NGINX proxy buffering settings for improved streaming performance

Revised the documentation to clarify the impact of enabling and disabling proxy buffering in NGINX for SQLPage. Added concise recommendations for handling slow SQL queries and emphasized the importance of adjusting `compress_responses` in `sqlpage.json` when using a reverse proxy.

Co-authored-by: contact <contact@ophir.dev>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>

* Update dependencies and version for sqlpage to 0.39.1

- Bump versions of several dependencies including `aho-corasick`, `cc`, `clap`, `icu_collections`, and others to their latest releases.
- Update `Cargo.toml` to reflect the new version of sqlpage.
- Ensure compatibility with updated dependencies and improve overall project stability.

* fix handling of one-element arrays in doc code generator

see https://github.com/sqlpage/SQLPage/issues/1079

* In the table component, allow simple objects in custom_actions instead of requiring arrays of objects.

 fix https://github.com/sqlpage/SQLPage/issues/1079

* Implement faster icon loading by inlining icons from the Tabler sprite. The previous method required downloading and parsing a large file, causing delays in icon rendering. Now, icons are generated and cached, improving page load times. Update the icon helper to utilize the new inline method.

* Update tabler icons to version 3.35 and refactor icon extraction logic for improved performance

* icon image helper: logging and error handling

- Changed debug logs to warning logs for invalid icon names and missing icons in the IconImgHelper.
- Updated the way icons are retrieved from the ICON_MAP for better clarity and performance.

* IconImgHelper: use raw string literals for SVG output

* Refactor icon extraction logic in build.rs to improve performance and memory usage. The download_tabler_icons function now directly processes sprite content in memory, eliminating the need for temporary file storage. Updated extract_icons_from_sprite to handle byte slices instead of strings, enhancing efficiency.

* build.rs: raise on missing icon id

* Simlplify icon generation in build.rs

* simplify icon _img helper

* update input field docs

fixes https://github.com/sqlpage/SQLPage/discussions/1081

* better form documentation

* fix ipv6 notation (#1084)

On Mac OS, when localhost:8080 is defined and sqlpage config file, the SocketAddr is resolved with ipv6 address if ip V6 is available on the internal network.

```json
{
  "listen_on": "localhost:8080"
}
```

On the terminal we can Ctrl + Click, but the URL is incorrect (ipV6 notation use bracket)

Actually we have 

```shell
View your website at:
🔗 http://::1:8080
```

Instead of 

```
View your website at:
🔗 http://[::1]:8080
```

Regards,

* Update dependencies in Cargo.lock to latest versions

* Fix github pr ci cache warnings (#1086)

* feat: Add shared-key to cargo cache action

Co-authored-by: contact <contact@ophir.dev>

* Refactor: Use matrix-specific cache key in CI

Co-authored-by: contact <contact@ophir.dev>

* feat: Cache Rust build artifacts only on main branch

Co-authored-by: contact <contact@ophir.dev>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>

* Enhance SQL performance guidance in migration script

- Added detailed recommendations for using primary and foreign keys, including examples for product and sales tables.
- Introduced best practices for indexing, query performance debugging, and database maintenance commands.
- Included advice on lazy loading and reducing the number of queries to optimize SQLPage applications.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Christophe CHAUVET <christophe.chauvet@gmail.com>
2025-11-08 00:31:38 +01:00
lovasoa 0d0bd84290 better form documentation 2025-11-05 10:13:02 +01:00
lovasoa 3bd58baf47 update input field docs
fixes https://github.com/sqlpage/SQLPage/discussions/1081
2025-11-04 17:25:21 +01:00
lovasoa cec270e1ee In the table component, allow simple objects in custom_actions instead of requiring arrays of objects.
fix https://github.com/sqlpage/SQLPage/issues/1079
2025-11-04 10:32:50 +01:00
lovasoa 26e091a699 fix handling of one-element arrays in doc code generator
see https://github.com/sqlpage/SQLPage/issues/1079
2025-11-04 00:40:23 +01:00
Ophir LOJKINE 6b57c4abee Document nginx streaming and compression for sqlpage (#1080)
* Docs: Add Nginx streaming and compression configuration

Co-authored-by: contact <contact@ophir.dev>

* Add NGINX streaming and compression configuration

Co-authored-by: contact <contact@ophir.dev>

* Refactor NGINX proxy settings documentation for clarity

Co-authored-by: contact <contact@ophir.dev>

* Refine NGINX proxy buffering recommendations for streaming

Co-authored-by: contact <contact@ophir.dev>

* Update NGINX proxy buffering settings for improved streaming performance

Revised the documentation to clarify the impact of enabling and disabling proxy buffering in NGINX for SQLPage. Added concise recommendations for handling slow SQL queries and emphasized the importance of adjusting `compress_responses` in `sqlpage.json` when using a reverse proxy.

Co-authored-by: contact <contact@ophir.dev>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-11-03 23:53:48 +01:00
lovasoa 2e71702c42 clear json in docs 2025-10-28 22:55:47 +01:00
lovasoa a7f05a4328 formatting 2025-10-28 22:54:53 +01:00
lovasoa ee3bad7eeb Enhance SQLPage documentation for execution process and function handling
- Clarify the execution flow of SQL statements in SQLPage, detailing the decision-making process for handling statements.
- Expand on the role of `sqlpage.*` functions and their execution context.
- Improve explanations and examples to illustrate the differences between local handling and database execution.
- Update section titles for better readability and understanding.
2025-10-28 22:53:23 +01:00
lovasoa 034b8485ca Update SQL documentation to clarify SQLPage's execution process and variable handling
- Refactor content for better clarity on how SQLPage processes SQL statements.
- Introduce sections on static simple selects, variable handling, and the execution of `sqlpage.*` functions.
- Improve examples to illustrate the differences between handled and sent queries.
- Enhance explanations regarding performance and data types in SQLPage.
2025-10-28 22:30:08 +01:00
lovasoa abe136d095 fix labels semantics in login component 2025-10-28 00:06:04 +01:00
lovasoa 5ee781cf40 use the login component in the user auth example 2025-10-27 23:36:29 +01:00
lovasoa 5a6192fcfa Merge olivierauverlot/login: combine local defaults with error_message and improved docs 2025-10-27 23:19:21 +01:00
lovasoa cc95ae25de Improve login component documentation and usability
Add complete example with database schema, credential processing, and page protection. Update authentication migration to reference new login component. Enhance login template with default icons and autocomplete attributes. Make validate parameter optional with sensible default.
2025-10-27 23:13:38 +01:00
Olivier Auverlot 3d7f780fbd Documentation improved 2025-10-27 23:13:38 +01:00
Olivier Auverlot 5aa6acb8a0 Documentation improved 2025-10-27 23:13:38 +01:00
Olivier Auverlot eb1f43c6e1 username_icon and password_icon attributes 2025-10-27 23:13:38 +01:00
Olivier Auverlot cfea904e5d The login component is an authentication form for users of an application. 2025-10-27 23:13:38 +01:00
lovasoa 722dc740fa add an error_message property to the login component
- Updated SQL queries in `create_session_token.sql` and `login.sql` to use consistent parameter naming conventions.
- Enhanced the login form in `login.sql` to include an error message for failed login attempts.
- Added a new parameter `error_message` in the migration file for better user feedback.
- Modified the Handlebars template to display the error message when applicable, improving user experience during authentication.
2025-10-27 23:07:57 +01:00
lovasoa c28cf2a46d Merge branch 'main' into login 2025-10-27 22:50:56 +01:00
Olivier Auverlot ce4ffd3394 Documentation improved 2025-10-24 08:45:57 +02:00
Olivier Auverlot 2570bda545 Documentation improved 2025-10-24 08:29:35 +02:00
Olivier Auverlot b356cc8904 username_icon and password_icon attributes 2025-10-24 08:04:39 +02:00
lovasoa f466bcc21d remove broken links 2025-10-21 11:54:31 +02:00
lovasoa d9d2832402 Merge branch 'main' into feature/table-action-buttons 2025-10-21 11:35:51 +02:00
lovasoa 842f67cf83 update documentation 2025-10-21 11:35:08 +02:00
Spencer Hansen 6729e10a01 Added sqlpage version number information to the new components. 2025-10-20 09:31:36 -07:00
Olivier Auverlot 5d5d1f94d7 The login component is an authentication form for users of an application. 2025-10-18 12:19:15 +02:00
lovasoa b577695eee Enhance llms.txt.sql to include detailed parameter documentation
- Updated the SQL file to improve the output format for components, adding sections for top-level and row-level parameters.
- Each parameter now includes its type, requirement status, and description for better clarity in the generated documentation.
2025-10-17 23:51:28 +02:00
lovasoa c5c4a4fcd5 add llms.txt
closes https://github.com/sqlpage/SQLPage/issues/980
2025-10-17 23:43:20 +02:00
Spencer Hansen be67d3e4ae Modified new table example. 2025-10-14 19:17:56 -07:00
Spencer Hansen ac4126b2af #Added support for action buttons in the table component template.
* A default edit and delete button can be included by specifying an "edit_url" or "delete_url"
* Custom Column based action buttons can be added in the table header using json object array in the custom_actions column.
* Custom action buttons can be defined on the row level by specifying _sqlpage_actions.
2025-10-14 17:59:56 -07:00
lovasoa cf1e585340 update feature and compatibility sections in homepage template with IDs for improved accessibility 2025-10-05 09:26:05 +02:00
lovasoa 2c7cb90729 add compatibility section to homepage 2025-10-04 22:31:12 +02:00
lovasoa e186f13d0d instructions 2025-10-04 21:22:12 +02:00
Ophir LOJKINE 625deb973b Add and document sqlpage.hmac function (#1033)
* feat: Add sqlpage.hmac function for cryptographic signing

Co-authored-by: contact <contact@ophir.dev>

* feat: Add sqlpage.hmac function for secure data signing

Co-authored-by: contact <contact@ophir.dev>

* Test HMAC function with RFC vectors and update tests

Co-authored-by: contact <contact@ophir.dev>

* feat: Add sqlpage.hmac() function for secure signatures

Co-authored-by: contact <contact@ophir.dev>

* feat: Add base64 output option to hmac function

Co-authored-by: contact <contact@ophir.dev>

* Refactor hmac function for cleaner output formatting

Co-authored-by: contact <contact@ophir.dev>

* Add webhook HMAC signature validation tests

Co-authored-by: contact <contact@ophir.dev>

* Refactor HMAC function and update SQL examples for clarity and consistency

- Changed function parameters to remove Option types for data and key in the HMAC function.
- Improved SQL documentation and examples for HMAC usage, including clearer descriptions and updated error handling.
- Enhanced test cases for webhook HMAC validation to ensure accurate signature checks and responses.
- Removed obsolete test file for HMAC with null values.

* Update HMAC validation logic to handle NULL values in SQL queries

- Modified conditions in SQL queries to check for NULL values alongside signature mismatches.
- Enhanced documentation on NULL handling for HMAC checks to improve clarity and portability.

* remove debug logging from ci

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-10-01 21:07:36 +02:00
lovasoa 07c8a03633 Update log component SQL migration to include introduced_in_version field 2025-09-14 01:06:39 +02:00