Skip to content

Commit

Permalink
[C#] feat: Allow passing custom credentials factory to CloudAdapter (#…
Browse files Browse the repository at this point in the history
…2166)

## Linked issues

closes: #2130

## Details

Added an additional constructor to CloudAdapter that allows passing a
custom credentials factory to CloudAdapter. This enables using an
alternative credentials factory, like
FederatedServiceClientCredentialsFactory, instead of it being hardcoded
to the ConfigurationServiceClientCredentialFactory.

## Attestation Checklist

- [x] My code follows the style guidelines of this project
- [x] I have checked for/fixed spelling, linting, and other errors
- [x] I have commented my code for clarity
- [x] I have made corresponding changes to the documentation (updating
the doc strings in the code is sufficient)
- [x] My changes generate no new warnings
- [x] New and existing unit tests pass locally with my changes
  • Loading branch information
stepro authored Dec 9, 2024
1 parent eb63a75 commit ecfdb0a
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,29 @@ public TeamsAdapter(
CredentialsFactory = new ConfigurationServiceClientCredentialFactory(configuration);
}

/// <summary>
/// Initializes a new instance of the <see cref="TeamsAdapter"/> class.
/// </summary>
/// <param name="configuration">The <see cref="IConfiguration"/> instance.</param>
/// <param name="credentialsFactory">The <see cref="ServiceClientCredentialsFactory"/> instance.</param>
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/> this adapter should use.</param>
/// <param name="logger">The <see cref="ILogger"/> implementation this adapter should use.</param>
public TeamsAdapter(
IConfiguration configuration,
ServiceClientCredentialsFactory credentialsFactory,
IHttpClientFactory? httpClientFactory = null,
ILogger? logger = null) : base(
new ConfigurationBotFrameworkAuthentication(configuration,
credentialsFactory: credentialsFactory,
httpClientFactory: new TeamsHttpClientFactory(httpClientFactory),
logger: logger),
logger)
{
HttpClientFactory = new TeamsHttpClientFactory(httpClientFactory);
Configuration = configuration;
CredentialsFactory = credentialsFactory;
}

/// <inheritdoc />
public new async Task ProcessAsync(HttpRequest httpRequest, HttpResponse httpResponse, IBot bot, CancellationToken cancellationToken = default)
{
Expand Down

0 comments on commit ecfdb0a

Please sign in to comment.