Commit Graph

54 Commits

Author SHA1 Message Date
lovasoa 44fd2e1cca disable response compression by default 2025-11-02 19:05:41 +01:00
Cursor Agent 83efc1aae5 Checkpoint before follow-up message
Co-authored-by: contact <contact@ophir.dev>
2025-09-29 15:32:49 +00:00
lovasoa a76965cd39 Update docker-compose and README for ODBC support; enhance CI workflow to include ODBC testing 2025-09-26 16:21:42 +02:00
Ophir LOJKINE 2a13f62738 Support multiple jwt audiences for oidc (#977)
* Add OIDC multiple audiences support with configurable trust settings

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

* Refactor OIDC audience verification with improved configuration options

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

* remive verbose docs

* Refactor OIDC audience verification logic

The changes move audience verification into a dedicated type and improve
code organization around ID token verification.

* Use oidc_additional_trusted_audiences in sso example

Add OIDC config comments and improve array syntax

* document oidc_additional_trusted_audiences

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-07-30 17:10:37 +02:00
Lenardt Gerhardts 84db9b2276 Added configuration option to skip OIDC authorization checks for certain endpoints (#969)
* Added posibility to bypass oidc authentication for certain endpoints

* fixxed missing .clone()

* Fixxed oidc_skip_endpoints not being optional

* feat(oidc): Introduce protected path prefixes

This commit replaces the OIDC endpoint blacklist with a path prefix whitelist. This is a more intuitive and secure approach for managing protected routes.

The new `oidc_protected_paths` configuration option allows users to specify a list of URL prefixes that require OIDC authentication. By default, all paths are protected.

The documentation has been updated to reflect this change, with clear examples and more user-friendly language.

* docs(oidc): Improve OIDC documentation and examples

This commit improves the OIDC documentation and the "single sign on"
example to better demonstrate how to create a selective login system.

The main documentation now includes a section on creating a public
login page and the "single sign on" example has been updated to
reflect this pattern.

* Simplify OIDC middleware request handling for unprotected paths

* docs(oidc): Improve single sign on example

This commit improves the "single sign on" example to better
demonstrate a public information page that adapts to the users
login status and a separate protected page.

* docs(oidc): Document oidc_protected_paths in configuration.md

This commit updates the main configuration documentation to reflect the
new `oidc_protected_paths` option. It removes the outdated
`oidc_skip_endpoints` and provides a more detailed explanation of how
to create a mix of public and private pages.

* Improve SSO demo UX

- Update docker compose command to use `--watch` flag - Add watch
configuration for SQLPage development - Enhance login page with hero
component and better styling - Simplify protected page welcome message -
Fix OIDC middleware path check logic - Update protected paths in config
to use `/protected` instead of `/protected.sql`

* Skip OIDC auth for non-protected paths later in middleware

We still want to be able to access authenticated user's info in
non-authenticated parts of the app.

We crucially need to check request.path() == SQLPAGE_REDIRECT_URI before
the protected_paths check

* Added whitelist option

* Update configuration.md

* Improve OIDC public paths documentation

The documentation now provides clearer examples and explains the
interaction between public and protected paths more precisely. Also
removes the now-unused default_oidc_public_paths function since the
field's default is handled by serde's default for Vec.

* Add OidcConfig method to check public paths

The new `is_public_path` method consolidates the logic for checking if a
path should bypass OIDC authentication. This replaces the previous
inline checks for public and protected paths.

* fix default empty public paths

* Update SSO example with new image path and public access rules

- Change hero image path in login page - Remove protected.sql as it's no
longer needed - Update sqlpage.yaml to allow public access to
/protected/public

---------

Co-authored-by: Lenardt Gerhardts <lenardt.gerhardts@obi.de>
Co-authored-by: lovasoa <contact@ophir.dev>
2025-07-25 21:15:53 +02:00
lovasoa 4874fe3c69 Revert "Allow the usage of eval from user scripts in the default Content-Security-Policy"
This reverts commit dd36a28b2d.
2025-05-25 22:13:19 +02:00
lovasoa dd36a28b2d Allow the usage of eval from user scripts in the default Content-Security-Policy 2025-05-23 01:21:50 +02:00
Gus Power 1582956ae5 Extend CSP Configuration to handle user-supplied values that can contain {NONCE} (#911)
* Extend CSP Configuration to handle user-supplied values that can contain {NONCE}

* fix RequestContext to use CSP value from AppConfig

* update documentation to describe usage

* generate nonce per request; config is a string (again); added playwright test to verify subsequent requests return a different nonce.

* fix js lint `let` -> `const`

* format

* remove some useless string copies

we are still re-parsing the csp template on every request

* implement a proper csp template struct

* parse the content-security-policy just once

* fix merge issue.

* fix docs

* fix docs

* clippy

---------

Co-authored-by: lovasoa <contact@ophir.dev>
2025-05-06 09:34:46 +02:00
Ophir LOJKINE adcbaa680b Single Sign-On via OpenID Connect (#888)
* add oidc config variables

* setup a basic middleware

* implement an async http client that uses oidc

* initialize provider_metadata in OidcService

* better error handling in oidc config

* HTTP client initialization in oidc now follows global config

* oidc: implement redirects

- Add `host` configuration option for specifying the application's web address in configuration.md and app_config.rs.
- Update docker-compose.yaml to include SQLPAGE_HOST and SQLPAGE_OIDC_ISSUER_URL environment variables.
- Enhance OIDC middleware to utilize the new `host` setting for redirect URLs and improve cookie handling in oidc.rs.

* improve local oidc configurability

* log

* Update warning message in OIDC configuration to clarify how to disable it by providing a host setting

* Update OIDC redirect logging to use info level with client ID

* Refactor unauthenticated request handling in OIDC service

- Extracted logic for handling unauthenticated requests into a separate method `handle_unauthenticated_request`.
- Updated the main request handling flow to utilize the new method for improved readability and maintainability.

* Enhance OIDC service with callback handling and token processing

- Introduced `handle_oidc_callback` method to manage OIDC callback requests.
- Added `process_oidc_callback` and `exchange_code_for_token` methods for token exchange logic.
- Updated `handle_unauthenticated_request` to check for callback URL and redirect accordingly.
- Refactored `build_redirect_response` to improve clarity in response handling.

* in handle_oidc_callback use service_request.into_response

* fmt

* Implement oidc code exchange and token storage

* validate oidc cookies

- Updated `get_sqlpage_auth_cookie` to return a result for better error handling and validation of the SQLPage auth cookie.
- Improved logging throughout the OIDC service for better traceability of requests and responses.
- Adjusted the handling of OIDC callback parameters to include context in error messages.

* OIDC callback: redirect to the auth URL on failure.

* oidc use localhost for redirect config instead of 0.0.0.0 by default

* Enhance OIDC provider metadata discovery with improved logging and error context

* maintain the initial URL during OIDC authentication

- Added state cookie handling to maintain the initial URL during OIDC authentication.
- Refactored `build_auth_url` to accept the initial URL as a parameter.
- Enhanced `process_oidc_callback` to retrieve the state from the cookie and redirect accordingly.

* implement csrf token

* update deps

* update sso examples

* nonce verification

- Improved error logging for invalid auth cookies and ID token verification.
- Introduced nonce verification logic to ensure security during OIDC authentication.
- Adjusted parameters for nonce hashing to optimize for short-lived tokens.

* Refactor OIDC logging and improve documentation

- Updated logging statements for better clarity and context.
- Refactored code for nonce verification and error handling.
- Enhanced documentation in `app_config.rs` for clarity on `https_domain` usage.

* Remove unused app_state field from OidcService struct

* Enhance OIDC client error handling and refactor HTTP request types

- Added context to OIDC client creation error handling.
- Updated HTTP request and response types for better integration with the openidconnect library.
- Introduced AwcWrapperError for improved error management in HTTP calls.

* clippy fixes

- Changed http_client from Arc to Rc in OidcService for improved memory efficiency.
- Updated related code to reflect the new ownership model for the HTTP client.

* initialize the oidc and http clients only once

- Added OidcState struct to encapsulate OIDC configuration and client.
- Refactored OidcMiddleware to utilize OidcState for improved state management.
- Updated HTTP client handling in OIDC service methods for better integration with app data.
- Enhanced logging for OIDC middleware initialization and request processing.

* functions for accessing user claims from OIDC tokens + documentation

- Updated SQLPage authentication component documentation for clarity on usage and options.
- Removed deprecated login and redirect handler scripts to streamline the SSO implementation.
- Enhanced logout functionality to properly clear session cookies and redirect users.
- Improved request handling to include OIDC claims in the request context for better user information retrieval.

* better sso troubleshooting info

* fmt

* add sso to the changelog
2025-05-05 17:59:07 +02:00
Ophir LOJKINE 804372e8f7 Update configuration.md
improve configuration documentation

Fixes https://github.com/sqlpage/SQLPage/issues/844
2025-03-12 14:27:05 +01:00
Ophir LOJKINE b7b1b2123c Add markdown rendering options to the sqlpage configuration (#823)
* Add markdown rendering options to the sqlpage configuration

* fmt

* silence clippy

* revert changes to conf

* docs

* fmt
2025-02-25 19:05:39 +01:00
lovasoa c9fdfbba27 Make maximum recursion depth of run_sql configurable
fixes #739
2024-12-15 14:33:30 +01:00
Ophir LOJKINE 73c5393dbd on_reset.sql 2024-12-03 14:04:23 +01:00
lovasoa 7b51990c8c new on_reset.sql 2024-12-03 00:54:04 +01:00
lovasoa b1da4d6aea sql.datapage.app -> sql-page.com 2024-11-26 23:26:09 +01:00
lovasoa b29899e01e add support for large form submissions
fixes https://github.com/sqlpage/SQLPage/issues/705
2024-11-22 00:51:58 +01:00
lovasoa 67e51f8a8b new database_password configuration option 2024-10-05 23:07:40 +02:00
lovasoa 0851076b51 add examples of percent encoding 2024-10-05 22:45:20 +02:00
Ophir LOJKINE 9fd29619fc Update configuration.md 2024-09-30 15:49:22 +02:00
lovasoa 3c405fcec0 document 404.sql
thanks again to  @wucke13  who implemented the feature
2024-08-22 23:49:54 +02:00
lovasoa 54cb2aab41 move to the datapage.app domain 2024-08-17 20:06:26 +02:00
lovasoa 7d1f6424e3 configuration documentation 2024-08-06 16:23:08 +02:00
lovasoa e8ba798f82 add support for using the system's root ca certificates in sqlpage.fetch
fixes https://github.com/lovasoa/SQLpage/issues/507
2024-08-05 18:34:35 +02:00
lovasoa 83f3e26dcc allow customizing the content security policy 2024-07-23 22:27:59 +02:00
PChemGuy c621672c4e Fixes tables formatting 2024-06-28 06:26:43 +03:00
lovasoa 07a1c2328b allow disabling http compression
compression can hinder http response streaming,
and is unwanted when using a reverse proxy that does the compression itself.

see https://github.com/lovasoa/SQLpage/issues/435
2024-06-23 15:11:13 +02:00
lovasoa b1c89cdd87 make max_pending_rows configurable and increase the default from 128 to 256
closes https://github.com/lovasoa/SQLpage/discussions/441
2024-06-22 11:45:22 +02:00
lovasoa 9d3171af55 Merge branch 'main' into unix_socket 2024-05-29 16:11:05 +02:00
lovasoa ea14c96361 links to migrations 2024-05-23 18:36:14 +02:00
Vlad Lasky c24d101cae Added new configuration option 'unix_socket'.
This specifies a path to a UNIX socket file to listen on instead of the TCP port.

If specified, SQLPage will accept HTTP connections only on this socket and not on any TCP port. This option is mutually exclusive with the `listen_on` and `port` options.

Useful when running SQLpage behind a proxy server like Nginx, as the overhead for communication using Unix Domain Sockets is less than when using the TCP stack.
2024-05-18 10:36:45 +10:00
lovasoa 81bc27682d clarify docs 2024-05-14 00:37:18 +02:00
Daniel Sheffield 9f52769760 missing trailing slash in configuration.md 2024-05-13 21:46:32 +12:00
Daniel Sheffield 013eb8f6c4 require trailing slash on site_prefix to avoid multiple strip_prefix calls 2024-05-13 21:28:19 +12:00
lovasoa 969b2b95aa implement client tls certificates
fixes https://github.com/lovasoa/SQLpage/issues/300
2024-05-05 00:58:01 +02:00
Ophir LOJKINE 9a7564b68e Add details about database url 2024-02-29 06:27:01 +01:00
lovasoa 031e2c46c0 SECURITY: fixes users being able to re-run migrations 2024-02-28 09:21:42 +01:00
Ophir LOJKINE e3fb2f8acc Introduce SQLPAGE_CONFIGURATION_DIRECTORY (#243)
* Introduce SQLPAGE_CONFIGURATION_DIRECTORY

Makes the configuration directory configurable instead of it being hardcoded to "./sqlpage/"

* logging
2024-02-25 19:23:17 +01:00
Alexander b47f7036ad Improve configuration documentaition (#153)
* Fix typo

* Add default values for different RDBMS

I optimized for a nicer looking rendered table, but the not rendered
one looks slightly less beautiful now.
2023-12-14 17:11:15 +01:00
lovasoa 51f58400a9 new configuration option: environment
allows hiding errors from users

closes https://github.com/lovasoa/SQLpage/issues/145

Thanks to @demogit-code
2023-12-04 00:27:15 +01:00
lovasoa ee413160ad v0.17 release notes
CI / compile_and_lint (push) Has been cancelled
CI / test (mssql) (push) Has been cancelled
CI / test (mysql) (push) Has been cancelled
Create Release / Build sqlpage binaries (target/superoptimized/sqlpage, macos-latest) (push) Has been cancelled
Create Release / Build sqlpage binaries (target/superoptimized/sqlpage, ubuntu-20.04) (push) Has been cancelled
Create Release / Build sqlpage binaries (target/superoptimized/sqlpage.exe, windows-latest) (push) Has been cancelled
Create Release / Build AWS Lambda Serverless zip image (push) Has been cancelled
CI / test (postgres) (push) Has been cancelled
CI / windows_test (push) Has been cancelled
CI / docker_build (linux/amd64) (push) Has been cancelled
CI / docker_build (linux/arm/v7) (push) Has been cancelled
CI / docker_build (linux/arm64) (push) Has been cancelled
CI / docker_push (push) Has been cancelled
Create Release / Create Github Release (push) Has been cancelled
Create Release / Publish to crates.io (push) Has been cancelled
2023-11-29 00:08:55 +01:00
lovasoa 6bce3af873 better csv ingestion, with tests and docs 2023-11-27 20:28:28 +01:00
lovasoa aa1e635ca4 Added support for .env files 2023-11-26 17:48:50 +01:00
lovasoa 2008e24834 fix docs 2023-11-25 13:48:18 +01:00
Ophir LOJKINE 8216313fc9 http/2 and automatic https (#140)
* better docs for multi-select

* wip

* fix bug in corporate conundrum demo

* update dependencies

* Fix bug with variable assignment

fixes #138

* Files (#139)

* document future file functions

* make forms multipart when they contain a file field

* extract http request data reading logic

* start work on file upload

* multipart post data parsing

* millisecond precision in logs

* implement customizable upload file size limits

* wip: add file handling functions

* file handling pseudo-functions

* clippy

* fmt

* Add file upload functionality to changelog

* fix example

* update datetime parsing

* add support for samesite cookies and document cookie expiration

* add support for https

* clippy

* ignore certs

* revert changes to default config

* changelog
2023-11-25 12:55:21 +01:00
Ophir LOJKINE 332420bc18 Files (#139)
* document future file functions

* make forms multipart when they contain a file field

* extract http request data reading logic

* start work on file upload

* multipart post data parsing

* millisecond precision in logs

* implement customizable upload file size limits

* wip: add file handling functions

* file handling pseudo-functions

* clippy

* fmt
2023-11-24 23:49:53 +01:00
lovasoa 6efdf206fb document custom component creation 2023-11-06 01:35:21 +01:00
lovasoa cf4c571ace connection initialization scripts
add the ability to create a `sqlpage/on_connect.sql` file that will be run every time a new database connection is opened.

This has many interesting applications, see configuration.md

See https://github.com/lovasoa/SQLpage/discussions/48
2023-09-30 02:29:19 +02:00
lovasoa 8ee57a08e5 new function: sqlpage.exec
This is a game changer and allows many new usecases that were previously impossible:

sending emails, querying external APIs, integrating with external providers, launching custom scripts, and much more.
2023-09-27 17:22:41 +02:00
lovasoa a897a1321c new configuration parameter: web_root
see https://github.com/lovasoa/SQLpage/discussions/87
2023-09-17 17:14:50 +02:00
lovasoa 6093094208 new config option: database_connection_acquire_timeout_seconds 2023-08-20 23:48:38 +02:00