Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Microsoft.Identity.Web.Aspnet/CommonUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ public static string EnsureAuthorityIsV2(string authority)
return authority;
}

/// <summary>
/// Create valid issuers both for V1.0 and V2.0
/// </summary>
/// <param name="webApiConfig"></param>
/// <returns></returns>
public static List<string> BuildValidIssuers(JwtBearerOptions webApiConfig)
{
return new List<string>
{
$"{EnsureTrailingSlash(webApiConfig.AADInstance)}{webApiConfig.TenantId}",
$"{EnsureTrailingSlash(webApiConfig.AADInstance)}{webApiConfig.TenantId}/v2.0"
};
}

public static string EnsureTrailingSlash(string value)
{
if (value == null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Microsoft.IdentityModel.Tokens;
using Microsoft.Owin.Security.ActiveDirectory;
using Owin;
using System;
using System.Collections.Generic;

namespace Microsoft.Identity.Web.Aspnet
{
Expand All @@ -17,10 +19,12 @@ public static void ProtectWebApiWithMicrosoftIdentity(this IAppBuilder app, JwtB
new WindowsAzureActiveDirectoryBearerAuthenticationOptions
{
Tenant = webApiConfig.TenantId,

TokenValidationParameters = new TokenValidationParameters
{
SaveSigninToken = true,
ValidAudiences = webApiConfig.ValidAudiences
ValidAudiences = webApiConfig.ValidAudiences,
ValidIssuers = CommonUtil.BuildValidIssuers(webApiConfig)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmprieur Thank you, I will check it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats what he will do next

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmprieur done proposed change

}
});
}
Expand Down
2 changes: 1 addition & 1 deletion TodoListService/TodoListService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>9184</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
Expand Down