Tighten additionalAllowedDomains API contract#541
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Tightens and clarifies the additionalAllowedDomains allowlist contract across the Apps package’s HTTP/auth pipeline, adds defensive copying to prevent post-construction mutation from changing runtime validation behavior, and introduces tests to guard the plumbing and regression scenario.
Changes:
- Clarified JSDoc for
additionalAllowedDomainsinAppOptions,HttpServerOptions, andServiceTokenValidator(bare hostnames only; no URL/wildcard patterns;['*']sentinel described). - Implemented defensive copying of
additionalAllowedDomainsin bothHttpServerandServiceTokenValidator. - Added unit tests covering (a) defensive-copy behavior and (b)
HttpServerOptions -> HttpServer.initialize() -> ServiceTokenValidatorallowlist plumbing.
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/middleware/auth/service-token-validator.ts | Adds constructor JSDoc and defensively copies additionalAllowedDomains. |
| packages/apps/src/middleware/auth/service-token-validator.spec.ts | Adds regression tests for defensive copying and undefined/empty allowlist handling. |
| packages/apps/src/http/http-server.ts | Adds HttpServerOptions JSDoc and defensively copies additionalAllowedDomains. |
| packages/apps/src/http/http-server.spec.ts | Adds tests to ensure allowlist is passed to the validator and is defensively copied. |
| packages/apps/src/app.ts | Updates public AppOptions.additionalAllowedDomains JSDoc to clarify contract. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
308e2af to
81d9240
Compare
heyitsaamir
previously approved these changes
Apr 27, 2026
heyitsaamir
approved these changes
Apr 27, 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.
Follow-up to the allowlist feature (shipped via #515). No runtime behavior change for correct callers. Adds hardening informed by review feedback on the sibling Python PR (microsoft/teams.py#404):
App.additionalAllowedDomains,HttpServerOptions, andServiceTokenValidatorconstructor all document that entries must be bare hostnames matched exactly (case-insensitive); wildcard patterns like*.example.com, URL suffixes, and full URLs are NOT supported.['*']is the sole wildcard, used as a disable-validation sentinel.HttpServerandServiceTokenValidatorno longer store the caller's array by reference. A post-construction mutation of the caller's array would previously have changed validator behavior at runtime; now it is isolated.HttpServerOptionsthroughHttpServer.initialize()into theServiceTokenValidatorconstructor.