Skip to content

Fix Keycloak HTTPS primary endpoint#17058

Merged
danegsta merged 1 commit into
microsoft:mainfrom
danegsta:danegsta-microsoft/fix-keycloak-https-endpoint
May 13, 2026
Merged

Fix Keycloak HTTPS primary endpoint#17058
danegsta merged 1 commit into
microsoft:mainfrom
danegsta:danegsta-microsoft/fix-keycloak-https-endpoint

Conversation

@danegsta
Copy link
Copy Markdown
Member

Description

Update the primary Keycloak endpoint to HTTPS rather than simply adding a second HTTPS endpoint when the dev certificate is enabled. This is a breaking change, but fixes an issue where the Keycloak HTTPS endpoint isn't stable leading to previously issued tokens to become invalid on restart.

Fixes #16979

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 13, 2026 21:56
@danegsta danegsta added the breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. label May 13, 2026
{
private const string DefaultAdmin = "admin";
internal const string PrimaryEndpointName = "tcp";
internal const string PrimaryEndpointName = "http";
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This changes the endpoint name to "http" to better match our service discovery URL behavior (and make the HTTPS scheme update behave reliably).

@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 -- 17058

Or

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 changes Keycloak’s HTTPS handling so the existing primary endpoint is switched to HTTPS when certificate support is enabled, instead of adding a separate HTTPS endpoint. This aligns the configured host port with the endpoint used by clients and helps avoid token issuer mismatches after AppHost restarts.

Changes:

  • Switches the Keycloak primary endpoint name constant to the existing "http" endpoint.
  • Updates HTTPS certificate handling to mutate the primary endpoint to HTTPS on target port 8443.
  • Adds a unit test covering primary endpoint mutation and KC_HTTPS_PORT configuration.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Aspire.Hosting.Keycloak/KeycloakResource.cs Updates the internal primary endpoint name used by Keycloak configuration.
src/Aspire.Hosting.Keycloak/KeycloakResourceBuilderExtensions.cs Changes run-mode HTTPS setup to mutate the primary endpoint and configure Keycloak’s HTTPS port.
tests/Aspire.Hosting.Keycloak.Tests/KeycloakResourceBuilderTests.cs Adds coverage for HTTPS primary endpoint behavior when a certificate annotation is present.

@github-actions
Copy link
Copy Markdown
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@danegsta danegsta merged commit cfab3c5 into microsoft:main May 13, 2026
583 of 586 checks passed
@github-actions github-actions Bot added this to the 13.4 milestone May 13, 2026
@danegsta
Copy link
Copy Markdown
Member Author

/backport to release/13.3

@github-actions
Copy link
Copy Markdown
Contributor

Started backporting to release/13.3 (link to workflow run)

JamesNK pushed a commit that referenced this pull request May 14, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Issue or PR that represents a breaking API or functional change over a prerelease.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AddKeycloak HTTPS endpoint port changes on AppHost restart, causing token issuer mismatch (IDX10205)

3 participants