2353 Commits

Author SHA1 Message Date
lovasoa d2292d2c90 Upgrade dependencies and update CHANGELOG
CI / compile_and_lint (push) Has been cancelled
CI / test (mssql) (push) Has been cancelled
CI / test (mysql) (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 / Build sqlpage binaries (macOS & Windows) (.exe, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
Create Release / Build sqlpage binaries (macOS & Windows) (macos-latest, x86_64-apple-darwin) (push) Has been cancelled
Create Release / Build sqlpage binaries (Linux) (push) Has been cancelled
Create Release / Build AWS Lambda Serverless zip image (push) Has been cancelled
Create Release / Create Github Release (push) Has been cancelled
Create Release / Publish to crates.io (push) Has been cancelled
- Upgrade cc and clap - Upgrade libredox and redox_users - Upgrade
rustls and serde_json - Upgrade tokio and toml - Upgrade biome to v2.1.3
- Update CHANGELOG.md to reflect the changes.
v0.36.0
2025-08-01 23:15:44 +02:00
lovasoa d81cd81705 rephrase changelog 2025-08-01 18:45:23 +02:00
lovasoa 2e23cec4a7 Fix OIDC flow: Redirect to initial URL on error
- Store initial URL in OidcLoginState. - Use initial URL when building
redirect response on callback error.
2025-08-01 18:44:02 +02:00
lovasoa 1c3b2c7104 Fix OIDC SSO redirect loop after provider key rotation
This commit adds automatic OIDC provider metadata refresh when token
validation fails. Previously, tokens would become invalid when providers
rotated their signing keys, requiring a manual SQLPage restart to
refresh the metadata.
2025-08-01 18:44:02 +02:00
lovasoa 93812ea1cf Add fast OIDC client refresh on auth errors 2025-08-01 18:44:02 +02:00
lovasoa c24479db86 Improve ID token error message with details 2025-08-01 18:44:02 +02:00
lovasoa 6c45719ea7 Change OIDC token verification to take ownership 2025-08-01 18:44:02 +02:00
lovasoa 9601478de2 Refactor OIDC authentication flow and error handling 2025-08-01 18:44:02 +02:00
lovasoa bd3d0d3a26 Fix multiple OIDC client refresh 2025-08-01 18:44:02 +02:00
lovasoa 644b3f0559 Refactor OIDC client refresh mechanism
Moves client refresh logic into a separate method and uses
request-scoped HTTP client instead of storing AppConfig. This simplifies
the state struct and improves the refresh mechanism's reliability.
2025-08-01 18:44:02 +02:00
lovasoa 4390a86087 OIDC client wrapper exposure 2025-08-01 18:44:02 +02:00
lovasoa b0a5bc7918 Remove state refresh on OIDC callback error 2025-08-01 18:44:02 +02:00
lovasoa 081c310622 Replace Mutex with RwLock for OIDC client
This change switches from std::sync::Mutex to tokio::sync::RwLock for
the OIDC client to avoid deadlocks. The read operations now use a shared
lock while writes remain exclusive.
2025-08-01 18:44:02 +02:00
lovasoa 1df352a2e0 refactor: restructure OIDC middleware for better modularity and
ownership

- Extract request handling logic into standalone async functions -
Replace service ownership with Rc<S> for better memory management -
Simplify get_client() return type to use MutexGuard directly - Add
MiddlewareResponse enum to clarify response handling flow - Move public
path checking to beginning of request pipeline - Reorganize code to
separate concerns and improve readability
2025-08-01 18:44:02 +02:00
lovasoa 746009eead feat: Add support for custom claims in OIDC JWT tokens
This enhancement allows SQLPage to read and utilize custom claims from
JWT tokens generated by OIDC providers, enabling users to store
additional information like roles or permissions that can be used in SQL
queries.

Key changes: - Modified get_token_claims() to accept optional login
state, allowing token verification without requiring active login
session state - Updated nonce verification logic to handle cases where
no login state exists - Refactored OIDC client and token response types
to use more specific generics that support additional claims through
OidcAdditionalClaims - Simplified function signatures by passing
oidc_state instead of separate client and config parameters - Enhanced
error handling in OIDC callback processing with automatic client refresh
- Updated type definitions to properly support custom claim extraction
from tokens

This enables SSO providers to include custom user metadata that SQLPage
can access and use for authorization and personalization in database
queries.
2025-08-01 18:44:02 +02:00
lovasoa 1521fcec15 Increase OIDC client refresh interval to 1 hour 2025-08-01 18:44:02 +02:00
lovasoa 72ddace5c5 Refresh OIDC client periodically 2025-08-01 18:44:02 +02:00
lovasoa 0a5ad91b83 WIP: sso oidc metadata refresh
introduces an async oidc_state.get_client
2025-08-01 18:44:02 +02:00
lovasoa 0763e528de remove useless smart pointers
oidc_state is already shared in an Arc; no need to create new reference
counts for each member
2025-07-31 13:01:00 +02:00
lovasoa 627b4789cb improve sso example (logout + auth custom) 2025-07-30 17:26:11 +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
Ophir LOJKINE 558b578f2a Fix oidc callback for authenticated users (#978)
* Handle OIDC callback for already authenticated users

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

* Fix lifetime annotations and remove unnecessary self references

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

* Move OIDC callback handling after user authentication check

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

* fmt

* fix cursor fuckup

* Move OIDC callback handler to standalone function
2025-07-29 22:50:48 +02:00
lovasoa 4b15bf19b5 Update Keycloak configuration display names to SQLPage SSO Demo 2025-07-29 17:39:53 +02:00
lovasoa 0a313af07b Update CHANGELOG.md 2025-07-29 13:37:11 +02:00
lovasoa 1149560fc3 Update dependency versions in Cargo.lock
- Update windows-targets from 0.53.2 to 0.53.3 - Update libredox from
0.1.6 to 0.1.8 - Update redox_syscall from 0.5.16 to 0.5.17 - Update
rustls from 0.23.30 to 0.23.29 - Update toml from 0.9.2 to 0.9.3
2025-07-29 13:35:41 +02:00
lovasoa 630a9eaef6 fix sso example logout link 2025-07-29 13:35:20 +02:00
lovasoa 92cbdc57a9 Simplify OIDC redirect URL handling and validation
- Remove custom URL building logic in favor of direct URI usage - Make
validate_redirect_url take ownership of the URL string - Remove
now-unnecessary test cases for removed functionality - Add logging for
redirect targets after successful login
2025-07-29 13:34:12 +02:00
Cursor Agent b5d4f4b804 Remove redundant Method::GET from OIDC test requests
Co-authored-by: contact <contact@ophir.dev>
2025-07-28 23:20:52 +00:00
Cursor Agent 435d5230c3 Fix OIDC query parameter preservation and add URL validation
Co-authored-by: contact <contact@ophir.dev>
2025-07-28 23:19:33 +00:00
Cursor Agent ac32222e6c Refactor OIDC redirect URL handling and improve test cases
Co-authored-by: contact <contact@ophir.dev>
2025-07-28 23:15:03 +00:00
Cursor Agent 57fb5cc1fa Fix OIDC redirect to preserve query parameters and prevent open redirects
Co-authored-by: contact <contact@ophir.dev>
2025-07-28 22:57:15 +00:00
lovasoa 7b7e4ccdc0 Escape search input in SQLite FTS queries
The search term is now properly escaped when used in SQLite full-text
search queries to prevent syntax errors with quotes. This ensures
searches containing quotes work correctly.
2025-07-28 18:08:29 +02:00
Ophir LOJKINE 33125565d3 Check for 404 before redirecting on no-extension paths (#972)
* Check for 404 before redirecting on no-extension paths

The commit improves routing logic by checking if a path would result in
a 404

fixes https://github.com/sqlpage/SQLPage/issues/971 before adding a
trailing slash. This prevents unnecessary redirects when a custom 404
handler exists.

* Fix test function signature formatting in routing module (#973)

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

* Simplify path resolution and redirect logic

The shorter code more clearly handles finding files with .sql extensions
and decides whether to add trailing slashes based on index file
presence.

* clippy

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-07-28 17:54:23 +02:00
lovasoa 1860aa8433 v0.36 2025-07-27 23:08:12 +02:00
lovasoa ae30d82917 biome fixes 2025-07-27 00:09:39 +02:00
lovasoa 6704dce04a sqlparser changelog 2025-07-27 00:03:51 +02:00
lovasoa 6e4227381f update sql parser 2025-07-26 23:43:25 +02:00
lovasoa 233cbb8837 update rust dependencies 2025-07-26 23:38:16 +02:00
lovasoa 0d7d58c103 update biome 2025-07-26 23:37:32 +02:00
lovasoa 16ed836782 Chart component: accept numerical values passed as strings in pie
charts.
2025-07-26 23:29:15 +02:00
lovasoa 8a3d51f385 Update CHANGELOG.md 2025-07-25 21:54:40 +02:00
lovasoa be9170d0bb update tabler icons 2025-07-25 21:54:33 +02:00
lovasoa 4af50e847f update tabler to v1.4 2025-07-25 21:49:08 +02:00
lovasoa 1820707591 Update apexcharts.js 2025-07-25 21:45:47 +02:00
lovasoa 630882ef5c remove large file 2025-07-25 21:30:15 +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 57ba206c78 cargo fmt 2025-07-24 23:47:45 +02:00
lovasoa e3334380af Move CLI parsing to separate module
fix potential cli parsing crash
2025-07-24 23:20:10 +02:00
lovasoa 7f7549ec38 fix clippy errors
introduced by https://github.com/sqlpage/SQLPage/pull/943
2025-07-24 22:45:45 +02:00
Ophir LOJKINE a351d6b8fc sso docs: do not mention github, since it is not an oidc provider
github does not implement oidc

see https://github.com/sqlpage/SQLPage/issues/963
2025-07-18 18:09:51 +02:00