Skip to content

Commit de2940f

Browse files
jennyf19Chris Brooksjmprieursciocoderh3rmanj
authored
Update POC with master (#1752)
* update xml (#1719) * update lab cert thumbprint (#1718) * changelog 1.24.1 (#1720) * Create TokenAcquisitionAppTokenCredential.cs (#1722) Extends Azure ADK support to include requesting tokens as the app. This is a copy of TokenAcquisitionTokenCredential.cs with changes to class name and changes to use _tokenAcquisition.GetAuthenticationResultForAppAsync() instead of GetAuthenticationResultForUserAsync(). * fix build, add using (#1729) * fix build, add using * add header in test * Adding support for .net 6 simplified templates apps (#1736) * Jennyf/scopes roles (#1742) * initial commit for app permissions * add test coverage * remove IEnumerable and use string[] * PR comments * IJwtBearerMiddlewareDiagnostics from singleton to transient (#1741) * fix tests after merge from fork (#1744) * fix for 1738 (#1743) * changelog for 1.25 (#1747) * update testing files to 1.25 (#1748) * update to wilson 6.19 (#1749) * fix: include StatusCode in HttpRequestException for .NET 5 (#1750) * update XML (#1751) * try 5.0.0 for config.binder in OWIN to resolve issue * don't build owin sample * add condition * remove release mode Co-authored-by: Chris Brooks <[email protected]> Co-authored-by: Jean-Marc Prieur <[email protected]> Co-authored-by: sciocoder <[email protected]> Co-authored-by: Herman Jensen <[email protected]>
1 parent 054ce12 commit de2940f

File tree

36 files changed

+4035
-35
lines changed

36 files changed

+4035
-35
lines changed

Microsoft.Identity.Web.sln

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,7 @@ Global
323323
{8C557C25-25C9-45B6-B2D3-77093893EBC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
324324
{8C557C25-25C9-45B6-B2D3-77093893EBC5}.Release|Any CPU.Build.0 = Release|Any CPU
325325
{E3611BED-B43A-40BD-A0A3-98AD65B5DAA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
326-
{E3611BED-B43A-40BD-A0A3-98AD65B5DAA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
327326
{E3611BED-B43A-40BD-A0A3-98AD65B5DAA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
328-
{E3611BED-B43A-40BD-A0A3-98AD65B5DAA4}.Release|Any CPU.Build.0 = Release|Any CPU
329327
{98F57CC8-01A0-49F3-B859-DDC4F8F5CD2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
330328
{98F57CC8-01A0-49F3-B859-DDC4F8F5CD2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
331329
{98F57CC8-01A0-49F3-B859-DDC4F8F5CD2F}.Release|Any CPU.ActiveCfg = Release|Any CPU

ProjectTemplates/AspNetCoreMicrosoftIdentityWebProjectTemplates.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<!--This should be passed from the VSTS build-->
5-
<ClientSemVer Condition="'$(ClientSemVer)' == ''">1.24.0</ClientSemVer>
5+
<ClientSemVer Condition="'$(ClientSemVer)' == ''">1.25.0</ClientSemVer>
66
<!--This will generate AssemblyVersion, AssemblyFileVersion and AssemblyInformationVersion-->
77
<PackageVersion>$(ClientSemVer)</PackageVersion>
88

ProjectTemplates/test-aspnet-templates-from-nuget.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
echo "Ensure ClientSemVer"
22
if "%ClientSemVer%" == "" (
3-
set ClientSemVer=1.24.0
3+
set ClientSemVer=1.25.0
44
)
55

66
REM: This is to test Microsoft.Identity.Web templates

ProjectTemplates/test-templates-from-nuget.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
echo "Ensure ClientSemVer"
22
if "%ClientSemVer%" == "" (
3-
set ClientSemVer=1.24.0
3+
set ClientSemVer=1.25.0
44
)
55

66
REM: This is to test Microsoft.Identity.Web templates

ProjectTemplates/test-templates.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
echo "Ensure ClientSemVer"
22
if "%ClientSemVer%" == "" (
3-
set ClientSemVer=1.24.0
3+
set ClientSemVer=1.25.0
44
)
55
Set TemplateNugetPackageName="Microsoft.Identity.Web.ProjectTemplates"
66

TESTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ In a Developer Command Prompt:
3434

3535
3. Set the version of the templates to test.
3636

37-
`Set ClientSemVer=1.24.0`
37+
`Set ClientSemVer=1.25.0`
3838

3939
4. In ProjectTemplates open the Configuration.json file and add the client secrets (or your own config file) .
4040

@@ -73,7 +73,7 @@ In a Developer Command Prompt:
7373

7474
2. Set the version of the templates to test.
7575

76-
`Set ClientSemVer=1.24.0`
76+
`Set ClientSemVer=1.25.0`
7777

7878
3. Add client secrets to the `ProjectTemplates\Configuration.json` file
7979

changelog.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
1.25.0
2+
==========
3+
### New Features:
4+
**Microsoft.Identity.Web now supports checking for scopes or app permissions,** via the `RequestedScopeOrAppPermissionAttribute`. See issue [#1641](https://github.com/AzureAD/microsoft-identity-web/issues/1641) for details.
5+
**Extend TokenAcquisitionTokenCredential concept to support tokens as app**. See issue [#1723](https://github.com/AzureAD/microsoft-identity-web/issues/1723) for details.
6+
7+
### Bug Fixes:
8+
**IJwtBearerMiddlewareDiagnostics is now transient and not a singleton**. See issue [#1710](https://github.com/AzureAD/microsoft-identity-web/issues/1710) for details.
9+
**In web API scenario, use the `tid` claim of the incoming assertion, unless overridden**. See issue [#1738](https://github.com/AzureAD/microsoft-identity-web/issues/1738) for details.
10+
11+
1.24.1
12+
==========
13+
### Bug Fixes:
14+
**Microsoft.Identity.Web now returns `TokenValidatedContext.Fail` instead of throwing `UnauthorizedAccessException` in case of missing roles or scopes**, which enables a better developer experience. See issue [#1716](https://github.com/AzureAD/microsoft-identity-web/issues/1716) for details.
15+
116
1.24.0
217
==========
318
Update to Microsoft.IdentityModel 6.17.0.

src/Microsoft.Identity.Web.OWIN/Microsoft.Identity.Web.OWIN.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
8484
</PackageReference>
8585
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.24" />
86-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.24" />
86+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
8787
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.24" />
8888
<PackageReference Include="Microsoft.Graph" Version="4.11.0" />
8989
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="$(IdentityModelVersion)" />

src/Microsoft.Identity.Web.TokenAcquisition/TokenAcquisition.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,25 @@ private IConfidentialClientApplication BuildConfidentialClientApplication(Merged
654654
if (builder != null)
655655
{
656656
builder.WithSendX5C(mergedOptions.SendX5C);
657+
658+
ClaimsPrincipal? user = _tokenAcquisitionHost.GetUserFromRequest();
659+
var userTenant = string.Empty;
660+
if (user != null)
661+
{
662+
userTenant = user.GetTenantId();
663+
builder.WithCcsRoutingHint(user.GetObjectId(), userTenant);
664+
}
657665
if (!string.IsNullOrEmpty(tenantId))
658666
{
659667
builder.WithTenantId(tenantId);
660668
}
661-
669+
else
670+
{
671+
if (!string.IsNullOrEmpty(userTenant))
672+
{
673+
builder.WithTenantId(userTenant);
674+
}
675+
}
662676
if (tokenAcquisitionOptions != null)
663677
{
664678
builder.WithExtraQueryParameters(tokenAcquisitionOptions.ExtraQueryParameters);
@@ -669,13 +683,7 @@ private IConfidentialClientApplication BuildConfidentialClientApplication(Merged
669683
{
670684
builder.WithProofOfPossession(tokenAcquisitionOptions.PoPConfiguration);
671685
}
672-
}
673-
674-
ClaimsPrincipal? user = _tokenAcquisitionHost.GetUserFromRequest();
675-
if (user != null)
676-
{
677-
builder.WithCcsRoutingHint(user.GetObjectId(), user.GetTenantId());
678-
}
686+
}
679687

680688
return await builder.ExecuteAsync(tokenAcquisitionOptions != null ? tokenAcquisitionOptions.CancellationToken : CancellationToken.None)
681689
.ConfigureAwait(false);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.Linq;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
using Azure.Core;
8+
using Microsoft.Identity.Client;
9+
10+
namespace Microsoft.Identity.Web
11+
{
12+
/// <summary>
13+
/// Azure SDK token credential for App tokens based on the ITokenAcquisition service.
14+
/// </summary>
15+
public class TokenAcquisitionAppTokenCredential : TokenCredential
16+
{
17+
private ITokenAcquisition _tokenAcquisition;
18+
19+
/// <summary>
20+
/// Constructor from an ITokenAcquisition service.
21+
/// </summary>
22+
/// <param name="tokenAcquisition">Token acquisition.</param>
23+
public TokenAcquisitionAppTokenCredential(ITokenAcquisition tokenAcquisition)
24+
{
25+
_tokenAcquisition = tokenAcquisition;
26+
}
27+
28+
/// <inheritdoc/>
29+
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken)
30+
{
31+
AuthenticationResult result = _tokenAcquisition.GetAuthenticationResultForAppAsync(requestContext.Scopes.First())
32+
.GetAwaiter()
33+
.GetResult();
34+
return new AccessToken(result.AccessToken, result.ExpiresOn);
35+
}
36+
37+
/// <inheritdoc/>
38+
public override async ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken)
39+
{
40+
AuthenticationResult result = await _tokenAcquisition.GetAuthenticationResultForAppAsync(requestContext.Scopes.First()).ConfigureAwait(false);
41+
return new AccessToken(result.AccessToken, result.ExpiresOn);
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)