Skip to content

Commit

Permalink
Add identity model validators (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangmsft committed May 10, 2024
1 parent c930108 commit 8856dc3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<Project>

<PropertyGroup Label="Centralized Package Versions">
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="Azure.Storage.Blobs" Version="12.14.1" />
<PackageVersion Include="BenchmarkDotNet" Version="0.13.12" />
Expand All @@ -19,10 +17,10 @@
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.28.1" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="7.5.1" />
<PackageVersion Include="Microsoft.IdentityModel.Validators" Version="7.5.1" />
<PackageVersion Include="StackExchange.Redis" Version="2.6.80" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.34.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="7.5.1" />
<PackageVersion Include="System.Interactive.Async" Version="6.0.1" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions libs/server/Auth/GarnetAadAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Garnet.server.Auth.Aad;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
using Microsoft.IdentityModel.Validators;

namespace Garnet.server.Auth
{
Expand Down Expand Up @@ -62,6 +63,7 @@ public bool Authenticate(ReadOnlySpan<byte> password, ReadOnlySpan<byte> usernam
ValidAudiences = _audiences,
IssuerSigningKeys = _signingTokenProvider.SigningTokens
};
parameters.EnableAadSigningKeyIssuerValidation();

var identity = _tokenHandler.ValidateToken(Encoding.UTF8.GetString(password), parameters, out var token);

Expand Down
1 change: 1 addition & 0 deletions libs/server/Garnet.server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.IdentityModel.Validators" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" />
Expand Down

0 comments on commit 8856dc3

Please sign in to comment.