mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-11 10:32:09 +08:00
refactor: Use ClockSkew options For prevent add default value (5min) to life time token
This commit is contained in:
parent
0b47559441
commit
bb7aaa2edb
@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
namespace BuildingBlocks.Jwt;
|
||||
|
||||
using Duende.IdentityServer.EntityFramework.Entities;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
public static class JwtExtensions
|
||||
{
|
||||
@ -20,7 +21,11 @@ public static class JwtExtensions
|
||||
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, options =>
|
||||
{
|
||||
options.Authority = jwtOptions.Authority;
|
||||
options.TokenValidationParameters.ValidateAudience = false;
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateAudience = false,
|
||||
ClockSkew = TimeSpan.FromSeconds(2) // For prevent add default value (5min) to life time token!
|
||||
};
|
||||
options.RequireHttpsMetadata = jwtOptions.RequireHttpsMetadata;
|
||||
options.MetadataAddress= jwtOptions.MetadataAddress;
|
||||
});
|
||||
|
||||
@ -44,14 +44,11 @@ public static class Config
|
||||
new()
|
||||
{
|
||||
ClientId = "client",
|
||||
|
||||
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
|
||||
|
||||
ClientSecrets =
|
||||
{
|
||||
new Secret("secret".Sha256())
|
||||
},
|
||||
|
||||
AllowedScopes =
|
||||
{
|
||||
IdentityServerConstants.StandardScopes.OpenId,
|
||||
@ -60,7 +57,9 @@ public static class Config
|
||||
Constants.StandardScopes.PassengerApi,
|
||||
Constants.StandardScopes.BookingApi,
|
||||
Constants.StandardScopes.IdentityApi
|
||||
}
|
||||
},
|
||||
AccessTokenLifetime = 3600, // authorize the client to access protected resources
|
||||
IdentityTokenLifetime = 3600 // authenticate the user
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user