fix: bypass JWT middleware for health endpoint in Python agent-framework sample#222
Open
pratapladhani wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: bypass JWT middleware for health endpoint in Python agent-framework sample#222pratapladhani wants to merge 1 commit intomicrosoft:mainfrom
pratapladhani wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…ork sample Container orchestrators (Azure Container Apps, Kubernetes, App Service) send unauthenticated health probes to /api/health. When agentic authentication is enabled, jwt_authorization_middleware rejects these probes with 401, causing the platform to consider the container unhealthy. Wrap the JWT middleware so requests to /api/health pass through without token validation while all other routes remain protected. Fixes microsoft#186
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a critical production deployment issue where container orchestrators (Azure Container Apps, Kubernetes, App Service) fail health checks because the /api/health endpoint requires JWT authentication. The fix wraps the existing JWT middleware to bypass token validation specifically for the health endpoint while keeping all other routes protected.
Changes:
- Modified JWT middleware in
python/agent-framework/sample-agent/host_agent_server.pyto wrapjwt_authorization_middlewarewith conditional bypass logic for/api/health - Added inline documentation explaining the bypass is needed for container orchestrator health probes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When agentic authentication is enabled,
jwt_authorization_middlewarerejects all unauthenticated requests - including health probes from container orchestrators (Azure Container Apps, Kubernetes, App Service) hitting/api/health. The platform marks the container as unhealthy and restarts or decommissions it.Fix
Wrap the existing JWT middleware so that requests to
/api/healthpass through without token validation, while all other routes remain protected.Scope
python/agent-framework/sample-agent/host_agent_server.pyTesting
Validated during Azure Container Apps deployment - health probes now return 200 while
/api/messagesremains JWT-protected.Fixes #186 (partial - addresses the health probe failure mode)