Skip to content

Commit

Permalink
Merge pull request #1025 from Microsoft/jeffders/govConstantsInto40
Browse files Browse the repository at this point in the history
Updating US Gov constants

CR in person with Chris.
  • Loading branch information
Jeffders authored Oct 12, 2018
2 parents de4c559 + f0221f7 commit 28a3d68
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public static class GovernmentAuthenticationConstants
/// <summary>
/// Government Channel Service property value
/// </summary>
public const string ChannelService = "https://botframework.us";
public const string ChannelService = "https://botframework.azure.us";

/// <summary>
/// TO GOVERNMENT CHANNEL FROM BOT: Login URL
/// </summary>
public const string ToChannelFromBotLoginUrl = "https://login.microsoftonline.us/botframework.com/oauth2/v2.0/token";
public const string ToChannelFromBotLoginUrl = "https://login.microsoftonline.us/cab8a31a-1906-4287-a0d8-4eef66b95f6e/oauth2/v2.0/token";

/// <summary>
/// TO GOVERNMENT CHANNEL FROM BOT: OAuth scope to request
Expand All @@ -33,11 +33,11 @@ public static class GovernmentAuthenticationConstants
/// <summary>
/// OAuth Url used to get a token from OAuthApiClient
/// </summary>
public const string OAuthUrlGov = "https://api.botframework.us";
public const string OAuthUrlGov = "https://api.botframework.azure.us";

/// <summary>
/// TO BOT FROM GOVERNMANT CHANNEL: OpenID metadata document for tokens coming from MSA
/// </summary>
public const string ToBotFromChannelOpenIdMetadataUrl = "https://login.botframework.us/v1/.well-known/openidconfiguration";
public const string ToBotFromChannelOpenIdMetadataUrl = "https://login.botframework.azure.us/v1/.well-known/openidconfiguration";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace Microsoft.Bot.Connector.Authentication
{
public sealed class GovernmentChannelValidation
{
public static string OpenIdMetadataUrl { get; set; } = GovernmentAuthenticationConstants.ToBotFromChannelOpenIdMetadataUrl;

/// <summary>
/// TO BOT FROM GOVERNMENT CHANNEL: Token validation parameters when connecting to a bot
/// </summary>
Expand Down Expand Up @@ -42,7 +44,7 @@ public static async Task<ClaimsIdentity> AuthenticateChannelToken(string authHea
{
var tokenExtractor = new JwtTokenExtractor(httpClient,
ToBotFromGovernmentChannelTokenValidationParameters,
GovernmentAuthenticationConstants.ToBotFromChannelOpenIdMetadataUrl,
OpenIdMetadataUrl,
AuthenticationConstants.AllowedSigningAlgorithms);

var identity = await tokenExtractor.GetIdentityAsync(authHeader, channelId).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static IApplicationBuilder UseBotFramework(this IApplicationBuilder appli
if (!string.IsNullOrEmpty(openIdEndpoint))
{
ChannelValidation.OpenIdMetadataUrl = openIdEndpoint;
GovernmentChannelValidation.OpenIdMetadataUrl = openIdEndpoint;
}

var oauthApiEndpoint = configuration.GetSection(AuthenticationConstants.OAuthUrlKey)?.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ private static void ConfigureCustomEndpoints()
if (!string.IsNullOrEmpty(openIdEndpoint))
{
ChannelValidation.OpenIdMetadataUrl = openIdEndpoint;
GovernmentChannelValidation.OpenIdMetadataUrl = openIdEndpoint;
}

var oauthApiEndpoint = ConfigurationManager.AppSettings[AuthenticationConstants.OAuthUrlKey];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public void MicrosoftGovernmentAppCredentials_Uses_Gov_Scope()
public void GovernmentAuthenticationConstants_ChannelService_IsRight()
{
// This value should not change
Assert.Equal("https://botframework.us", GovernmentAuthenticationConstants.ChannelService);
Assert.Equal("https://botframework.azure.us", GovernmentAuthenticationConstants.ChannelService);
}

[Fact]
public void GovernmentAuthenticationConstants_ToChannelFromBotLoginUrl_IsRight()
{
// This value should not change
Assert.Equal("https://login.microsoftonline.us/botframework.com/oauth2/v2.0/token", GovernmentAuthenticationConstants.ToChannelFromBotLoginUrl);
Assert.Equal("https://login.microsoftonline.us/cab8a31a-1906-4287-a0d8-4eef66b95f6e/oauth2/v2.0/token", GovernmentAuthenticationConstants.ToChannelFromBotLoginUrl);
}

[Fact]
Expand All @@ -57,14 +57,14 @@ public void GovernmentAuthenticationConstants_ToBotFromChannelTokenIssuer_IsRigh
public void GovernmentAuthenticationConstants_OAuthUrlGov_IsRight()
{
// This value should not change
Assert.Equal("https://api.botframework.us", GovernmentAuthenticationConstants.OAuthUrlGov);
Assert.Equal("https://api.botframework.azure.us", GovernmentAuthenticationConstants.OAuthUrlGov);
}

[Fact]
public void GovernmentAuthenticationConstants_ToBotFromChannelOpenIdMetadataUrl_IsRight()
{
// This value should not change
Assert.Equal("https://login.botframework.us/v1/.well-known/openidconfiguration", GovernmentAuthenticationConstants.ToBotFromChannelOpenIdMetadataUrl);
Assert.Equal("https://login.botframework.azure.us/v1/.well-known/openidconfiguration", GovernmentAuthenticationConstants.ToBotFromChannelOpenIdMetadataUrl);
}
}
}

0 comments on commit 28a3d68

Please sign in to comment.