Skip to content

Fix JWT validator issuer validation and audience matching#469

Open
heyitsaamir wants to merge 2 commits intomainfrom
fix/jwt-validator-issuer-audience
Open

Fix JWT validator issuer validation and audience matching#469
heyitsaamir wants to merge 2 commits intomainfrom
fix/jwt-validator-issuer-audience

Conversation

@heyitsaamir
Copy link
Collaborator

@heyitsaamir heyitsaamir commented Mar 8, 2026

Summary

  • Fix issuer validation bug: validateIssuer: { allowedTenantIds: undefined } was incorrectly treated as configured validation.
  • Add api://botid-{clientId} to default audience list for bot token validation since this is a really common, default value of the application id uri.
  • Add optional audience field to IJwtValidationOptions for custom audience values beyond the defaults (clientId, api://clientId, api://botid-clientId).

Test plan

  • Verify tokens with api://botid-{clientId} audience are accepted
  • Verify createEntraTokenValidator without explicit allowedTenantIds no longer rejects valid tokens
  • Existing JWT validator tests pass

- Fix validateIssuer treating {allowedTenantIds: undefined} as configured
  validation (JSON.stringify hides undefined keys but `in` operator still
  finds them). Now checks the actual value, not just key presence.
- Add api://botid-{clientId} to default audience list for bot token
  validation.
- Add optional `audience` field to IJwtValidationOptions for custom
  audience values beyond the defaults.
- Add applicationIdUri to AppOptions, matching webApplicationInfo.resource
  in the Teams app manifest
- Wire through createEntraTokenValidator to JwtValidator.audience
- Add tests for audience validation (default audiences, custom, rejection)
- Add tests for issuer validation edge cases (empty object, undefined/empty
  allowedTenantIds)
- Add tests for applicationIdUri in createEntraTokenValidator factory
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