From c51d294fc37fb7d048dbef129c2380f1095c7d42 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 8 Aug 2024 13:42:48 -0400 Subject: [PATCH 1/4] chore: aligns test projects property configuration Signed-off-by: Vincent Biret --- tests/Directory.Build.props | 9 +++++++++ .../Microsoft.Kiota.Abstractions.Tests.csproj | 6 ------ ...Microsoft.Kiota.Authentication.Azure.Tests.csproj | 11 +++-------- tests/bundle/Microsoft.Kiota.Bundle.Tests.csproj | 7 +------ ...crosoft.Kiota.Http.HttpClientLibrary.Tests.csproj | 11 +++-------- .../Microsoft.Kiota.Serialization.Form.Tests.csproj | 12 +++--------- .../Microsoft.Kiota.Serialization.Json.Tests.csproj | 11 +++-------- ...rosoft.Kiota.Serialization.Multipart.Tests.csproj | 12 ++++-------- .../Microsoft.Kiota.Serialization.Text.Tests.csproj | 10 +++------- 9 files changed, 29 insertions(+), 60 deletions(-) create mode 100644 tests/Directory.Build.props diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props new file mode 100644 index 00000000..b23e239e --- /dev/null +++ b/tests/Directory.Build.props @@ -0,0 +1,9 @@ + + + net8.0;net462 + true + disable + true + latest + + \ No newline at end of file diff --git a/tests/abstractions/Microsoft.Kiota.Abstractions.Tests.csproj b/tests/abstractions/Microsoft.Kiota.Abstractions.Tests.csproj index 3018cd82..54db1cef 100644 --- a/tests/abstractions/Microsoft.Kiota.Abstractions.Tests.csproj +++ b/tests/abstractions/Microsoft.Kiota.Abstractions.Tests.csproj @@ -1,11 +1,5 @@  - - true - net8.0;net462 - disable - - all diff --git a/tests/authentication/azure/Microsoft.Kiota.Authentication.Azure.Tests.csproj b/tests/authentication/azure/Microsoft.Kiota.Authentication.Azure.Tests.csproj index e2a08541..5b9bf747 100644 --- a/tests/authentication/azure/Microsoft.Kiota.Authentication.Azure.Tests.csproj +++ b/tests/authentication/azure/Microsoft.Kiota.Authentication.Azure.Tests.csproj @@ -1,11 +1,5 @@  - - net8.0;net462 - true - disable - - all @@ -26,7 +20,8 @@ - + - + \ No newline at end of file diff --git a/tests/bundle/Microsoft.Kiota.Bundle.Tests.csproj b/tests/bundle/Microsoft.Kiota.Bundle.Tests.csproj index d3bb6af6..3356151d 100644 --- a/tests/bundle/Microsoft.Kiota.Bundle.Tests.csproj +++ b/tests/bundle/Microsoft.Kiota.Bundle.Tests.csproj @@ -1,10 +1,5 @@  - - true - net8.0;net462 - - all @@ -29,5 +24,5 @@ - + \ No newline at end of file diff --git a/tests/http/httpClient/Microsoft.Kiota.Http.HttpClientLibrary.Tests.csproj b/tests/http/httpClient/Microsoft.Kiota.Http.HttpClientLibrary.Tests.csproj index 655ce09d..6264fbaa 100644 --- a/tests/http/httpClient/Microsoft.Kiota.Http.HttpClientLibrary.Tests.csproj +++ b/tests/http/httpClient/Microsoft.Kiota.Http.HttpClientLibrary.Tests.csproj @@ -1,11 +1,5 @@  - - net8.0;net462 - true - disable - - all @@ -26,7 +20,8 @@ - + - + \ No newline at end of file diff --git a/tests/serialization/form/Microsoft.Kiota.Serialization.Form.Tests.csproj b/tests/serialization/form/Microsoft.Kiota.Serialization.Form.Tests.csproj index 1893a387..accb3ef5 100644 --- a/tests/serialization/form/Microsoft.Kiota.Serialization.Form.Tests.csproj +++ b/tests/serialization/form/Microsoft.Kiota.Serialization.Form.Tests.csproj @@ -1,12 +1,5 @@  - - net8.0;net462 - true - true - enable - - all @@ -27,7 +20,8 @@ - + - + \ No newline at end of file diff --git a/tests/serialization/json/Microsoft.Kiota.Serialization.Json.Tests.csproj b/tests/serialization/json/Microsoft.Kiota.Serialization.Json.Tests.csproj index f78259b1..c2d09938 100644 --- a/tests/serialization/json/Microsoft.Kiota.Serialization.Json.Tests.csproj +++ b/tests/serialization/json/Microsoft.Kiota.Serialization.Json.Tests.csproj @@ -1,11 +1,5 @@  - - net8.0;net462 - true - disable - - all @@ -26,7 +20,8 @@ - + - + \ No newline at end of file diff --git a/tests/serialization/multipart/Microsoft.Kiota.Serialization.Multipart.Tests.csproj b/tests/serialization/multipart/Microsoft.Kiota.Serialization.Multipart.Tests.csproj index 27a2c849..dd8dbd4e 100644 --- a/tests/serialization/multipart/Microsoft.Kiota.Serialization.Multipart.Tests.csproj +++ b/tests/serialization/multipart/Microsoft.Kiota.Serialization.Multipart.Tests.csproj @@ -1,11 +1,5 @@  - - net8.0;net462 - true - disable - - all @@ -26,8 +20,10 @@ - - + + \ No newline at end of file diff --git a/tests/serialization/text/Microsoft.Kiota.Serialization.Text.Tests.csproj b/tests/serialization/text/Microsoft.Kiota.Serialization.Text.Tests.csproj index 42035885..812aa8ec 100644 --- a/tests/serialization/text/Microsoft.Kiota.Serialization.Text.Tests.csproj +++ b/tests/serialization/text/Microsoft.Kiota.Serialization.Text.Tests.csproj @@ -1,10 +1,5 @@  - - net8.0;net462 - true - - runtime; build; native; contentfiles; analyzers; buildtransitive @@ -25,7 +20,8 @@ - + - + \ No newline at end of file From 2fe683f25b7a1a219669ab33df7905c8a5187efe Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 8 Aug 2024 13:52:22 -0400 Subject: [PATCH 2/4] fix: nullable support in form test project Signed-off-by: Vincent Biret --- .../form/Microsoft.Kiota.Serialization.Form.Tests.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/serialization/form/Microsoft.Kiota.Serialization.Form.Tests.csproj b/tests/serialization/form/Microsoft.Kiota.Serialization.Form.Tests.csproj index accb3ef5..b89b9029 100644 --- a/tests/serialization/form/Microsoft.Kiota.Serialization.Form.Tests.csproj +++ b/tests/serialization/form/Microsoft.Kiota.Serialization.Form.Tests.csproj @@ -1,4 +1,7 @@  + + enable + From 1a31d46f399614e849cd9f3d81264632dd4fd048 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 8 Aug 2024 13:53:51 -0400 Subject: [PATCH 3/4] feat: CAE enabled by default Signed-off-by: Vincent Biret --- CHANGELOG.md | 4 ++++ Directory.Build.props | 2 +- .../azure/AzureIdentityAccessTokenProvider.cs | 20 +++++++++++++++++-- .../AzureIdentityAuthenticationProvider.cs | 18 +++++++++++++++-- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dae766be..05440214 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.11.0] - 2024-08-08 + +- Enabled Continuous Access evaluation by default. + ## [1.10.1] - 2024-08-01 - Cleans up enum serialization to read from attributes for form and text serialization [#284](https://github.com/microsoft/kiota-dotnet/issues/284) diff --git a/Directory.Build.props b/Directory.Build.props index 81999928..cd005950 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 1.10.1 + 1.11.0 false diff --git a/src/authentication/azure/AzureIdentityAccessTokenProvider.cs b/src/authentication/azure/AzureIdentityAccessTokenProvider.cs index db18837e..033d37af 100644 --- a/src/authentication/azure/AzureIdentityAccessTokenProvider.cs +++ b/src/authentication/azure/AzureIdentityAccessTokenProvider.cs @@ -22,6 +22,7 @@ public class AzureIdentityAccessTokenProvider : IAccessTokenProvider, IDisposabl private readonly TokenCredential _credential; private readonly ActivitySource _activitySource; + private readonly bool _isCaeEnabled; private readonly HashSet _scopes; /// public AllowedHostsValidator AllowedHostsValidator { get; protected set; } @@ -33,7 +34,8 @@ public class AzureIdentityAccessTokenProvider : IAccessTokenProvider, IDisposabl /// The list of allowed hosts for which to request access tokens. /// The scopes to request the access token for. /// The observability options to use for the authentication provider. - public AzureIdentityAccessTokenProvider(TokenCredential credential, string[]? allowedHosts = null, ObservabilityOptions? observabilityOptions = null, params string[] scopes) + /// Whether to enable Conditional Access Evaluation (CAE) for the token request. + public AzureIdentityAccessTokenProvider(TokenCredential credential, string[]? allowedHosts = null, ObservabilityOptions? observabilityOptions = null, bool isCaeEnabled = true, params string[] scopes) { _credential = credential ?? throw new ArgumentNullException(nameof(credential)); @@ -45,6 +47,20 @@ public AzureIdentityAccessTokenProvider(TokenCredential credential, string[]? al _scopes = new(scopes, StringComparer.OrdinalIgnoreCase); _activitySource = new((observabilityOptions ?? new()).TracerInstrumentationName); + _isCaeEnabled = isCaeEnabled; + } + /// + /// The constructor + /// + /// The credential implementation to use to obtain the access token. + /// The list of allowed hosts for which to request access tokens. + /// The scopes to request the access token for. + /// The observability options to use for the authentication provider. + [Obsolete("This constructor is obsolete and will be removed in a future version. Use the constructor that takes an isCaeEnabled parameter instead.")] + public AzureIdentityAccessTokenProvider(TokenCredential credential, string[]? allowedHosts, ObservabilityOptions? observabilityOptions, params string[] scopes) : + this(credential, allowedHosts, observabilityOptions, true, scopes) + { + } private const string ClaimsKey = "claims"; @@ -96,7 +112,7 @@ public async Task GetAuthorizationTokenAsync(Uri uri, DictionaryThe credential implementation to use to obtain the access token. /// The list of allowed hosts for which to request access tokens. /// The scopes to request the access token for. + /// Whether to enable Conditional Access Evaluation (CAE) for the token request. /// The observability options to use for the authentication provider. - public AzureIdentityAuthenticationProvider(TokenCredential credential, string[]? allowedHosts = null, ObservabilityOptions? observabilityOptions = null, params string[] scopes) - : base(new AzureIdentityAccessTokenProvider(credential, allowedHosts, observabilityOptions, scopes)) + public AzureIdentityAuthenticationProvider(TokenCredential credential, string[]? allowedHosts = null, ObservabilityOptions? observabilityOptions = null, bool isCaeEnabled = true, params string[] scopes) + : base(new AzureIdentityAccessTokenProvider(credential, allowedHosts, observabilityOptions, isCaeEnabled, scopes)) + { + } + /// + /// The constructor + /// + /// The credential implementation to use to obtain the access token. + /// The list of allowed hosts for which to request access tokens. + /// The scopes to request the access token for. + /// The observability options to use for the authentication provider. + [Obsolete("This constructor is obsolete and will be removed in a future version. Use the constructor that takes an isCaeEnabled parameter instead.")] + public AzureIdentityAuthenticationProvider(TokenCredential credential, string[]? allowedHosts, ObservabilityOptions? observabilityOptions, params string[] scopes) + : this(credential, allowedHosts, observabilityOptions, true, scopes) { } } From 654eeead90f6897042c161922b6b4f9f3a0b2bde Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Fri, 9 Aug 2024 10:43:46 +0300 Subject: [PATCH 4/4] Fix failing CI --- tests/Directory.Build.props | 1 + .../text/Microsoft.Kiota.Serialization.Text.Tests.csproj | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index b23e239e..cdf95a31 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -1,4 +1,5 @@ + net8.0;net462 true diff --git a/tests/serialization/text/Microsoft.Kiota.Serialization.Text.Tests.csproj b/tests/serialization/text/Microsoft.Kiota.Serialization.Text.Tests.csproj index 812aa8ec..b3e3e2cd 100644 --- a/tests/serialization/text/Microsoft.Kiota.Serialization.Text.Tests.csproj +++ b/tests/serialization/text/Microsoft.Kiota.Serialization.Text.Tests.csproj @@ -1,5 +1,9 @@  + + enable + + runtime; build; native; contentfiles; analyzers; buildtransitive