Skip to content

Commit

Permalink
Add token life time and issuer validation (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
CSR2017 authored Dec 18, 2024
1 parent b9cc269 commit 769826a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ Serilog.ILogger logger
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = true,
ValidAudience = identitySettings.Audience,
ValidateIssuer = true,
ValidIssuer = identitySettings.Authority,
ValidateLifetime = true,
RoleClaimType = identitySettings.RoleClaimType,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ Serilog.ILogger ConfigureLogging()
webAppBuilder.Services.Configure<IdentitySettings>(settings);
webAppBuilder.Services.AddHttpClient();


if (identitySettings.EnforceAuthorization)
{
string metadataAddress = $"{identitySettings.Authority}/.well-known/openid-configuration";
Expand All @@ -111,7 +110,10 @@ Serilog.ILogger ConfigureLogging()
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = true,
ValidateIssuer = false,
ValidAudience = identitySettings.Audience,
ValidateIssuer = true,
ValidIssuer = identitySettings.Authority,
ValidateLifetime = true,
RoleClaimType = identitySettings.RoleClaimType,
};

Expand Down

0 comments on commit 769826a

Please sign in to comment.