CI / test (postgres, odbc, Driver=PostgreSQL Unicode;Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!, true) (push) Has been cancelled
cargo test was failing with too many open files because each test server
spawned a worker per CPU, quickly exhausting file descriptors when tests ran
in parallel. Set test servers to one worker so they use a bounded number of
sockets/threads, avoiding fd exhaustion and letting OIDC and migration tests
start reliably.
This commit introduces a macro for handling requests with cookies, simplifying the OIDC test flow. It also removes redundant session management functions, enhancing code clarity and maintainability. The setup function for OIDC tests is updated to improve readability and streamline the initialization process.
Refactor OIDC login simulation by extracting query parameter logic into a separate function and renaming the callback function for clarity. This improves code readability and maintainability.
* Fix: Prevent infinite OIDC redirects
This commit adds a mechanism to prevent infinite redirects in the OIDC
callback flow. It does this by:
- Tracking the number of redirects using a cookie.
- Setting a maximum number of redirects (3).
- Returning an error if the maximum is exceeded.
* Merge branch 'main' into prevent-oidc-infinite-redirects
* simplify OIDC infinite redirect prevention logic
This update introduces a new function, `handle_oidc_callback_error`, to streamline error handling during OIDC callback processing. It enhances the management of redirect counts and separates the logic for handling maximum redirect limits into `handle_max_redirect_count_reached`. Additionally, the `build_auth_provider_redirect_response` function is updated to accept the redirect count, ensuring accurate tracking of redirects. This refactor aims to prevent infinite redirect loops and improve code clarity.
* 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.
CI / test (postgres, odbc, Driver=PostgreSQL Unicode;Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!, true) (push) Has been cancelled
* simplify SQL test files
- Simplified SQL test files by removing unnecessary components and restructuring queries to focus on expected vs actual results.
- Updated the request handling in `run_sql_test` to differentiate between JSON and HTML responses based on test file content.
- Enhanced error handling and assertions for both JSON and HTML responses to improve test reliability and clarity.
- Removed redundant code and improved readability in the test execution flow.
* move more tests to the new expected/actual format
* migrate more tests to the expected/actual format
- Changed references in various test files to point to the new `simple.sql` instead of the outdated `it_works_simple.sql`.
- Removed several obsolete SQL test files that are no longer needed, streamlining the test suite.
- Updated assertions and request paths in the test cases to reflect the new structure and improve clarity.
* Enhance error handling in SQL tests and update SQL syntax
- Added a new function `format_error` to improve error reporting in SQL test assertions, capturing detailed error descriptions and backtraces.
- Updated SQL syntax in `sqrt.sql` to use `INT` instead of `integer` for consistency with SQL standards.
* sqrt test
* 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
* 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>
* 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>
* 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>
* remove docker build cruft
- Simplified environment variable sourcing in build scripts by using a single build-env.sh file.
- Updated Dockerfile to streamline the build process and reduce unnecessary comments.
- Enhanced setup-cross-compilation.sh to directly set target and linker variables without temporary files.
- Improved clarity and maintainability of build scripts.
* fix setup-cross-compilation.sh
- Updated the script to use a more concise syntax for exporting environment variables.
- Improved readability by using echo and conditional checks for BINDGEN_EXTRA_CLANG_ARGS.
- This change simplifies the script while maintaining functionality.
* Refactor setup-cross-compilation.sh for improved readability
- Changed the syntax for checking BINDGEN_EXTRA_CLANG_ARGS to use a conditional statement for clarity.
- This enhances the script's maintainability while preserving its functionality.
* 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.
* WIP: Add ExecutionContext to separate mutable state from RequestInfo
This is a draft refactoring to avoid cloning large immutable data (headers,
cookies, body) when creating nested execution contexts in run_sql().
Changes:
- RequestInfo now contains only immutable request data
- ExecutionContext wraps Rc<RequestInfo> + mutable execution state
- Avoids cloning potentially large strings in nested run_sql() calls
Status: NOT COMPILING YET - this is work in progress
* Refactor: Rename RequestInfo to ExecutionContext
Co-authored-by: contact <contact@ophir.dev>
* avoid cloning request
* improve run_sql invalid variables error message
* changelog
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
* 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
* Add support for PostgreSQL range types in SQL to JSON conversion
Co-authored-by: contact <contact@ophir.dev>
* add support for postgres range types
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
CI / test (postgres, odbc, Driver=PostgreSQL Unicode;Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!, true) (push) Has been cancelled