Skip to content

Fix validation-level authorization with multiple schemas - #10824

Merged
glen-84 merged 3 commits into
mainfrom
gai/validation-authorization-multiple-schemas
Nov 9, 2026
Merged

glen-84 merged 3 commits into
mainfrom
gai/validation-authorization-multiple-schemas

Conversation

@glen-84

@glen-84 glen-84 commented Nov 9, 2026

Copy link
Copy Markdown
Member

Summary

  • AddAuthorizationCore creates the authorization cache for each schema's validation rule instead of registering one in the application services.
  • An application that hosts several schemas with ApplyPolicy.Validation policies authorizes each request against the policies of the schema it runs on.

Test plan

  • Authorize_Validation_With_Multiple_Schemas covers two schemas in one application with different validation-level policies.
  • Ran on net10.0: HotChocolate.Authorization.Tests, HotChocolate.AspNetCore.Authorization.Tests, and HotChocolate.AspNetCore.Authorization.Opa.Tests.

Copilot AI lite review requested due to automatic review settings November 9, 2026 13:09

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.

🟢 Approval recommended

No active review issues are reported, and the change includes targeted regression coverage for schema-specific authorization behavior.

No open issues 🎉

What changed in this PR

This pull request fixes validation-level authorization for applications hosting multiple GraphQL schemas by isolating authorization directive caches per schema.

Changes:

  • Creates an AuthorizationCache for each schema’s authorization validation rule.
  • Adds regression coverage for two schemas with different validation-level policies.
File Description
src/​HotChocolate/​Core/​test/​Authorization.Tests/​CodeFirstAuthorizationTests.cs Verifies independent validation authorization behavior across multiple schemas.
src/​HotChocolate/​Core/​src/​Authorization/​Extensions/​AuthorizeRequestExecutorBuilder.cs Scopes authorization directive caching to each schema’s validation rule.

Review effort: Lite

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (1/1)

File Covered Changed Patch %
…/Authorization/Extensions/AuthorizeRequestExecutorBuilder.cs 1 1 100.0% 🟢

Project coverage: 59.5% (321568/540802 lines)

@glen-84
glen-84 merged commit 7d785cb into main Nov 9, 2026
159 checks passed
@glen-84
glen-84 deleted the gai/validation-authorization-multiple-schemas branch November 9, 2026 17:04
glen-84 added a commit that referenced this pull request Nov 9, 2026
glen-84 added a commit that referenced this pull request Nov 9, 2026
glen-84 added a commit that referenced this pull request Nov 10, 2026
glen-84 added a commit that referenced this pull request Nov 10, 2026
This was referenced Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants