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) { } } diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props new file mode 100644 index 00000000..cdf95a31 --- /dev/null +++ b/tests/Directory.Build.props @@ -0,0 +1,10 @@ + + + + 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..b89b9029 100644 --- a/tests/serialization/form/Microsoft.Kiota.Serialization.Form.Tests.csproj +++ b/tests/serialization/form/Microsoft.Kiota.Serialization.Form.Tests.csproj @@ -1,9 +1,5 @@  - - net8.0;net462 - true - true enable @@ -27,7 +23,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..b3e3e2cd 100644 --- a/tests/serialization/text/Microsoft.Kiota.Serialization.Text.Tests.csproj +++ b/tests/serialization/text/Microsoft.Kiota.Serialization.Text.Tests.csproj @@ -1,10 +1,9 @@  - net8.0;net462 - true + enable - + runtime; build; native; contentfiles; analyzers; buildtransitive @@ -25,7 +24,8 @@ - + - + \ No newline at end of file