feat: implement user-based wallet and transaction retrieval by parsing JWT sub claim and adjust JWT validation parameters across services.
This commit is contained in:
@@ -137,8 +137,13 @@ try
|
||||
.AddJwtBearer("Bearer", options =>
|
||||
{
|
||||
options.Authority = builder.Configuration["Jwt:Authority"] ?? "http://localhost:5001";
|
||||
options.Audience = builder.Configuration["Jwt:Audience"] ?? "membership-service";
|
||||
options.RequireHttpsMetadata = false;
|
||||
options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = false,
|
||||
ValidateAudience = false,
|
||||
ValidateLifetime = true,
|
||||
};
|
||||
});
|
||||
|
||||
builder.Services.AddAuthorization();
|
||||
|
||||
@@ -74,7 +74,8 @@ public class MemberEntityTypeConfiguration : IEntityTypeConfiguration<Member>
|
||||
|
||||
// EN: Soft delete
|
||||
// VI: Xóa mềm
|
||||
builder.Property("_isDeleted")
|
||||
builder.Property(m => m.IsDeleted)
|
||||
.HasField("_isDeleted")
|
||||
.HasColumnName("is_deleted")
|
||||
.HasDefaultValue(false);
|
||||
|
||||
@@ -93,7 +94,7 @@ public class MemberEntityTypeConfiguration : IEntityTypeConfiguration<Member>
|
||||
builder.HasIndex("_currentExp")
|
||||
.HasDatabaseName("ix_members_current_exp");
|
||||
|
||||
builder.HasIndex("_isDeleted")
|
||||
builder.HasIndex(m => m.IsDeleted)
|
||||
.HasDatabaseName("ix_members_is_deleted");
|
||||
|
||||
// EN: Ignore domain events (not persisted)
|
||||
|
||||
@@ -63,6 +63,10 @@ public class MembershipServiceContext : DbContext, IUnitOfWork
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
// EN: Ignore Enumeration types to prevent EF Core discovery issues
|
||||
// VI: Bỏ qua Enumeration types để tránh lỗi EF Core discovery
|
||||
modelBuilder.Ignore<ExperienceSource>();
|
||||
|
||||
// EN: Apply entity configurations
|
||||
// VI: Áp dụng entity configurations
|
||||
modelBuilder.ApplyConfigurationsFromAssembly(typeof(MembershipServiceContext).Assembly);
|
||||
|
||||
@@ -115,8 +115,8 @@ try
|
||||
options.TokenValidationParameters = new()
|
||||
{
|
||||
ValidateAudience = false,
|
||||
ValidateIssuer = true,
|
||||
ValidIssuer = builder.Configuration["Jwt:Issuer"]
|
||||
ValidateIssuer = false,
|
||||
ValidateLifetime = true,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user