Skip to content

Tighten additionalAllowedDomains API contract#541

Merged
corinagum merged 3 commits intomainfrom
cg/fix-allowlist-plumbing-ts
Apr 27, 2026
Merged

Tighten additionalAllowedDomains API contract#541
corinagum merged 3 commits intomainfrom
cg/fix-allowlist-plumbing-ts

Conversation

@corinagum
Copy link
Copy Markdown
Collaborator

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):

  1. Docstring clarity. App.additionalAllowedDomains, HttpServerOptions, and ServiceTokenValidator constructor 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.
  2. Defensive copy. HttpServer and ServiceTokenValidator no 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.
  3. Tests covering the class of bug Python shipped in Add signin/failure invoke activity support #404: plumbing from HttpServerOptions through HttpServer.initialize() into the ServiceTokenValidator constructor.

Copilot AI review requested due to automatic review settings April 24, 2026 22:49
Copy link
Copy Markdown
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

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 additionalAllowedDomains in AppOptions, HttpServerOptions, and ServiceTokenValidator (bare hostnames only; no URL/wildcard patterns; ['*'] sentinel described).
  • Implemented defensive copying of additionalAllowedDomains in both HttpServer and ServiceTokenValidator.
  • Added unit tests covering (a) defensive-copy behavior and (b) HttpServerOptions -> HttpServer.initialize() -> ServiceTokenValidator allowlist 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.

Comment thread packages/apps/src/middleware/auth/service-token-validator.ts
Comment thread packages/apps/src/http/http-server.ts Outdated
Comment thread packages/apps/src/app.ts Outdated
corinagum and others added 2 commits April 27, 2026 13:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@corinagum corinagum force-pushed the cg/fix-allowlist-plumbing-ts branch from 308e2af to 81d9240 Compare April 27, 2026 20:31
heyitsaamir
heyitsaamir previously approved these changes Apr 27, 2026
Comment thread packages/apps/src/http/http-server.ts Outdated
Comment thread packages/apps/src/middleware/auth/service-token-validator.ts
@corinagum corinagum merged commit 574bc3a into main Apr 27, 2026
6 checks passed
@corinagum corinagum deleted the cg/fix-allowlist-plumbing-ts branch April 27, 2026 21:34
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.

3 participants