From ac5dafcd9c4efa7a6d8252c5ba947494b99ad08d Mon Sep 17 00:00:00 2001 From: CeciliaAvila Date: Thu, 12 Mar 2026 15:44:09 -0300 Subject: [PATCH 1/2] Add a warning before using anonymous identity --- packages/agents-hosting/src/cloudAdapter.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/agents-hosting/src/cloudAdapter.ts b/packages/agents-hosting/src/cloudAdapter.ts index 7a467e6a9..948d7316e 100644 --- a/packages/agents-hosting/src/cloudAdapter.ts +++ b/packages/agents-hosting/src/cloudAdapter.ts @@ -126,6 +126,7 @@ export class CloudAdapter extends BaseAdapter { headers?: HeaderPropagationCollection) { if (!identity?.aud) { // anonymous + logger.warn('Missing request identity or identity.aud. Creating connector client for anonymous identity') return ConnectorClient.createClientWithToken( activity.serviceUrl!, null!, @@ -318,6 +319,9 @@ export class CloudAdapter extends BaseAdapter { * @param res - The response to send. * @param logic - The logic to execute. * @param headerPropagation - Optional function to handle header propagation. + * + * @remarks This function assumes the request has already been authenticated and the user identity is available on request.user. + * For request authentication, use the authorizeJWT middleware. */ public async process ( request: Request, From 91481f7636749cb49e2ab3b4e9428a5178e6a526 Mon Sep 17 00:00:00 2001 From: CeciliaAvila Date: Fri, 13 Mar 2026 10:45:00 -0300 Subject: [PATCH 2/2] Update warning message and method remarks --- packages/agents-hosting/src/cloudAdapter.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/agents-hosting/src/cloudAdapter.ts b/packages/agents-hosting/src/cloudAdapter.ts index 948d7316e..a259cee09 100644 --- a/packages/agents-hosting/src/cloudAdapter.ts +++ b/packages/agents-hosting/src/cloudAdapter.ts @@ -126,7 +126,7 @@ export class CloudAdapter extends BaseAdapter { headers?: HeaderPropagationCollection) { if (!identity?.aud) { // anonymous - logger.warn('Missing request identity or identity.aud. Creating connector client for anonymous identity') + logger.warn('Missing identity or identity.aud when creating connector client. Using anonymous identity') return ConnectorClient.createClientWithToken( activity.serviceUrl!, null!, @@ -320,8 +320,9 @@ export class CloudAdapter extends BaseAdapter { * @param logic - The logic to execute. * @param headerPropagation - Optional function to handle header propagation. * - * @remarks This function assumes the request has already been authenticated and the user identity is available on request.user. - * For request authentication, use the authorizeJWT middleware. + * @remarks This function supports both authenticated and unauthenticated requests. When the request is not authenticated, + * the adapter will use anonymous identity. For authenticated requests, the adapter relies on the presence of a user identity + * on `request.user`. It is strongly recommended to use the `authorizeJWT` middleware to ensure that requests are correctly authenticated. */ public async process ( request: Request,