Skip to content

Commit

Permalink
Merge 64b459d into 540fadc
Browse files Browse the repository at this point in the history
  • Loading branch information
johnataylor committed Oct 7, 2020
2 parents 540fadc + 64b459d commit 433ed88
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Net.Http;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -43,18 +44,18 @@ public static class BotFrameworkAuthenticationFactory
HttpClient httpClient,
ILogger logger)
{
if (string.IsNullOrEmpty(channelService))
{
return new PublicCloudBotFrameworkAuthentication(credentialFactory, authConfiguration, httpClient, logger);
}
else if (channelService == GovernmentAuthenticationConstants.ChannelService)
{
return new GovernmentCloudBotFrameworkAuthentication(credentialFactory, authConfiguration, httpClient, logger);
}
else
if (
!string.IsNullOrEmpty(toChannelFromBotLoginUrl) ||
!string.IsNullOrEmpty(toChannelFromBotOAuthScope) ||
!string.IsNullOrEmpty(toBotFromChannelTokenIssuer) ||
!string.IsNullOrEmpty(oAuthUrl) ||
!string.IsNullOrEmpty(toBotFromChannelOpenIdMetadataUrl) ||
!string.IsNullOrEmpty(toBotFromEmulatorOpenIdMetadataUrl) ||
!string.IsNullOrEmpty(callerId))
{
// if we have any of the 'parameterized' properties defined we'll assume this is the parameterized code

return new ParameterizedBotFrameworkAuthentication(
channelService,
validateAuthority,
toChannelFromBotLoginUrl,
toChannelFromBotOAuthScope,
Expand All @@ -68,6 +69,23 @@ public static class BotFrameworkAuthenticationFactory
httpClient,
logger);
}
else
{
// else apply the built in default behavior, which is either the public cloud or the gov cloud depending on whether we have a channelService value present

if (string.IsNullOrEmpty(channelService))
{
return new PublicCloudBotFrameworkAuthentication(credentialFactory, authConfiguration, httpClient, logger);
}
else if (channelService == GovernmentAuthenticationConstants.ChannelService)
{
return new GovernmentCloudBotFrameworkAuthentication(credentialFactory, authConfiguration, httpClient, logger);
}
else
{
throw new Exception("A ChannelService was given but the value was not recognized.");
}
}
}
}
}
Expand Up @@ -19,7 +19,6 @@ internal class ParameterizedBotFrameworkAuthentication : BotFrameworkAuthenticat
{
private static HttpClient _defaultHttpClient = new HttpClient();

private readonly string _channelService;
private readonly bool _validateAuthority;
private readonly string _toChannelFromBotLoginUrl;
private readonly string _toChannelFromBotOAuthScope;
Expand All @@ -34,7 +33,6 @@ internal class ParameterizedBotFrameworkAuthentication : BotFrameworkAuthenticat
private readonly ILogger _logger;

public ParameterizedBotFrameworkAuthentication(
string channelService,
bool validateAuthority,
string toChannelFromBotLoginUrl,
string toChannelFromBotOAuthScope,
Expand All @@ -48,7 +46,6 @@ internal class ParameterizedBotFrameworkAuthentication : BotFrameworkAuthenticat
HttpClient httpClient = null,
ILogger logger = null)
{
_channelService = channelService;
_validateAuthority = validateAuthority;
_toChannelFromBotLoginUrl = toChannelFromBotLoginUrl;
_toChannelFromBotOAuthScope = toChannelFromBotOAuthScope;
Expand Down
Expand Up @@ -127,7 +127,7 @@ public void ConstructorWithConfiguration()
{
{ "MicrosoftAppId", "appId" },
{ "MicrosoftAppPassword", "appPassword" },
{ "ChannelService", "channelService" }
{ "ChannelService", GovernmentAuthenticationConstants.ChannelService }
};

var configuration = new ConfigurationBuilder()
Expand Down

0 comments on commit 433ed88

Please sign in to comment.