Skip to content

Reject registration-only configuration on existing Entra references - #21493

Merged
Eric Erhardt (eerhardt) merged 1 commit into
mainfrom
eerhardt-entra-existing-reference-guards
Nov 2, 2026
Merged

Eric Erhardt (eerhardt) merged 1 commit into
mainfrom
eerhardt-entra-existing-reference-guards

Conversation

@eerhardt

Copy link
Copy Markdown
Member

Description

Registration-only Entra configuration currently accepts existing registrations and silently does nothing, leaving applications to fail later during authentication. Fail at the configuration call instead, with guidance for configuring the registration manually.

Guard redirect URIs, owners, ID-token issuance, pre-authorization, admin consent, and the default application ID URI. Align existing role, certificate, and federation errors, and reject incompatible settings before AsExistingApplication changes resource state. Cover both fluent orders, run/publish modes, and polyglot adapters.

Consumer configuration remains supported, including audiences, credentials, explicit API URI/scope metadata, and downstream API permissions. Created registrations can still consent to existing APIs or pre-authorize existing clients. Preserve the distinction between fluent conversion retaining Azure setup and AddExistingEntraApplication not enabling provisioning.

Update XML/ATS documentation and the README. No Azure core changes, Key Vault resource-reference changes, or new dependencies.

Fixes #21256

User-facing usage

Describe an existing API using its registered URI; consumer audience configuration remains supported.

var api = builder.AddExistingEntraApplication("entra-api", tenantId, clientId)
    .WithApplicationIdUri("api://existing")
    .WithAudience("api://existing");
const api = await builder.addExistingEntraApplication("entra-api", tenantId, clientId)
    .withApplicationIdUri("api://existing")
    .withAudience("api://existing");

Behavior change

Registration-only calls that previously did nothing on existing references now throw InvalidOperationException. AsExistingApplication also rejects registration-only settings applied before conversion, including mode-specific certificate/federation setup. Configure those settings manually on the existing registration and retain only consumer configuration in the AppHost. Existing API references must supply their registered URI rather than call parameterless WithApplicationIdUri().

Validation

  • Passed: dotnet test --project tests\Aspire.Hosting.Azure.EntraId.Tests\Aspire.Hosting.Azure.EntraId.Tests.csproj --no-launch-profile -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" — 628 tests passed.
  • Passed: git diff --check.
  • Existing System.Security.Cryptography.Xml NuGet advisory warnings remain. No live Azure deployments or directory/permission changes were performed.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21493

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21493"

@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot October 30, 2026 20:34
@github-actions github-actions Bot added the area-integrations Issues pertaining to Aspire Integrations packages label Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

2 / 100 PR test projects · 2 PR jobs, from 6 changed files.

Selected PR test projects (2 / 100)

Aspire.Hosting.Azure.EntraId.Tests, Aspire.Hosting.Azure.Tests

Selected PR jobs (2)

polyglot, typescript-api-compat


How these were chosen — grouped by what changed

🔧 src/Aspire.Hosting.Azure.EntraId/EntraIdApplicationResource.cs (changed source)
→ 2 directly: Aspire.Hosting.Azure.EntraId.Tests, Aspire.Hosting.Azure.Tests

🔧 src/Aspire.Hosting.Azure.EntraId/EntraIdResourceExtensions.cs (changed source)
→ 2 directly: Aspire.Hosting.Azure.EntraId.Tests, Aspire.Hosting.Azure.Tests

🧪 tests/Aspire.Hosting.Azure.EntraId.Tests/EntraIdApiProvisioningTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Azure.EntraId.Tests

🧪 tests/Aspire.Hosting.Azure.EntraId.Tests/EntraIdPolyglotTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Azure.EntraId.Tests

🧪 tests/Aspire.Hosting.Azure.EntraId.Tests/EntraIdProvisioningTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Azure.EntraId.Tests

🧪 tests/Aspire.Hosting.Azure.EntraId.Tests/MicrosoftIdentityWebConfigurationTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Azure.EntraId.Tests

Job reasons

Job Triggered by
polyglot affected project Aspire.Hosting.Azure.EntraId
typescript-api-compat affected project Aspire.Hosting.Azure.EntraId

Selection computed for commit a93c431.

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 block approval of the existing-registration configuration changes.

No open issues 🎉

What changed in this PR

Addresses #21256 by rejecting registration-only configuration on existing Entra registrations at configuration time, while preserving consumer settings and explicit API metadata.

Changes:

  • Adds consistent, actionable errors and validates incompatible settings before AsExistingApplication changes resource state.
  • Expands tests across fluent call orders, run/publish modes, and polyglot adapters.
  • Updates XML documentation and the README to distinguish registration provisioning from consumer configuration.
File Description
tests/​Aspire.Hosting.Azure.EntraId.Tests/​MicrosoftIdentityWebConfigurationTests.cs Verifies consumer configuration survives conversion to an existing registration.
tests/​Aspire.Hosting.Azure.EntraId.Tests/​EntraIdProvisioningTests.cs Tests registration-only rejection and unchanged resource state after failures.
tests/​Aspire.Hosting.Azure.EntraId.Tests/​EntraIdPolyglotTests.cs Covers existing-registration consumer configuration in run and publish modes.
tests/​Aspire.Hosting.Azure.EntraId.Tests/​EntraIdApiProvisioningTests.cs Tests default URI rejection and preservation of supported API metadata.
src/​Aspire.Hosting.Azure.EntraId/​README.md Explains supported settings, manual configuration, and provisioning distinctions.
src/​Aspire.Hosting.Azure.EntraId/​EntraIdResourceExtensions.cs Guards registration-only calls and updates XML and polyglot documentation.
src/​Aspire.Hosting.Azure.EntraId/​EntraIdApplicationResource.cs Centralizes validation and tracks mode-specific provisioning intent.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@mitchdenny Mitch Denny (mitchdenny) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good from a surface-level API and security review. Failing early for registration-only configuration on existing references is clearer than silently ignoring it, and checking before conversion while retaining run/publish-specific configuration intent is a good safeguard. No blocking issues identified in this review.

@eerhardt
Eric Erhardt (eerhardt) merged commit 9f0961d into main Nov 2, 2026
111 of 114 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Nov 2, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2027

Generated by PR Documentation Check · copilot · auto · 34.4 AIC · ⌖ 1.15 AIC · ⊞ 7.1K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2027 targeting release/17.0.

Added a new page integrations/security/microsoft-entra-id.mdx documenting existing Entra references and the new rejection of registration-only configuration. Triggered signals: integration_readme_changed (Aspire.Hosting.Azure.EntraId/README.md), pr_body_has_user_facing_section, pr_body_has_cli_flag_mention. Please verify wording against the README.

Note

This draft PR needs human review before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Entra ID: throw when registration-only APIs are used with existing registrations

3 participants