hi
This means no cookies exist.
https://github.com/dotnet/aspnetcore/blob/release/8.0/src/Security/Authentication/Cookies/src/CookieAuthenticationHandler.cs#L153-L156 https://github.com/dotnet/aspnetcore/blob/release/8.0/src/Security/Authentication/Cookies/src/AuthenticateResults.cs#L8-L12
If you check the request headers of the home page, I think it doesn't have identity.application cookies.
hi
I can't build and run your app.
Can you share a template sample project?
Thanks
hi
Add this service to see the reason.
context.Services.Replace(ServiceDescriptor.Scoped<IAuthenticationService, MyAuthenticationService>());
private void ConfigureAuthentication(ServiceConfigurationContext context)
{
// services.TryAddScoped<IAuthenticationService, AuthenticationService>();
context.Services.Replace(ServiceDescriptor.Scoped<IAuthenticationService, MyAuthenticationService>());
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
{
options.IsDynamicClaimsEnabled = true;
});
}
** _logger.LogError(result.Failure?.Message);**
using System;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace MyCompanyName.MyProjectName.Blazor.Server;
public class MyAuthenticationService : AuthenticationService
{
private readonly ILogger<MyAuthenticationService> _logger;
public MyAuthenticationService(
IAuthenticationSchemeProvider schemes,
IAuthenticationHandlerProvider handlers,
IClaimsTransformation transform,
IOptions<AuthenticationOptions> options, ILogger<MyAuthenticationService> logger)
: base(schemes, handlers, transform, options)
{
_logger = logger;
}
public async override Task<AuthenticateResult> AuthenticateAsync(HttpContext context, string? scheme)
{
var result = await base.AuthenticateAsync(context, scheme);
if (!result.Succeeded)
{
_logger.LogError("Authentication failed.");
_logger.LogError(result.Failure?.Message);
}
else
{
_logger.LogError("Authentication succeeded.");
}
return result;
}
}
hi
AuthenticationScheme: Identity.Application was not authenticated. AuthenticationScheme: Identity.Application was challenged.
This means the Cookies are no longer valid. so I think this is still a** browser cookies **problem. The code is no problem.
[INF] Request starting HTTP/2 GET https://localhost:44367/ - null null
[DBG] AuthenticationScheme: Identity.Application was not authenticated.
2024-06-21 11:43:05.180 +02:00 [DBG] AuthenticationScheme: OpenIddict.Validation.AspNetCore was not authenticated.
[INF] AuthenticationScheme: Identity.Application was challenged.
[INF] Request finished HTTP/2 GET https://localhost:44367/ - 302 0 null 1459.6662ms
Thanks. I will check it asap.
hi
Your module code is no problem.
The WildcardDomainsFormat is enough.
PreConfigure<AbpOpenIddictWildcardDomainOptions>(options =>
{
options.EnableWildcardDomainSupport = true;
options.WildcardDomainsFormat.Add("https://{0}.mybackend.com/");
options.WildcardDomainsFormat.Add("https://{0}.mybackend.com/signin-oidc");
options.WildcardDomainsFormat.Add("https://{0}.mybackend.com/signout-callback-oidc");
options.WildcardDomainsFormat.Add("https://{0}.mybackend.com/authentication/login-callback");
options.WildcardDomainsFormat.Add("https://{0}.myfrontend.com/");
});
Can you set the log level to Debug(MinimumLevel.Debug()) and share the Logs.txt
public class Program
{
public async static Task<int> Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
.WriteTo.Async(c => c.Console())
.CreateLogger();
liming.ma@volosoft.com
Thanks
You have multiple host projects and only want to use hangfire in API.HOST project. so you shouldn't use the hangfire module in the shared module(domain)
: )
hi
I will reply here if I have news.
hi
Using this overload is no problem.
Can you share a new template project to reproduce your problem?
liming.ma@volosoft.com