Commit Graph

797 Commits

Author SHA1 Message Date
Christophe CHAUVET f551f1900c 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,
2025-11-07 22:02:36 +01:00
lovasoa f6c1c6fa9b simplify icon _img helper 2025-11-07 22:02:36 +01:00
lovasoa 1e66ea559e Simlplify icon generation in build.rs 2025-11-07 22:02:36 +01:00
lovasoa 79fff9b460 IconImgHelper: use raw string literals for SVG output 2025-11-07 22:02:35 +01:00
lovasoa 96a0a791c1 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.
2025-11-07 22:02:35 +01:00
lovasoa 7818619939 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. 2025-11-07 22:02:35 +01:00
lovasoa c4ffc0dda3 clippy 2025-11-03 09:53:46 +01:00
lovasoa 44fd2e1cca disable response compression by default 2025-11-02 19:05:41 +01:00
Ophir LOJKINE 73044e7016 nice visual error messages for invalid header values
* Feat: Sanitize header values to prevent injection attacks

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

* Refactor sanitize_header_value to use Cow and remove test file

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

* refactor header error handling in render.rs

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-10-28 23:50:18 +01:00
lovasoa c803214766 Add server timing for parameter binding in query execution
- Recorded server timing for the parameter binding process in the query execution flow.
- Updated tests to verify the inclusion of the new timing event in the server timing header.
2025-10-28 16:18:05 +01:00
lovasoa 1e396ac095 Fix missing server timing in some cases
- Updated response handling to use a builder pattern for better clarity and consistency.
- Enhanced server timing format to include microseconds in the output.
- Added a new test for server timing in redirect responses to ensure proper header inclusion.
2025-10-28 16:08:40 +01:00
lovasoa 06df761eee Refactor: Update ServerTiming to use Arc and simplify header generation
This commit modifies the ServerTiming structure to utilize Arc for thread-safe reference counting, enhancing performance and memory management. The header generation logic is streamlined, and related code is updated to reflect these changes. Additionally, tests are adjusted to ensure proper functionality with the new implementation.

Co-authored-by: contact <contact@ophir.dev>
2025-10-23 12:42:09 +02:00
Cursor Agent 38e08d78d1 Refactor: Pass ServerTiming to extract_request_info
Co-authored-by: contact <contact@ophir.dev>
2025-10-22 22:08:10 +00:00
Cursor Agent 5c415984bf Refactor Server-Timing header generation and add tests
This commit refactors the Server-Timing header generation to be more efficient and adds comprehensive tests for its behavior in development and production environments. It also includes a new test SQL file for server timing verification.

Co-authored-by: contact <contact@ophir.dev>
2025-10-22 20:03:09 +00:00
Cursor Agent faf19a6660 feat: Add Server-Timing header to track request performance
Co-authored-by: contact <contact@ophir.dev>
2025-10-22 19:47:39 +00:00
Cursor Agent 8e248b9571 feat: Add Server-Timing header support
Co-authored-by: contact <contact@ophir.dev>
2025-10-22 12:38:36 +00:00
lovasoa f1375615f4 always display line info in errors
https://github.com/sqlpage/SQLPage/issues/1057
2025-10-20 18:27:25 +02:00
lovasoa 0184bb9b9a Enhance routing to support SQL execution for non-SQL file extensions
- Updated routing logic to execute SQL files when a request is made for paths with extensions other than .sql.
- Added tests to verify that SQL files are executed correctly for paths with non-SQL extensions.
- Updated CHANGELOG to reflect this new feature in version 0.38.1.
2025-10-17 23:42:33 +02:00
lovasoa cc3faba20f fix https://github.com/sqlpage/SQLPage/issues/1055 2025-10-17 21:45:05 +02:00
lovasoa e9831ab5f3 fix clippy warning 2025-10-14 16:39:03 +02:00
lovasoa 9dfbf42f56 enable arbitrary precision in the internal representation of values
- Enabled arbitrary precision for `serde_json` to handle large numbers without rounding.
- Refactored decimal handling in `sql_to_json.rs` to utilize a new function for converting decimals to JSON format.

Fixes https://github.com/sqlpage/SQLPage/issues/1052
2025-10-14 16:33:10 +02:00
lovasoa 534fa422fa Local execution of simple static SET commands
`SET x = 'hello'` is now executed locally by SQLPage and does not send anything to the database. This completely removes the cost of extracting static values into variables for cleaner SQL files.
2025-10-14 12:14:11 +02:00
lovasoa 25f8385067 make odbc mandatory 2025-10-03 23:00:01 +02:00
Cursor Agent a2ad7bbfab Refactor: Move odbc import to top of file
Co-authored-by: contact <contact@ophir.dev>
2025-10-02 20:54:05 +00:00
Cursor Agent 8866cf4759 feat: Add ODBC build modes and documentation
Co-authored-by: contact <contact@ophir.dev>
2025-10-02 16:17:48 +00:00
lovasoa 746c70c95b Refactor SQL column handling to ensure consistent JSON output
- Updated column name handling in `row_to_json` to use lowercase for ODBC databases.
- Added `canonical_col_name` function to standardize column names.
- Modified SQL queries in tests to use lowercase column names for consistency.
- Enhanced tests for edge cases and variations in column naming.
2025-10-01 23:39:34 +02:00
lovasoa 080cd75d9b fix decoding of the sql DECIMAL type: integers and floats are now handled separately
we used to decode all decimals as floats
2025-10-01 23:00:03 +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 b029661cf4 Improve error message formatting in SQL file parsing 2025-10-01 10:48:16 +02:00
lovasoa f5a679d449 Update sqlx dependencies to use a new commit hash and modify Snowflake table creation syntax in filesystem.rs 2025-09-30 14:44:25 +02:00
lovasoa e44b5e874f Add Snowflake support in database handling and enhance logging
- Introduced Snowflake as a supported database in the enum and related logic.
- Updated SQL table creation to include Snowflake-specific syntax.
- Enhanced logging for file modification checks in both local and database contexts.
2025-09-30 10:56:27 +02:00
lovasoa ec90218306 reduce log verbosity in tests 2025-09-29 22:37:05 +02:00
Ophir LOJKINE 0ff91bea22 Allow large text fields in odbc (#1031)
* feat: Remove ODBC max column size limit and warn on password

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

* Refactor: Extract ODBC connection options to a separate function

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

* feat: Enhance ODBC connection options by adding batch size configuration and logging

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-09-29 22:27:30 +02:00
lovasoa 941522bf47 clippy 2025-09-29 21:36:02 +02:00
lovasoa 94c274daec Update sqlx dependencies to version 0.6.49-beta.4 and refactor database interaction in tests for improved clarity and consistency. 2025-09-29 17:03:22 +02:00
lovasoa d4dd9c20e9 Refactor SQLite connection options setup by extracting logic into a separate function for improved readability and maintainability. 2025-09-29 16:50:45 +02:00
lovasoa 94519752fd clippy 2025-09-26 16:21:42 +02:00
lovasoa 450a23e162 clippy 2025-09-26 16:21:42 +02:00
lovasoa e5fa8d56a1 Refactor database handling to consistently use DbInfo and AnyKind across filesystem and SQL modules for improved clarity and flexibility. 2025-09-26 16:21:42 +02:00
lovasoa 53293d7442 Refactor database queries and connection handling to utilize DbInfo for improved clarity and consistency across database operations. 2025-09-26 16:21:42 +02:00
lovasoa 9ff5caed32 Refactor database connection handling to use AnyKind instead of SupportedDatabase for improved flexibility and clarity in connection options. 2025-09-26 16:21:42 +02:00
lovasoa 659183e0df Refactor database handling in tests to use database_type instead of any_kind for improved clarity and consistency. 2025-09-26 16:21:42 +02:00
lovasoa 83132c51dd fmt 2025-09-26 16:21:42 +02:00
lovasoa 939e9857fc Update sqlpage and sqlx dependencies, refactor database handling to use SupportedDatabase enum for improved database type management and placeholder generation. 2025-09-26 16:21:42 +02:00
Cursor Agent a1a8120be2 Add ODBC support and update dependencies
This commit introduces support for ODBC databases, allowing users to connect to a wider range of data sources. It also includes updates to various dependencies, ensuring the project is using the latest stable versions and incorporating necessary bug fixes and performance improvements.

Co-authored-by: contact <contact@ophir.dev>
2025-09-26 16:21:42 +02:00
Ophir LOJKINE 0cf2e9491c Refactor OIDC request handling to streamline callback processing and remove redundant code. Simplify the handling of authenticated user info and improve error logging for OIDC callback parameters. (#1022)
* Refactor OIDC request handling to streamline callback processing and remove redundant code. Simplify the handling of authenticated user info and improve error logging for OIDC callback parameters.

* Refactor OIDC callback processing to use ID token directly, enhancing cookie management and nonce handling. Update logging for successful logins and streamline token claims retrieval.

* Refactor OIDC state management to use a temporary login flow state cookie, enhancing nonce and redirect handling. Update cookie creation and retrieval methods for improved clarity and maintainability.

fixes https://github.com/sqlpage/SQLPage/issues/1014

* Enhance error handling in login flow state parsing by adding context to JSON deserialization failure.

* Fix infinite redirect loop in OIDC login flows when multiple tabs initiate login simultaneously, particularly after inactivity in mobile browsers.

* clippy
2025-09-19 15:39:31 +02:00
Ophir LOJKINE a451c7e7dc Fix concurrent oidc login cookie overwrites (#1018)
* Refactor OIDC state handling to use separate nonce and redirect cookies

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

* Refactor OIDC state management to use separate nonce and redirect cookies

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

* Refactor OIDC redirect handling to use updated cookie names and improve error logging

* Update OIDC redirect response to use header constant and simplify cookie creation

* Refactor nonce retrieval in OIDC user info handling to simplify logic and ensure proper token claims processing

* Refactor OIDC cookie handling to introduce a constant for cookie expiration and simplify nonce validation logic

* Refactor OIDC redirect URL cookie retrieval to streamline logic and improve error handling

* Refactor OIDC redirect URL cookie name construction for improved clarity

* fix redirect auth cookie removal

Update OIDC redirect URL cookie path to ensure proper handling after authentication

* Refactor OIDC redirect URL cookie name construction for improved efficiency

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-09-19 11:36:20 +02:00
lovasoa 31a4c29181 file access restrictions: improve error messages 2025-09-15 15:54:52 +02:00
lovasoa ddd52fd74c Refactor unauthorized response
Use ErrorWithStatus for unauthorized errors to set the WWW-Authenticate
header.
2025-09-15 11:34:23 +02:00
lovasoa b1184b9308 Improve routing error messages 2025-09-15 11:21:27 +02:00