Skip to content

auth

Inbound and outbound authentication for the Teams messaging endpoint.

POST /api/teams/messages is a PUBLIC URL - Azure Bot Service calls it from the internet, so it cannot sit behind AppKit’s OBO headers or a workspace login. Its only trust boundary is the JWT the Bot Service signs each request with, which is what this module verifies:

  1. fetch the Bot Framework OpenID metadata to discover the signing JWKS;
  2. verify the token’s signature against that key set;
  3. check issuer is a known Bot Service issuer and audience is exactly this bot’s app id.

All three matter. Skipping (3) is the classic bot vulnerability: a token the Bot Service legitimately issued for a DIFFERENT bot still verifies against the same JWKS, so without an audience check anyone with their own bot could drive this agent.

The outbound half is the reverse: replies go to the Connector API, which needs a client-credentials token for the bot’s own app registration. Both key sets and tokens are cached, since a busy channel would otherwise re-fetch metadata on every turn.