Skip to content

Conversation

@madebygps
Copy link
Collaborator

This pull request enhances the Keycloak authentication configuration by introducing a new environment variable for the Keycloak token issuer and improving the robustness of environment variable extraction scripts. The main goal is to allow the token issuer to be explicitly set, which provides more flexibility and better alignment with various Keycloak deployment scenarios. Additionally, the scripts that generate environment files now filter out error messages from azd commands, preventing invalid values from being written.

Keycloak authentication improvements:

  • Added support for explicitly specifying the Keycloak token issuer via a new KEYCLOAK_TOKEN_ISSUER environment variable, which is now passed through the deployment pipeline and used by the server for JWT verification. If not set, it defaults to the realm URL. [1] [2] [3] [4] [5]

Deployment script robustness:

  • Updated write_env.ps1 and write_env.sh to filter out error messages from azd output when retrieving environment variables, preventing invalid values (such as error strings) from being written to the .env file. This was applied to Keycloak and Entra Proxy related variables. [1] [2]
  • update spanish readme

…in .env

Add KEYCLOAK_TOKEN_ISSUER to fix JWT validation when Keycloak is behind HTTP routes:
- Bicep: Pass keycloakTokenIssuer from main.bicep to server.bicep
- Server: Set KEYCLOAK_TOKEN_ISSUER env var with fallback to KEYCLOAK_REALM_URL
- Python: Use separate issuer URL for token validation vs realm URL for JWKS

Fix write_env scripts to handle azd error output:
- azd writes "ERROR: key not found" to stdout instead of stderr
- Filter ERROR messages before writing to .env file
- Prevents error text from polluting local environment files
Copy link
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 pull request enhances the Keycloak authentication configuration by adding support for explicitly specifying the token issuer and improves the robustness of environment variable extraction scripts. The changes allow for more flexible Keycloak deployments where the token issuer URL differs from the realm URL, while also preventing error messages from being written to .env files.

Key Changes:

  • Added KEYCLOAK_TOKEN_ISSUER environment variable support throughout the deployment pipeline, with proper fallback to KEYCLOAK_REALM_URL when not set
  • Implemented error message filtering in environment generation scripts (write_env.sh and write_env.ps1) to prevent invalid values from being written when azd commands fail
  • Updated the Spanish README with comprehensive documentation covering all deployment scenarios and usage instructions

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
spanish/README.md Complete translation update with expanded documentation for all deployment scenarios, local development, and authentication configurations
servers/auth_mcp.py Added KEYCLOAK_TOKEN_ISSUER environment variable retrieval with fallback to KEYCLOAK_REALM_URL for JWT verification
infra/write_env.sh Added error message filtering for Keycloak and Entra Proxy variables, plus support for writing KEYCLOAK_TOKEN_ISSUER to .env
infra/write_env.ps1 PowerShell version of error filtering and KEYCLOAK_TOKEN_ISSUER support, maintaining parity with bash script
infra/server.bicep Added keycloakTokenIssuer parameter and environment variable configuration with conditional fallback logic
infra/main.bicep Added keycloakTokenIssuer parameter passing to server module and output variable for environment scripts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

madebygps and others added 2 commits December 10, 2025 23:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@madebygps madebygps merged commit 867161e into Azure-Samples:main Dec 11, 2025
8 checks passed
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.

2 participants