Skip to content

Commit

Permalink
fix: Fixing code scanning alert on AAD issuer validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Omondi committed Aug 19, 2024
1 parent 7c7511c commit 523a5dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Microsoft.Graph
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using Microsoft.IdentityModel.Tokens;
using Microsoft.IdentityModel.Protocols;
using Microsoft.IdentityModel.Validators;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -65,7 +66,7 @@ private static bool IsTokenValid(string token, JwtSecurityTokenHandler handler,
{
try
{
handler.ValidateToken(token, new TokenValidationParameters
var tokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
Expand All @@ -74,7 +75,9 @@ private static bool IsTokenValid(string token, JwtSecurityTokenHandler handler,
ValidIssuers = issuersToValidate,
ValidAudiences = appIds,
IssuerSigningKeys = openIdConfig.SigningKeys
}, out _);
};
tokenValidationParameters.EnableAadSigningKeyIssuerValidation();
handler.ValidateToken(token, tokenValidationParameters, out _);
}
catch
{
Expand Down
7 changes: 4 additions & 3 deletions src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.0.1" />
<PackageReference Include="Microsoft.IdentityModel.Validators" Version="8.0.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Authentication.Azure" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.11.3" />
<PackageReference Include="Microsoft.Kiota.Serialization.Multipart" Version="1.11.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Multipart" Version="1.11.3" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="[6.0,9.0)" />
Expand Down

0 comments on commit 523a5dc

Please sign in to comment.