Skip to content

Commit b896075

Browse files
authored
Merge pull request #322 from microsoft/feature/caeEnabled
feature/caeEnabled
2 parents 8be19ce + 654eeea commit b896075

13 files changed

+71
-60
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.11.0] - 2024-08-08
11+
12+
- Enabled Continuous Access evaluation by default.
13+
1014
## [1.10.1] - 2024-08-01
1115

1216
- Cleans up enum serialization to read from attributes for form and text serialization [#284](https://github.com/microsoft/kiota-dotnet/issues/284)

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<!-- Common default project properties for ALL projects-->
33
<PropertyGroup>
4-
<VersionPrefix>1.10.1</VersionPrefix>
4+
<VersionPrefix>1.11.0</VersionPrefix>
55
<VersionSuffix></VersionSuffix>
66
<!-- This is overidden in test projects by setting to true-->
77
<IsTestProject>false</IsTestProject>

src/authentication/azure/AzureIdentityAccessTokenProvider.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class AzureIdentityAccessTokenProvider : IAccessTokenProvider, IDisposabl
2222

2323
private readonly TokenCredential _credential;
2424
private readonly ActivitySource _activitySource;
25+
private readonly bool _isCaeEnabled;
2526
private readonly HashSet<string> _scopes;
2627
/// <inheritdoc />
2728
public AllowedHostsValidator AllowedHostsValidator { get; protected set; }
@@ -33,7 +34,8 @@ public class AzureIdentityAccessTokenProvider : IAccessTokenProvider, IDisposabl
3334
/// <param name="allowedHosts">The list of allowed hosts for which to request access tokens.</param>
3435
/// <param name="scopes">The scopes to request the access token for.</param>
3536
/// <param name="observabilityOptions">The observability options to use for the authentication provider.</param>
36-
public AzureIdentityAccessTokenProvider(TokenCredential credential, string[]? allowedHosts = null, ObservabilityOptions? observabilityOptions = null, params string[] scopes)
37+
/// <param name="isCaeEnabled">Whether to enable Conditional Access Evaluation (CAE) for the token request.</param>
38+
public AzureIdentityAccessTokenProvider(TokenCredential credential, string[]? allowedHosts = null, ObservabilityOptions? observabilityOptions = null, bool isCaeEnabled = true, params string[] scopes)
3739
{
3840
_credential = credential ?? throw new ArgumentNullException(nameof(credential));
3941

@@ -45,6 +47,20 @@ public AzureIdentityAccessTokenProvider(TokenCredential credential, string[]? al
4547
_scopes = new(scopes, StringComparer.OrdinalIgnoreCase);
4648

4749
_activitySource = new((observabilityOptions ?? new()).TracerInstrumentationName);
50+
_isCaeEnabled = isCaeEnabled;
51+
}
52+
/// <summary>
53+
/// The <see cref="AzureIdentityAccessTokenProvider"/> constructor
54+
/// </summary>
55+
/// <param name="credential">The credential implementation to use to obtain the access token.</param>
56+
/// <param name="allowedHosts">The list of allowed hosts for which to request access tokens.</param>
57+
/// <param name="scopes">The scopes to request the access token for.</param>
58+
/// <param name="observabilityOptions">The observability options to use for the authentication provider.</param>
59+
[Obsolete("This constructor is obsolete and will be removed in a future version. Use the constructor that takes an isCaeEnabled parameter instead.")]
60+
public AzureIdentityAccessTokenProvider(TokenCredential credential, string[]? allowedHosts, ObservabilityOptions? observabilityOptions, params string[] scopes) :
61+
this(credential, allowedHosts, observabilityOptions, true, scopes)
62+
{
63+
4864
}
4965

5066
private const string ClaimsKey = "claims";
@@ -96,7 +112,7 @@ public async Task<string> GetAuthorizationTokenAsync(Uri uri, Dictionary<string,
96112
scopes = [$"{uri.Scheme}://{uri.Host}/.default"];
97113
span?.SetTag("com.microsoft.kiota.authentication.scopes", string.Join(",", scopes));
98114

99-
var result = await _credential.GetTokenAsync(new TokenRequestContext(scopes, claims: decodedClaim), cancellationToken).ConfigureAwait(false);
115+
var result = await _credential.GetTokenAsync(new TokenRequestContext(scopes, claims: decodedClaim, isCaeEnabled: _isCaeEnabled), cancellationToken).ConfigureAwait(false);
100116
return result.Token;
101117
}
102118

src/authentication/azure/AzureIdentityAuthenticationProvider.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
33
// ------------------------------------------------------------------------------
44

5+
using System;
56
using Azure.Core;
67
using Microsoft.Kiota.Abstractions.Authentication;
78

@@ -17,9 +18,22 @@ public class AzureIdentityAuthenticationProvider : BaseBearerTokenAuthentication
1718
/// <param name="credential">The credential implementation to use to obtain the access token.</param>
1819
/// <param name="allowedHosts">The list of allowed hosts for which to request access tokens.</param>
1920
/// <param name="scopes">The scopes to request the access token for.</param>
21+
/// <param name="isCaeEnabled">Whether to enable Conditional Access Evaluation (CAE) for the token request.</param>
2022
/// <param name="observabilityOptions">The observability options to use for the authentication provider.</param>
21-
public AzureIdentityAuthenticationProvider(TokenCredential credential, string[]? allowedHosts = null, ObservabilityOptions? observabilityOptions = null, params string[] scopes)
22-
: base(new AzureIdentityAccessTokenProvider(credential, allowedHosts, observabilityOptions, scopes))
23+
public AzureIdentityAuthenticationProvider(TokenCredential credential, string[]? allowedHosts = null, ObservabilityOptions? observabilityOptions = null, bool isCaeEnabled = true, params string[] scopes)
24+
: base(new AzureIdentityAccessTokenProvider(credential, allowedHosts, observabilityOptions, isCaeEnabled, scopes))
25+
{
26+
}
27+
/// <summary>
28+
/// The <see cref="AzureIdentityAuthenticationProvider"/> constructor
29+
/// </summary>
30+
/// <param name="credential">The credential implementation to use to obtain the access token.</param>
31+
/// <param name="allowedHosts">The list of allowed hosts for which to request access tokens.</param>
32+
/// <param name="scopes">The scopes to request the access token for.</param>
33+
/// <param name="observabilityOptions">The observability options to use for the authentication provider.</param>
34+
[Obsolete("This constructor is obsolete and will be removed in a future version. Use the constructor that takes an isCaeEnabled parameter instead.")]
35+
public AzureIdentityAuthenticationProvider(TokenCredential credential, string[]? allowedHosts, ObservabilityOptions? observabilityOptions, params string[] scopes)
36+
: this(credential, allowedHosts, observabilityOptions, true, scopes)
2337
{
2438
}
2539
}

tests/Directory.Build.props

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project>
2+
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
3+
<PropertyGroup>
4+
<TargetFrameworks>net8.0;net462</TargetFrameworks>
5+
<IsTestProject>true</IsTestProject>
6+
<Nullable>disable</Nullable>
7+
<ImplicitUsings>true</ImplicitUsings>
8+
<LangVersion>latest</LangVersion>
9+
</PropertyGroup>
10+
</Project>

tests/abstractions/Microsoft.Kiota.Abstractions.Tests.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<IsTestProject>true</IsTestProject>
5-
<TargetFrameworks>net8.0;net462</TargetFrameworks>
6-
<Nullable>disable</Nullable>
7-
</PropertyGroup>
8-
93
<ItemGroup>
104
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
115
<PrivateAssets>all</PrivateAssets>

tests/authentication/azure/Microsoft.Kiota.Authentication.Azure.Tests.csproj

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net462</TargetFrameworks>
5-
<IsTestProject>true</IsTestProject>
6-
<Nullable>disable</Nullable>
7-
</PropertyGroup>
8-
93
<ItemGroup>
104
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
115
<PrivateAssets>all</PrivateAssets>
@@ -26,7 +20,8 @@
2620
</ItemGroup>
2721

2822
<ItemGroup>
29-
<ProjectReference Include="..\..\..\src\authentication\azure\Microsoft.Kiota.Authentication.Azure.csproj" />
23+
<ProjectReference
24+
Include="..\..\..\src\authentication\azure\Microsoft.Kiota.Authentication.Azure.csproj" />
3025
</ItemGroup>
3126

32-
</Project>
27+
</Project>

tests/bundle/Microsoft.Kiota.Bundle.Tests.csproj

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<IsTestProject>true</IsTestProject>
5-
<TargetFrameworks>net8.0;net462</TargetFrameworks>
6-
</PropertyGroup>
7-
83
<ItemGroup>
94
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
105
<PrivateAssets>all</PrivateAssets>
@@ -29,5 +24,5 @@
2924
<ItemGroup>
3025
<ProjectReference Include="..\..\src\bundle\Microsoft.Kiota.Bundle.csproj" />
3126
</ItemGroup>
32-
27+
3328
</Project>

tests/http/httpClient/Microsoft.Kiota.Http.HttpClientLibrary.Tests.csproj

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net462</TargetFrameworks>
5-
<IsTestProject>true</IsTestProject>
6-
<Nullable>disable</Nullable>
7-
</PropertyGroup>
8-
93
<ItemGroup>
104
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
115
<PrivateAssets>all</PrivateAssets>
@@ -26,7 +20,8 @@
2620
</ItemGroup>
2721

2822
<ItemGroup>
29-
<ProjectReference Include="..\..\..\src\http\httpClient\Microsoft.Kiota.Http.HttpClientLibrary.csproj" />
23+
<ProjectReference
24+
Include="..\..\..\src\http\httpClient\Microsoft.Kiota.Http.HttpClientLibrary.csproj" />
3025
</ItemGroup>
3126

32-
</Project>
27+
</Project>

tests/serialization/form/Microsoft.Kiota.Serialization.Form.Tests.csproj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net462</TargetFrameworks>
5-
<IsTestProject>true</IsTestProject>
6-
<ImplicitUsings>true</ImplicitUsings>
73
<Nullable>enable</Nullable>
84
</PropertyGroup>
95

@@ -27,7 +23,8 @@
2723
</ItemGroup>
2824

2925
<ItemGroup>
30-
<ProjectReference Include="..\..\..\src\serialization\form\Microsoft.Kiota.Serialization.Form.csproj" />
26+
<ProjectReference
27+
Include="..\..\..\src\serialization\form\Microsoft.Kiota.Serialization.Form.csproj" />
3128
</ItemGroup>
3229

33-
</Project>
30+
</Project>

0 commit comments

Comments
 (0)