Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #53 from microsoft/andrueastman/NRT
Browse files Browse the repository at this point in the history
Adds support for nullable reference types
  • Loading branch information
andrueastman authored Jan 17, 2023
2 parents 6288a5c + aff3f34 commit f01f0f1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

## [1.0.0-rc.3] - 2023-01-17

### Added

- Adds support for nullabe reference types

## [1.0.0-rc.2] - 2023-01-16

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFrameworks>net6.0;net462</TargetFrameworks>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/AzureIdentityAccessTokenProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class AzureIdentityAccessTokenProvider : IAccessTokenProvider, IDisposabl
private readonly ActivitySource _activitySource;
private readonly HashSet<string> _scopes;
/// <inheritdoc />
public AllowedHostsValidator AllowedHostsValidator { get; private set; }
public AllowedHostsValidator AllowedHostsValidator { get; protected set; }

/// <summary>
/// The <see cref="AzureIdentityAccessTokenProvider"/> constructor
Expand All @@ -31,7 +31,7 @@ public class AzureIdentityAccessTokenProvider : IAccessTokenProvider, IDisposabl
/// <param name="allowedHosts">The list of allowed hosts for which to request access tokens.</param>
/// <param name="scopes">The scopes to request the access token for.</param>
/// <param name="observabilityOptions">The observability options to use for the authentication provider.</param>
public AzureIdentityAccessTokenProvider(TokenCredential credential, string [] allowedHosts = null, ObservabilityOptions observabilityOptions = null, params string[] scopes)
public AzureIdentityAccessTokenProvider(TokenCredential credential, string []? allowedHosts = null, ObservabilityOptions? observabilityOptions = null, params string[] scopes)
{
_credential = credential ?? throw new ArgumentNullException(nameof(credential));

Expand All @@ -48,7 +48,7 @@ public AzureIdentityAccessTokenProvider(TokenCredential credential, string [] al
private const string ClaimsKey = "claims";

/// <inheritdoc/>
public async Task<string> GetAuthorizationTokenAsync(Uri uri, Dictionary<string, object> additionalAuthenticationContext = default, CancellationToken cancellationToken = default)
public async Task<string> GetAuthorizationTokenAsync(Uri uri, Dictionary<string, object>? additionalAuthenticationContext = default, CancellationToken cancellationToken = default)
{
using var span = _activitySource?.StartActivity(nameof(GetAuthorizationTokenAsync));
if(!AllowedHostsValidator.IsUrlHostValid(uri)) {
Expand All @@ -63,7 +63,7 @@ public async Task<string> GetAuthorizationTokenAsync(Uri uri, Dictionary<string,

span?.SetTag("com.microsoft.kiota.authentication.is_url_valid", true);

string decodedClaim = null;
string? decodedClaim = null;
if (additionalAuthenticationContext is not null &&
additionalAuthenticationContext.ContainsKey(ClaimsKey) &&
additionalAuthenticationContext[ClaimsKey] is string claims) {
Expand Down
3 changes: 2 additions & 1 deletion src/AzureIdentityAuthenticationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class AzureIdentityAuthenticationProvider : BaseBearerTokenAuthentication
/// <param name="allowedHosts">The list of allowed hosts for which to request access tokens.</param>
/// <param name="scopes">The scopes to request the access token for.</param>
/// <param name="observabilityOptions">The observability options to use for the authentication provider.</param>
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, params string[] scopes)
: base(new AzureIdentityAccessTokenProvider(credential, allowedHosts, observabilityOptions, scopes))
{
}
}
9 changes: 6 additions & 3 deletions src/Microsoft.Kiota.Authentication.Azure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<AssemblyTitle>Kiota Azure Identity Authentication Library for dotnet</AssemblyTitle>
<Authors>Microsoft</Authors>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<LangVersion>latest</LangVersion>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/microsoft/kiota-authentication-azure-dotnet</RepositoryUrl>
<PackageProjectUrl>https://microsoft.github.io/kiota/</PackageProjectUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Deterministic>true</Deterministic>
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix>rc.2</VersionSuffix>
<VersionSuffix>rc.3</VersionSuffix>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<!-- Enable this line once we go live to prevent breaking changes -->
<!-- <PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion> -->
<SignAssembly>false</SignAssembly>
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<PackageReleaseNotes>
https://github.com/microsoft/kiota-authentication-azure-dotnet/releases
</PackageReleaseNotes>
Expand All @@ -33,7 +36,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Azure.Core" Version="1.27.0" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.0.0-rc.3" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.0.0-rc.4" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="7.0.0" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/ObservabilityOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------

Expand All @@ -9,7 +9,7 @@ namespace Microsoft.Kiota.Authentication.Azure;
/// Holds the tracing, metrics and logging configuration for the authentication provider
/// </summary>
public class ObservabilityOptions {
private static readonly Lazy<string> _name = new Lazy<string>(() => typeof(ObservabilityOptions).Namespace);
private static readonly Lazy<string> _name = new Lazy<string>(() => typeof(ObservabilityOptions).Namespace!);
/// <summary>
/// Gets the observability name to use for the tracer
/// </summary>
Expand Down

0 comments on commit f01f0f1

Please sign in to comment.