Skip to content

Commit

Permalink
fix warnings in extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
rido-min committed Feb 27, 2025
1 parent ef2a04d commit f6bb2c0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions samples/basic/echo-bot/dotnet/AspNetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public static class AspNetExtensions
/// `OpenIdMetadataUrl` can be omitted. In which case default values in combination with `IsGov` is used.
/// `AzureBotServiceTokenHandling` defaults to true and should always be true until Azure Bot Service sends Entra ID token.
/// </remarks>
public static void AddBotAspNetAuthentication(this IServiceCollection services, IConfiguration configuration, string tokenValidationSectionName = "TokenValidation", ILogger logger = null)
public static void AddBotAspNetAuthentication(this IServiceCollection services, IConfiguration configuration, string tokenValidationSectionName = "TokenValidation", ILogger logger = null!)
{
IConfigurationSection tokenValidationSection = configuration.GetSection(tokenValidationSectionName);
List<string> validTokenIssuers = tokenValidationSection.GetSection("ValidIssuers").Get<List<string>>();
List<string> audiences = tokenValidationSection.GetSection("Audiences").Get<List<string>>();
List<string> validTokenIssuers = tokenValidationSection.GetSection("ValidIssuers").Get<List<string>>()!;
List<string> audiences = tokenValidationSection.GetSection("Audiences").Get<List<string>>()!;

if (!tokenValidationSection.Exists())
{
Expand All @@ -85,7 +85,7 @@ public static void AddBotAspNetAuthentication(this IServiceCollection services,
"https://login.microsoftonline.com/69e9b82d-4842-4902-8d1e-abc5b98a55e8/v2.0",
];

string tenantId = tokenValidationSection["TenantId"];
string tenantId = tokenValidationSection["TenantId"]!;
if (!string.IsNullOrEmpty(tenantId))
{
validTokenIssuers.Add(string.Format(CultureInfo.InvariantCulture, AuthenticationConstants.ValidTokenIssuerUrlTemplateV1, tenantId));
Expand Down Expand Up @@ -155,7 +155,7 @@ public static void AddBotAspNetAuthentication(this IServiceCollection services,
return;
}

string[] parts = authorizationHeader?.Split(' ');
string[] parts = authorizationHeader?.Split(' ')!;
if (parts.Length != 2 || parts[0] != "Bearer")
{
// Default to AadTokenValidation handling
Expand Down

0 comments on commit f6bb2c0

Please sign in to comment.