Skip to content

arch: Teams adapter breaking async factory change — migration guide + token security review #862

Closed

Description

@diberry

Problem

Breaking change: PR #768 changed \createCommunicationAdapter\ from sync to async with no migration guide or deprecation period.

Security gaps identified:

  1. Module-level cached auth token — no tenant isolation
  2. No revoke/logout mechanism — tokens persist indefinitely
  3. No device-code auth timeout guard — could hang indefinitely on failed auth flow
  4. Token not cleared on error — stale/invalid token reused

Impact

  • Existing code calling \createCommunicationAdapter\ synchronously will break
  • Teams adapter could authenticate as wrong tenant in multi-tenant deployments
  • Hung auth flows with no timeout could freeze the CLI
  • Logout not possible without restarting the process

Proposed solution

  1. Migration guide: Document breaking change, provide examples of async/await migration, suggest codemods or deprecation warnings

  2. Token security:

    • Tenant-scoped token cache (isolate by tenant ID)
    • Explicit revoke() method for logout
    • Device-code timeout guard (e.g., 15min max)
    • Clear token on auth error, not reuse
  3. Testing: Multi-tenant scenarios, timeout conditions, token lifecycle

Success criteria

  • Migration guide published
  • Token cache is tenant-scoped
  • Logout (revoke) mechanism implemented
  • Device-code flow has timeout guard
  • Stale tokens are not reused

Activity

  1. diberry commented on Apr 6, 2026

    @diberry
    ContributorAuthor

    ✈️ Flight — Issue-Level PRD

    Summary

    PR #768 changed createCommunicationAdapter from sync to async with no migration guide, deprecation period, or token security hardening. This PRD covers the migration guide for the breaking change and addresses four token security gaps (no tenant isolation, no revoke mechanism, no auth timeout, stale token reuse).

    Problem Statement

    • Breaking change: Existing code calling createCommunicationAdapter synchronously will break with no guidance
    • Token security: Module-level cached auth token has no tenant isolation — wrong tenant in multi-tenant deployments
    • No revoke: Tokens persist indefinitely with no logout mechanism
    • No timeout: Device-code auth flow could hang indefinitely on failed auth
    • Stale tokens: Token not cleared on auth error — invalid token reused on retry

    Proposed Approach

    Phase 1 — Migration Guide + Deprecation (P0)

    • Document the sync→async breaking change with before/after code examples
    • Add runtime deprecation warning if sync call pattern is detected (if feasible)
    • Update CHANGELOG and any samples that use the sync API
    • Add migration section to docs/ or UPGRADING.md

    Phase 2 — Token Security Hardening (P1)

    • Tenant-scoped token cache: key tokens by tenant ID, not global singleton
    • Explicit revoke() method on the adapter for logout/cleanup
    • Device-code timeout guard: 15-minute max, configurable, clear error on timeout
    • Clear token on auth error — force re-auth on next call

    Phase 3 — Multi-Tenant Testing (P2)

    • Integration tests: two tenants, verify tokens are isolated
    • Timeout test: device-code flow with simulated timeout
    • Token lifecycle test: auth → error → clear → re-auth

    Acceptance Criteria

    • Migration guide published with sync→async examples and codemods
    • CHANGELOG updated for the breaking change
    • Token cache is tenant-scoped (keyed by tenant ID)
    • revoke() method implemented and documented
    • Device-code flow has configurable timeout (default 15 min)
    • Stale tokens cleared on auth error
    • Multi-tenant integration test passes
    • Timeout integration test passes

    Architecture Notes

  2. added 2 commits that reference this issue on Apr 7, 2026
    0335a57
    032df44
  3. diberry commented on Apr 10, 2026

    @diberry
    ContributorAuthor

    🔒 On hold — focusing on low-touch and medium-touch issues first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions