Skip to content

Commit 1b912de

Browse files
authored
Merge pull request #138 from Azure-Samples/jennyf/fixNuget
fix build errors
2 parents 318504b + 27e19ed commit 1b912de

File tree

58 files changed

+80
-2494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+80
-2494
lines changed

2. Web API now calls Microsoft Graph/TodoListService/Controllers/TodoListController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public async Task<string> CallGraphApiOnBehalfOfUser()
9292
// we use MSAL.NET to get a token to call the API On Behalf Of the current user
9393
try
9494
{
95-
string accessToken = await _tokenAcquisition.GetAccessTokenOnBehalfOfUserAsync(scopes);
95+
string accessToken = await _tokenAcquisition.GetAccessTokenForUserAsync(scopes);
9696
dynamic me = await CallGraphApiOnBehalfOfUser(accessToken);
9797
return me.userPrincipalName;
9898
}

2. Web API now calls Microsoft Graph/TodoListService/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public Startup(IConfiguration configuration)
2424
public void ConfigureServices(IServiceCollection services)
2525
{
2626
services.AddProtectedWebApi(Configuration)
27-
.AddProtectedApiCallsWebApis(Configuration)
27+
.AddProtectedWebApiCallsProtectedWebApi(Configuration)
2828
.AddInMemoryTokenCaches();
2929
services.AddControllers();
3030
}

3.-Web-api-call-Microsoft-graph-for-personal-accounts/TodoListService/Controllers/TodoListController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public async Task<string> CallGraphApiOnBehalfOfUser()
9292
// we use MSAL.NET to get a token to call the API On Behalf Of the current user
9393
try
9494
{
95-
string accessToken = await _tokenAcquisition.GetAccessTokenOnBehalfOfUserAsync(scopes);
95+
string accessToken = await _tokenAcquisition.GetAccessTokenForUserAsync(scopes);
9696
dynamic me = await CallGraphApiOnBehalfOfUser(accessToken);
9797
return me.userPrincipalName;
9898
}

3.-Web-api-call-Microsoft-graph-for-personal-accounts/TodoListService/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public Startup(IConfiguration configuration)
2424
public void ConfigureServices(IServiceCollection services)
2525
{
2626
services.AddProtectedWebApi(Configuration)
27-
.AddProtectedApiCallsWebApis(Configuration)
27+
.AddProtectedWebApiCallsProtectedWebApi(Configuration)
2828
.AddInMemoryTokenCaches();
2929
services.AddControllers();
3030
}

4.-Console-app-calls-web-API-with-PoP/Desktop-App-calls-Web-API-using-PoP.sln

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1212
README.md = README.md
1313
EndProjectSection
1414
EndProject
15-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Future", "..\Microsoft.Identity.Web\Microsoft.Identity.Web.Future.csproj", "{F29C8FF6-5725-4C26-B0B4-682FCF218E6D}"
15+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Future", "Microsoft.Identity.Web.Future\Microsoft.Identity.Web.Future.csproj", "{CBA23165-BA0B-469A-B3A4-3299989AAECD}"
1616
EndProject
1717
Global
1818
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -28,10 +28,10 @@ Global
2828
{443FB1A8-4F29-4D18-A4EB-23C3D764580C}.Debug|Any CPU.Build.0 = Debug|Any CPU
2929
{443FB1A8-4F29-4D18-A4EB-23C3D764580C}.Release|Any CPU.ActiveCfg = Release|Any CPU
3030
{443FB1A8-4F29-4D18-A4EB-23C3D764580C}.Release|Any CPU.Build.0 = Release|Any CPU
31-
{F29C8FF6-5725-4C26-B0B4-682FCF218E6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32-
{F29C8FF6-5725-4C26-B0B4-682FCF218E6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
33-
{F29C8FF6-5725-4C26-B0B4-682FCF218E6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
34-
{F29C8FF6-5725-4C26-B0B4-682FCF218E6D}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{CBA23165-BA0B-469A-B3A4-3299989AAECD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{CBA23165-BA0B-469A-B3A4-3299989AAECD}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{CBA23165-BA0B-469A-B3A4-3299989AAECD}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{CBA23165-BA0B-469A-B3A4-3299989AAECD}.Release|Any CPU.Build.0 = Release|Any CPU
3535
EndGlobalSection
3636
GlobalSection(SolutionProperties) = preSolution
3737
HideSolutionNode = FALSE

Microsoft.Identity.Web/Resource/AadIssuerValidator.cs renamed to 4.-Console-app-calls-web-API-with-PoP/Microsoft.Identity.Web.Future/AadIssuerValidator.cs

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
using Microsoft.IdentityModel.JsonWebTokens;
1010
using Microsoft.IdentityModel.Protocols;
1111
using Microsoft.IdentityModel.Tokens;
12-
using Microsoft.Identity.Web.InstanceDiscovery;
12+
using Microsoft.Identity.Web.Future;
1313

14-
namespace Microsoft.Identity.Web.Resource
14+
namespace Microsoft.Identity.Future
1515
{
1616
/// <summary>
1717
/// Generic class that validates token issuer from the provided Azure AD authority. Use the <see cref="AadIssuerValidatorFactory"/> to create instances of this class.
1818
/// </summary>
19-
public class AadIssuerValidator
19+
internal class AadIssuerValidator
2020
{
2121
private const string AzureADIssuerMetadataUrl = "https://login.microsoftonline.com/common/discovery/instance?authorization_endpoint=https://login.microsoftonline.com/common/oauth2/v2.0/authorize&api-version=1.1";
2222
private const string FallbackAuthority = "https://login.microsoftonline.com/";
@@ -71,6 +71,7 @@ public static AadIssuerValidator GetIssuerValidator(string aadAuthority)
7171
var aliases = issuerMetadata.Metadata
7272
.Where(m => m.Aliases.Any(a => string.Equals(a, authority, StringComparison.OrdinalIgnoreCase)))
7373
.SelectMany(m => m.Aliases)
74+
.Append(authority) // For b2c scenarios, the alias will be the authorityHost itself
7475
.Distinct();
7576
s_issuerValidators[authority] = new AadIssuerValidator(aliases);
7677
return s_issuerValidators[authority];
@@ -94,7 +95,7 @@ public static AadIssuerValidator GetIssuerValidator(string aadAuthority)
9495
/// <exception cref="SecurityTokenInvalidIssuerException">if the issuer </exception>
9596
public string Validate(string actualIssuer, SecurityToken securityToken, TokenValidationParameters validationParameters)
9697
{
97-
if (String.IsNullOrEmpty(actualIssuer))
98+
if (string.IsNullOrEmpty(actualIssuer))
9899
throw new ArgumentNullException(nameof(actualIssuer));
99100

100101
if (securityToken == null)
@@ -159,21 +160,43 @@ private static bool IsValidTidInLocalPath(string tenantId, Uri uri)
159160
/// <remarks>Only <see cref="JwtSecurityToken"/> and <see cref="JsonWebToken"/> are acceptable types.</remarks>
160161
private static string GetTenantIdFromToken(SecurityToken securityToken)
161162
{
163+
string tid = "tid";
162164
if (securityToken is JwtSecurityToken jwtSecurityToken)
163165
{
164-
if (jwtSecurityToken.Payload.TryGetValue(ClaimConstants.Tid, out object tenantId))
166+
if (jwtSecurityToken.Payload.TryGetValue(tid, out object tenantId))
165167
return tenantId as string;
168+
169+
// Since B2C doesn't have TID as default, get it from issuer
170+
return GetTenantIdFromIss(jwtSecurityToken.Issuer);
166171
}
167172

168-
// brentsch - todo, TryGetPayloadValue is available in 5.5.0
169173
if (securityToken is JsonWebToken jsonWebToken)
170174
{
171-
var tid = jsonWebToken.GetPayloadValue<string>(ClaimConstants.Tid);
172-
if (tid != null)
173-
return tid;
175+
jsonWebToken.TryGetPayloadValue(tid, out string tid2);
176+
if (tid2 != null)
177+
return tid2;
178+
179+
// Since B2C doesn't have TID as default, get it from issuer
180+
return GetTenantIdFromIss(jsonWebToken.Issuer);
181+
}
182+
183+
return string.Empty;
184+
}
185+
186+
// The AAD iss claims contains the tenantId in its value. The uri is {domain}/{tid}/v2.0
187+
private static string GetTenantIdFromIss(string iss)
188+
{
189+
if (string.IsNullOrEmpty(iss))
190+
return string.Empty;
191+
192+
var uri = new Uri(iss);
193+
194+
if (uri.Segments.Length > 1)
195+
{
196+
return uri.Segments[1].TrimEnd('/');
174197
}
175198

176199
return string.Empty;
177200
}
178201
}
179-
}
202+
}

Microsoft.Identity.Web/InstanceDiscovery/IssuerConfigurationRetriever.cs renamed to 4.-Console-app-calls-web-API-with-PoP/Microsoft.Identity.Web.Future/IssuerConfigurationRetriever.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using Microsoft.IdentityModel.Protocols;
88
using Newtonsoft.Json;
99

10-
namespace Microsoft.Identity.Web.InstanceDiscovery
10+
namespace Microsoft.Identity.Web.Future
1111
{
1212
/// <summary>
1313
/// An implementation of IConfigurationRetriever geared towards Azure AD issuers metadata />

Microsoft.Identity.Web/InstanceDiscovery/IssuerMetadata.cs renamed to 4.-Console-app-calls-web-API-with-PoP/Microsoft.Identity.Web.Future/IssuerMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Collections.Generic;
55
using Newtonsoft.Json;
66

7-
namespace Microsoft.Identity.Web.InstanceDiscovery
7+
namespace Microsoft.Identity.Web.Future
88
{
99
/// <summary>
1010
/// Model class to hold information parsed from the Azure AD issuer endpoint

Microsoft.Identity.Web/InstanceDiscovery/Metadata.cs renamed to 4.-Console-app-calls-web-API-with-PoP/Microsoft.Identity.Web.Future/Metadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Collections.Generic;
55
using Newtonsoft.Json;
66

7-
namespace Microsoft.Identity.Web.InstanceDiscovery
7+
namespace Microsoft.Identity.Web.Future
88
{
99
/// <summary>
1010
/// Model child class to hold alias information parsed from the Azure AD issuer endpoint.

Microsoft.Identity.Web/Microsoft.Identity.Web.Future.csproj renamed to 4.-Console-app-calls-web-API-with-PoP/Microsoft.Identity.Web.Future/Microsoft.Identity.Web.Future.csproj

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33

44
<!--This should be passed from the VSTS build-->
5-
<ClientSemVer Condition="'$(ClientSemVer)' == ''">1.0.0-localbuild</ClientSemVer>
5+
<ClientSemVer Condition="'$(ClientSemVer)' == ''">1.0.0-preview</ClientSemVer>
66
<!--This will generate AssemblyVersion, AssemblyFileVersion and AssemblyInformationVersion-->
77
<Version>$(ClientSemVer)</Version>
88

@@ -26,34 +26,6 @@
2626
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2727
</PropertyGroup>
2828

29-
<ItemGroup>
30-
<Compile Remove="InstanceDiscovery\**" />
31-
<Compile Remove="Resource\**" />
32-
<Compile Remove="TokenCacheProviders\**" />
33-
<EmbeddedResource Remove="InstanceDiscovery\**" />
34-
<EmbeddedResource Remove="Resource\**" />
35-
<EmbeddedResource Remove="TokenCacheProviders\**" />
36-
<None Remove="InstanceDiscovery\**" />
37-
<None Remove="Resource\**" />
38-
<None Remove="TokenCacheProviders\**" />
39-
</ItemGroup>
40-
41-
<ItemGroup>
42-
<Compile Remove="AccountExtensions.cs" />
43-
<Compile Remove="AuthorizeForScopesAttribute.cs" />
44-
<Compile Remove="ClaimConstants.cs" />
45-
<Compile Remove="ClaimsPrincipalExtensions.cs" />
46-
<Compile Remove="ClaimsPrincipalFactory.cs" />
47-
<Compile Remove="Extensions.cs" />
48-
<Compile Remove="HttpContextExtensions.cs" />
49-
<Compile Remove="InternalsVisibleTo.cs" />
50-
<Compile Remove="ITokenAcquisition.cs" />
51-
<Compile Remove="OidcConstants.cs" />
52-
<Compile Remove="ServiceCollectionExtensions.cs" />
53-
<Compile Remove="TokenAcquisition.cs" />
54-
<Compile Remove="WebAppServiceCollectionExtensions.cs" />
55-
</ItemGroup>
56-
5729
<ItemGroup>
5830
<None Remove="NuGet.Config" />
5931
<None Remove="README.md" />
@@ -68,21 +40,7 @@
6840
<TargetFramework>netcoreapp3.1</TargetFramework>
6941
</PropertyGroup>
7042

71-
72-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
73-
<CodeAnalysisRuleSet>Microsoft.Identity.Web.ruleset</CodeAnalysisRuleSet>
74-
</PropertyGroup>
75-
76-
77-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
78-
<CodeAnalysisRuleSet>Microsoft.Identity.Web.ruleset</CodeAnalysisRuleSet>
79-
</PropertyGroup>
80-
8143
<ItemGroup>
82-
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="3.1.0" />
83-
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureADB2C.UI" Version="3.1.0" />
84-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
85-
<PackageReference Include="Microsoft.Identity.Client" Version="4.10.0" />
8644
<PackageReference Include="Microsoft.Identity.Web" Version="0.1.0-preview" />
8745
<PackageReference Include="Microsoft.IdentityModel.Protocols.SignedHttpRequest" Version="6.5.0" />
8846
<PackageReference Include="System.Collections" Version="4.3.0" />

0 commit comments

Comments
 (0)