allow detour auth#1374
Conversation
PR Summary by QodoAllow anonymous connector auth in Teams plugin (DEBUG) and ensure per-turn HttpContext
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Unvalidated ServiceUrl usage
|
| public Task<IConnectorClient> CreateConnectorClientAsync(ITurnContext turnContext, string? audience = null, IList<string>? scopes = null, bool useAnonymous = false, CancellationToken cancellationToken = default) | ||
| #pragma warning disable CS0618 // intentionally using the legacy overload to bypass the agentic branch | ||
| => inner.CreateConnectorClientAsync(turnContext.Identity, turnContext.Activity.ServiceUrl, audience, cancellationToken, scopes, true); | ||
| #pragma warning restore CS0618 |
There was a problem hiding this comment.
1. Unvalidated serviceurl usage 📘 Rule violation ☼ Reliability
AnonymousDebugChannelServiceClientFactory.CreateConnectorClientAsync(ITurnContext ...) passes turnContext.Activity.ServiceUrl (and turnContext.Identity) to connector creation without null/empty/state checks. This can cause exception-driven control flow at an integration boundary instead of a safe, deterministic failure.
Agent Prompt
## Issue description
The debug `IChannelServiceClientFactory` implementation forwards `turnContext.Identity` and `turnContext.Activity.ServiceUrl` to `RestChannelServiceClientFactory` without validating they are present/valid, which can lead to exceptions at an integration boundary.
## Issue Context
Even though this is `#if DEBUG`, the compliance requirement expects boundary inputs (like URLs and request-derived fields) to be validated and to fail safely/deterministically.
## Fix Focus Areas
- src/Plugins/BotSharp.Plugin.MicrosoftTeams/MicrosoftTeamsPlugin.cs[94-97]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| public Task<IConnectorClient> CreateConnectorClientAsync(ITurnContext turnContext, string? audience = null, IList<string>? scopes = null, bool useAnonymous = false, CancellationToken cancellationToken = default) | ||
| #pragma warning disable CS0618 // intentionally using the legacy overload to bypass the agentic branch | ||
| => inner.CreateConnectorClientAsync(turnContext.Identity, turnContext.Activity.ServiceUrl, audience, cancellationToken, scopes, true); | ||
| #pragma warning restore CS0618 |
There was a problem hiding this comment.
2. Nullable audience forwarded 🐞 Bug ≡ Correctness
AnonymousDebugChannelServiceClientFactory.CreateConnectorClientAsync(ITurnContext, ...) accepts string? audience = null but forwards that value into a legacy overload that declares `string audience, relying on the inner factory to tolerate null and risking failures when audience` is omitted. This is a new nullability/contract mismatch introduced in the DEBUG detour path.
Agent Prompt
### Issue description
`AnonymousDebugChannelServiceClientFactory.CreateConnectorClientAsync(ITurnContext ...)` takes `string? audience = null` and passes it to `RestChannelServiceClientFactory.CreateConnectorClientAsync(ClaimsIdentity, string, string audience, ...)`.
This violates the nullability contract of the legacy overload and makes connector creation depend on the inner implementation’s handling of `null` (which may fail or produce incorrect audience selection).
### Issue Context
This only executes under `#if DEBUG`, but it directly affects local/debug runs and test environments where the detour factory is registered.
### Fix Focus Areas
- src/Plugins/BotSharp.Plugin.MicrosoftTeams/MicrosoftTeamsPlugin.cs[94-97]
### Suggested fix
Update the ITurnContext overload to ensure a non-null audience is passed to the legacy overload. Options:
1) Coalesce to a safe default (preferably the same default the SDK would use when `audience` is null), e.g. derive it from configuration/settings, and only fall back to `string.Empty` if that is known to be accepted by the SDK.
2) Refactor the wrapper/constructor to accept whatever value you consider the default audience (e.g., AppId or configured audience) and apply `audience ??= <defaultAudience>` before calling the legacy overload.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
No description provided.