From 1455a88c6626f1ddad5ef971017d278184376fee Mon Sep 17 00:00:00 2001 From: Taimoor Zaeem Date: Thu, 16 Apr 2026 11:16:35 +0500 Subject: [PATCH 1/2] add: config `jwt-schema-claim-key` for schema selection in JWT It follows the same JSPath grammar as `jwt-role-claim-key`. If the schema is specified in JWT claims, it overides the `Accept-Profile` and `Content-Profile` headers. Signed-off-by: Taimoor Zaeem --- CHANGELOG.md | 1 + docs/postgrest.dict | 3 +- docs/references/api/schemas.rst | 16 +++++++++ docs/references/auth.rst | 2 ++ docs/references/configuration.rst | 15 ++++++++ src/PostgREST/ApiRequest.hs | 32 +++++++++++------ src/PostgREST/App.hs | 2 +- src/PostgREST/Auth/Jwt.hs | 6 ++-- src/PostgREST/Auth/Types.hs | 3 ++ src/PostgREST/Config.hs | 15 +++++++- src/PostgREST/Config/Database.hs | 1 + src/PostgREST/Config/JSPath.hs | 6 ++++ test/io/configs/expected/aliases.config | 1 + .../configs/expected/boolean-numeric.config | 1 + .../io/configs/expected/boolean-string.config | 1 + test/io/configs/expected/defaults.config | 1 + .../expected/jspath-str-op-dump1.config | 1 + .../expected/jspath-str-op-dump2.config | 1 + .../expected/jspath-str-op-dump3.config | 1 + .../expected/jspath-str-op-dump4.config | 1 + .../expected/jspath-str-op-dump5.config | 1 + ...efaults-with-db-other-authenticator.config | 1 + .../expected/no-defaults-with-db.config | 1 + test/io/configs/expected/no-defaults.config | 1 + test/io/configs/expected/types.config | 1 + test/io/configs/expected/utf-8.config | 1 + test/io/configs/no-defaults-env.yaml | 1 + test/io/configs/no-defaults.config | 1 + test/io/fixtures/db_config.sql | 2 ++ test/io/fixtures/fixtures.yaml | 34 +++++++++++++++++++ test/io/fixtures/privileges.sql | 1 + test/io/fixtures/schema.sql | 10 ++++++ test/io/test_auth.py | 18 ++++++++++ test/io/test_cli.py | 14 ++++++++ test/observability/ObsHelper.hs | 1 + test/spec/SpecHelper.hs | 1 + 36 files changed, 184 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43807eb014..a666876bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file. From versio - Add `Vary` header to responses by @develop7 in #4609 - Add config `db-timezone-enabled` for optional querying of timezones by @taimoorzaeem in #4751 - Log when the pool is released during schema cache reload on `log-level=debug` by @mkleczek in #4668 +- Add config `jwt-schema-claim-key` for schema selection in JWT by @taimoorzaeem in #4608 ### Fixed diff --git a/docs/postgrest.dict b/docs/postgrest.dict index 355c72dccb..33538ed77f 100644 --- a/docs/postgrest.dict +++ b/docs/postgrest.dict @@ -92,6 +92,7 @@ lte macOS misprediction multi +multitenancy namespace namespaced Nanos @@ -200,4 +201,4 @@ webuser wfts www debouncing -deduplicates \ No newline at end of file +deduplicates diff --git a/docs/references/api/schemas.rst b/docs/references/api/schemas.rst index 63cc78a831..4583d07bff 100644 --- a/docs/references/api/schemas.rst +++ b/docs/references/api/schemas.rst @@ -41,6 +41,8 @@ Only the selected schema gets added to the `search_path