Fix allowlist plumbing through through TokenValidator#404
Merged
Conversation
lilyydu
approved these changes
Apr 24, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes a regression where additional_allowed_domains configured on App(...) was not applied during JWT token validation, causing valid non-default service URLs (e.g. canary) to be rejected before reaching the server-level allowlist check.
Changes:
- Thread
additional_allowed_domainsthroughTokenValidator(__init__,for_service,for_entra) and enforce it invalidate_token. - Forward the allowlist from
HttpServer.initializeandApp.__init__into the token validator construction. - Add unit tests covering the “auth on + non-default service URL” path and verify
HttpServer.initializeforwards the allowlist.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/apps/src/microsoft_teams/apps/auth/token_validator.py | Plumbs allowlist into TokenValidator and uses it during validate_token service URL checks. |
| packages/apps/src/microsoft_teams/apps/http/http_server.py | Forwards server-configured additional_allowed_domains into TokenValidator.for_service(...). |
| packages/apps/src/microsoft_teams/apps/app.py | Forwards app option additional_allowed_domains into TokenValidator.for_entra(...). |
| packages/apps/tests/test_token_validator.py | Adds coverage proving validate_token honors/rejects based on additional_allowed_domains, including wildcard behavior and factory plumbing. |
| packages/apps/tests/test_http_server.py | Adds a regression test ensuring HttpServer.initialize passes the allowlist to TokenValidator.for_service. |
This was referenced Apr 24, 2026
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.
App(additional_allowed_domains=[...])was silently ignored at the token-validation layer, rejecting user-approved service URLs (e.g.canary.botapi.skype.com) before they ever reached the allowlist-aware check inHttpServer.handle_request.Fix threads the allowlist through
TokenValidator.__init__, both factory methods (for_service,for_entra), and thevalidate_tokencall site. UpdatesHttpServer.initializeandApp.__init__to forward the option.Why unit tests missed it
All existing
additional_allowed_domainstests usedskip_auth=True, which bypasses theTokenValidatorcode path entirely. The helper functionis_allowed_service_urlhad direct tests with 3 args, so the function itself was fine — just no test proved the code calling it in the auth-on path was also using 3 args. E2E validation was against default service url, which is in the built-in allowlist and doesn't need the knob. The intersection of "auth on" AND "non-default service URL" had zero coverage.Tests
test_token_validator.py:test_validate_token_honors_additional_allowed_domains— canary accepted when in allowlisttest_validate_token_rejects_when_domain_not_in_allowlist— baseline: canary rejected without the knobtest_validate_token_wildcard_allows_arbitrary_domain—["*"]disables the check at the token-validation layertest_for_service_stores_additional_allowed_domains/test_for_entra_stores_additional_allowed_domains— factory plumbingtest_http_server.py:test_initialize_forwards_allowlist_to_token_validator— spiesTokenValidator.for_serviceand asserts it's called with the allowlist (catches the exact regressionclass)
All 67 tests pass.
Test plan
uv run pytest packages/apps/tests/test_token_validator.py packages/apps/tests/test_http_server.py— 67/67uv run poe check— cleanuv run pyright— no new errorshttps://canary.botapi.skype.com/amer/...passes token validation and reachesonMessage(previously 401'd)smba.trafficmanager.netstill works