Skip to content

Improving custom JWT authentication#3681

Draft
MichaelWagner-blue-zone wants to merge 4 commits into
Azure:mainfrom
MichaelWagner-blue-zone:dev/michaelwagner-blue-zone
Draft

Improving custom JWT authentication#3681
MichaelWagner-blue-zone wants to merge 4 commits into
Azure:mainfrom
MichaelWagner-blue-zone:dev/michaelwagner-blue-zone

Conversation

@MichaelWagner-blue-zone

@MichaelWagner-blue-zone MichaelWagner-blue-zone commented Jun 25, 2026

Copy link
Copy Markdown

Why make this change?

Improving custom JWT authentication.

What is this change?

  • configurable JWT role claim handling (rolesPath, rolesSeparator)
  • optional JWKS URL support for JWT validation (jwksUrl)
  • JWT role normalization during token validation
  • related authorization updates to respect configured role claim types
  • PostgreSQL session-context support for propagated claims
  • a few smaller robustness fixes in the affected components

How was this tested?

  • Integration Tests
  • Unit Tests

Sample Request(s)

  • n/a

MichaelWagner-blue-zone and others added 2 commits June 25, 2026 22:44
Merge missing improvements from origin
* optional JWKS URL support for JWT validation (jwksUrl)
* JWT role normalization during token validation
* related authorization updates to respect configured role claim types
* PostgreSQL session-context support for propagated claims
* a few smaller robustness fixes in the affected components
@MichaelWagner-blue-zone

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Data API Builder’s authentication and authorization pipeline to improve JWT handling (configurable role-claim extraction/normalization and JWKS-based signing key resolution) and adds PostgreSQL session-context propagation for processed claims.

Changes:

  • Adds configurable JWT role claim parsing/normalization (rolesPath, rolesSeparator) and updates authorization to respect configured role claim types.
  • Introduces JWKS URL support for JWT validation and wires in signing-key retrieval during startup/hot-reload configuration.
  • Adds PostgreSQL session-context propagation of processed claims via set_config(...).

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/Service/Startup.cs Configures JWT bearer auth, role-claim behavior, and JWKS fetching during startup.
src/Service.Tests/Authentication/Helpers/WebHostBuilderHelper.cs Updates test host JWT configuration to use configurable role claim type.
src/Core/Resolvers/PostgresQueryBuilder.cs Fixes JSON aggregation typing by casting empty array literal to jsonb.
src/Core/Resolvers/PostgreSqlExecutor.cs Adds PostgreSQL session-context propagation and refactors managed identity token handling.
src/Core/Resolvers/OboSqlTokenProvider.cs Updates authorization-context hashing to respect configured role claim types.
src/Core/Authorization/AuthorizationResolver.cs Updates claim resolution to use configured role claim type while preserving original roles.
src/Core/AuthenticationHelpers/JwtRoleClaimsTransformer.cs Adds role-claim normalization (JSON array + separated string support).
src/Core/AuthenticationHelpers/JwtHttpClientFactory.cs Adds a shared HTTP client factory (incl. optional self-signed cert handling) for JWKS retrieval.
src/Core/AuthenticationHelpers/ConfigureJwtBearerOptions.cs Updates hot-reload JWT bearer configuration to use JWKS and role-claim normalization.
src/Core/AuthenticationHelpers/ClientRoleHeaderAuthenticationMiddleware.cs Hardens principal assignment and maps Generic OAuth provider to JWT bearer scheme.
src/Config/ObjectModel/JwtOptions.cs Expands JWT config model with rolesPath/rolesSeparator/jwksUrl and derived helpers.
src/Config/ObjectModel/DataSource.cs Adds PostgreSqlOptions typed options support.
schemas/dab.draft.schema.json Extends JSON schema to document the new JWT configuration fields.

Comment thread schemas/dab.draft.schema.json Outdated
Comment thread src/Core/Resolvers/PostgreSqlExecutor.cs Outdated
Comment thread src/Core/Resolvers/PostgreSqlExecutor.cs
Comment thread src/Core/Resolvers/PostgreSqlExecutor.cs
Comment thread src/Service/Startup.cs Outdated
Comment thread src/Service/Startup.cs
Comment thread src/Config/ObjectModel/JwtOptions.cs
Comment thread src/Service/Startup.cs Outdated
MichaelWagner-blue-zone and others added 2 commits June 25, 2026 23:09
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@MichaelWagner-blue-zone MichaelWagner-blue-zone changed the title Dev/michaelwagner blue zone Improving custom JWT authentication Jun 28, 2026
@MichaelWagner-blue-zone MichaelWagner-blue-zone marked this pull request as draft June 29, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants