hi
Can you try to use PreConfigure
?
PreConfigure<HttpConnectionDispatcherOptions>(x =>
{
x.CloseOnAuthenticationExpiration = true;
});
You can also output the AuthenticateResult?.Properties?.ExpiresUtc
to logs by adding a custom middleware after UseAuthentication
app.UseAuthentication();
app.Use(async (httpContext, next) =>
{
var logger = httpContext.RequestServices.GetRequiredService<ILogger<YourModule>>();
var authenticateResultFeature = context.Features.Get<IAuthenticateResultFeature>();
if (authenticateResultFeature is not null)
{
logger.LogError("ExpiresUtc: " + authenticateResultFeature.AuthenticateResult?.Properties?.ExpiresUtc);
}
else
{
logger.LogError("authenticateResultFeature is null");
}
await next(httpContext);
});
Thanks.
hi
I have already checked the appsettings.secrets.json file, and the AbpLicenseCode key is present with the correct value.
Does the appsettings.secrets.json
file exist in the Container
?
Can you try to move the AbpLicenseCode
from appsettings.secrets.json
to appsettings.json
?
Thanks.
hi
Can you share a minimal project that reproduces the error?
I will download and check your code.
liming.ma@volosoft.com
Thanks.
hi
For your requirements, I suggest downloading the File Management Module source code and modifying it.
Adding new Entity and properties.
Thanks.
hi
The DTO classes for requests and responses need to use primitive objects/types; otherwise, you'll have to add a JSON converter for serialization and deserialization.
Can you share the returned JSON? You can call the API in Swagger to see the returned JSON.
Of course. You can also share a minimal project to reproduce the error.
liming.ma@volosoft.com
Thanks.
hi
I need to check the code. Please share a project. Thank you.
Hi
Please share your DTO(input/output) class code.
Thank
hi
When using [Authorize("Permission.View")] on API method, a user that has the "Permission.View" permission granted and on correct tenant, does not get Authorized and I get a 403 error.
Can you add a custom middleware and share full debug logs?
liming.ma@volosoft.com
see https://abp.io/support/questions/8622/How-to-enable-Debug-logs-for-troubleshoot-problems
var loggerConfiguration = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
app.UseAuthentication();
app.Use(async (httpContext, next) =>
{
var logger = httpContext.RequestServices.GetRequiredService<ILogger<YourModule>>();
var claims = httpContext.User.Claims.Select(x => new { x.Type, x.Value }).ToList();
logger.LogError("HttpContext.User Claims:");
logger.LogError(JsonSerializer.Serialize(claims));
var currentUser = httpContext.RequestServices.GetRequiredService<ICurrentUser>().GetAllClaims().Select(x => new { x.Type, x.Value }).ToList();
logger.LogError("Current User Claims:");
logger.LogError(JsonSerializer.Serialize(currentUser));
var userid = AbpClaimTypes.UserId;
var username = AbpClaimTypes.UserName;
var roleClaimType = AbpClaimTypes.Role;
logger.LogError($"UserId Claim Type: {userid}");
logger.LogError($"UserName Claim Type: {username}");
logger.LogError($"Role Claim Type: {roleClaimType}");
var authorizationHeader = httpContext.Request.Headers["Authorization"];
logger.LogError(!string.IsNullOrEmpty(authorizationHeader)
? $"Authorization Header: {authorizationHeader}"
: "Authorization Header is missing or empty.");
await next(httpContext);
});
hi
I tested in the latest Blazor Server template project. And it works.
Can you share your project or a demo project to reproduce?
Thanks