- ABP Framework version: v8.2.0-rc.5 / 8.1.0
- UI Type: Blazor Server
- Database System: EF Core (SQL Server)
I am working with version 8.2.0-rc.5 (new Blazor Server project) and have the problem that I have to log in almost every time I start the application from Visual Studio, even if I select "Remember me". Sometimes the automatic login works, but only very rarely and I have not yet found out when this is the case.
Also, the background of the login page is purple instead of blue and after logging in, the dark theme is shortly displayed before it automatically switches to the system theme. I also have to click away the cookie message every time.
UPDATE: I also found out that the problem does not occur when I keep the page open in another browser window. Then I can restart the application from Visual Studio and the automatic login etc. works.
NOTE: I have already posted the problem under Bugs & Issues v8.2.x, but have now found out that the problem also occurs in 8.1.0 under certain circumstances. So I think it has to do with the configuration.
23 Answer(s)
-
0
hi
I think the cookies of
localhost
domain have been deleted by the browser. You can check the cookies. -
0
What else I found out, if I run another app at the same time (also localhost, different port), then it works as it should. It really seems like the browser deletes the localhost cookies when you close it.
But since it happens in Chrome and Edge, I don't think it affects a browser setting that I would have configured myself...? Where would I have to look for it?
-
0
hi
if I run another app at the same time (also localhost, different port)
The localhost cookies will not distinguish between ports.
You can try configuring different applications to use different cookie names, or use a local domain(https://readme.localtest.me/) name instead of localhost to prevent cookie conflicts between multiple different applications.
-
0
I think you misunderstood me. The different applications were just a test, during which I found that then the problem does NOT occur.
But in general I am currently only working on one project and only one application is running and THEN I have problems.
-
0
I will send you two log files by e-mail. One where the start works correctly and one with the mentioned problem.
-
0
ok, You can set the log level to Debug to see more logs.
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();
-
0
I also get this error message from time to time after starting. If I then refresh the page (F5), it works again. Since both problems have only occurred since this project, I suspect that there is a relationship.
NullReferenceException: Object reference not set to an instance of an object. Microsoft.AspNetCore.Http.DefaultHttpRequest.get_Path() Volo.Abp.AspNetCore.Uow.AspNetCoreUnitOfWorkTransactionBehaviourProvider.get_IsTransactional() Volo.Abp.Uow.UnitOfWorkInterceptor.CreateOptions(IServiceProvider serviceProvider, IAbpMethodInvocation invocation, UnitOfWorkAttribute unitOfWorkAttribute) Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter<TInterceptor>.InterceptAsync<TResult>(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func<IInvocation, IInvocationProceedInfo, Task<TResult>> proceed) Volo.Abp.Features.TenantFeatureValueProvider.GetOrNullAsync(FeatureDefinition feature) Volo.Abp.Features.FeatureChecker.GetOrNullValueFromProvidersAsync(IEnumerable<IFeatureValueProvider> providers, FeatureDefinition feature) Volo.Abp.Features.FeatureChecker.GetOrNullAsync(string name) Volo.Abp.Features.FeatureCheckerBase.IsEnabledAsync(string name) Volo.Abp.Features.FeatureCheckerExtensions.IsEnabledAsync(IFeatureChecker featureChecker, bool requiresAll, string[] featureNames) Volo.Abp.Features.RequireFeaturesSimpleStateChecker<TState>.IsEnabledAsync(SimpleStateCheckerContext<TState> context) Volo.Abp.SimpleStateChecking.SimpleStateCheckerManager<TState>.InternalIsEnabledAsync(TState state, bool useBatchChecker) Volo.Abp.SimpleStateChecking.SimpleStateCheckerManager<TState>.IsEnabledAsync(TState state) Volo.Abp.Authorization.Permissions.PermissionChecker.IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string[] names) Volo.Abp.Authorization.Permissions.PermissionChecker.IsGrantedAsync(string[] names) Volo.Abp.Authorization.Permissions.RequirePermissionsSimpleBatchStateChecker<TState>.IsEnabledAsync(SimpleBatchStateCheckerContext<TState> context) Volo.Abp.SimpleStateChecking.SimpleStateCheckerManager<TState>.IsEnabledAsync(TState[] states) Volo.Abp.UI.Navigation.MenuManager.CheckPermissionsAsync(IServiceProvider serviceProvider, IHasMenuItems menuWithItems) Volo.Abp.UI.Navigation.MenuManager.GetInternalAsync(string name) Volo.Abp.UI.Navigation.MenuManager.GetAsync(string[] menuNames) Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Navigation.MainMenuProvider.GetMenuAsync() Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components.ApplicationLayout.SideMenu.Navigation.MobileNavbar.SetMenuAndProfileAsync() Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components.ApplicationLayout.SideMenu.Navigation.MobileNavbar.OnInitializedAsync() Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.<WaitForNonStreamingPendingTasks>g__Execute|38_0() Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.WaitForResultReady(bool waitForQuiescence, PrerenderedComponentHtmlContent result) Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.RenderEndpointComponent(HttpContext httpContext, Type rootComponentType, ParameterView parameters, bool waitForQuiescence) System.Threading.Tasks.ValueTask<TResult>.get_Result() Microsoft.AspNetCore.Components.Endpoints.RazorComponentEndpointInvoker.RenderComponentCore(HttpContext context) Microsoft.AspNetCore.Components.Endpoints.RazorComponentEndpointInvoker.RenderComponentCore(HttpContext context) Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext+<>c+<<InvokeAsync>b__10_0>d.MoveNext() Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger) Volo.Abp.AspNetCore.Serilog.AbpSerilogMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<<CreateMiddleware>b__0>d.MoveNext() Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Volo.Abp.AspNetCore.Auditing.AbpAuditingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<<CreateMiddleware>b__0>d.MoveNext() Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) Volo.Abp.AspNetCore.Security.Claims.AbpDynamicClaimsMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<<CreateMiddleware>b__0>d.MoveNext() Volo.Abp.AspNetCore.Uow.AbpUnitOfWorkMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<<CreateMiddleware>b__0>d.MoveNext() Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<<CreateMiddleware>b__0>d.MoveNext() Volo.Abp.AspNetCore.MultiTenancy.MultiTenancyMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<<CreateMiddleware>b__0>d.MoveNext() Microsoft.AspNetCore.Builder.ApplicationBuilderAbpOpenIddictMiddlewareExtension+<>c__DisplayClass0_0+<<UseAbpOpenIddictValidation>b__0>d.MoveNext() Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Volo.Abp.AspNetCore.Security.AbpSecurityHeadersMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<<CreateMiddleware>b__0>d.MoveNext() Volo.Abp.AspNetCore.Tracing.AbpCorrelationIdMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<<CreateMiddleware>b__0>d.MoveNext() Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.RequestLocalization.AbpRequestLocalizationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next) Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+InterfaceMiddlewareBinder+<>c__DisplayClass2_0+<<CreateMiddleware>b__0>d.MoveNext() Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
-
0
hi
Can you change the logs level and share the logs again?
Thanks.
https://support.abp.io/QA/Questions/7383/Remember-me-does-not-work-properly-during-development#answer-3a134c11-55b1-b7cc-7378-4891bda51064
-
0
hi
Can you change the logs level and share the logs again?
Thanks.
https://support.abp.io/QA/Questions/7383/Remember-me-does-not-work-properly-during-development#answer-3a134c11-55b1-b7cc-7378-4891bda51064
Sorry, I didn't realize that with my configuration the Microsoft messages are only logged at the INFO level. I'll send them to you again.
-
0
Thanks. I will check it asap.
-
0
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
-
0
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; } }
-
0
I have changed this, but unfortunately
result.failure
is null.2024-06-24 09:59:47.742 +02:00 [DBG] AuthenticationScheme: Identity.Application was not authenticated. 2024-06-24 09:59:47.743 +02:00 [ERR] Authentication failed. 2024-06-24 09:59:47.743 +02:00 [ERR] [null] 2024-06-24 09:59:47.748 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ValidateHostHeader. 2024-06-24 09:59:47.749 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+EvaluateValidatedTokens. 2024-06-24 09:59:47.751 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromAuthorizationHeader. 2024-06-24 09:59:47.752 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromBodyForm. 2024-06-24 09:59:47.753 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromQueryString. 2024-06-24 09:59:47.755 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateRequiredTokens. 2024-06-24 09:59:47.755 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was marked as rejected by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateRequiredTokens. 2024-06-24 09:59:47.755 +02:00 [DBG] AuthenticationScheme: OpenIddict.Validation.AspNetCore was not authenticated. 2024-06-24 09:59:47.755 +02:00 [ERR] Authentication failed. 2024-06-24 09:59:47.756 +02:00 [ERR] [null] 2024-06-24 09:59:47.795 +02:00 [DBG] Policy authentication schemes did not succeed 2024-06-24 09:59:48.049 +02:00 [INF] Authorization failed. These requirements were not met: PermissionRequirement: Palma.Terminations 2024-06-24 09:59:48.054 +02:00 [INF] AuthenticationScheme: Identity.Application was challenged. 2024-06-24 09:59:48.065 +02:00 [INF] Request finished HTTP/2 GET https://localhost:44367/ - 302 0 null 1422.2229ms 2024-06-24 09:59:48.071 +02:00 [INF] Request starting HTTP/2 GET https://localhost:44367/Account/Login?ReturnUrl=%2F - null null 2024-06-24 09:59:48.083 +02:00 [DBG] The request path /Account/Login does not match a supported file type 2024-06-24 09:59:48.086 +02:00 [DBG] 1 candidate(s) found for the request path '/Account/Login' 2024-06-24 09:59:48.089 +02:00 [DBG] Endpoint '/Account/Login' with route pattern 'Account/Login' is valid for the request path '/Account/Login' 2024-06-24 09:59:48.090 +02:00 [DBG] Request matched endpoint '/Account/Login' 2024-06-24 09:59:48.091 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessRequestContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ResolveRequestUri. 2024-06-24 09:59:48.091 +02:00 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ResolveRequestUri. 2024-06-24 09:59:48.091 +02:00 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.OpenIddictServerHandlers+InferEndpointType. 2024-06-24 09:59:48.091 +02:00 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by Volo.Abp.Account.Web.Pages.Account.OpenIddictImpersonateInferEndpointType. 2024-06-24 09:59:48.091 +02:00 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ValidateTransportSecurityRequirement. 2024-06-24 09:59:48.091 +02:00 [DBG] The event OpenIddict.Server.OpenIddictServerEvents+ProcessRequestContext was successfully processed by OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandlers+ValidateHostHeader. 2024-06-24 09:59:48.096 +02:00 [DBG] AuthenticationScheme: Identity.Application was not authenticated. 2024-06-24 09:59:48.096 +02:00 [ERR] Authentication failed. 2024-06-24 09:59:48.096 +02:00 [ERR] [null] 2024-06-24 09:59:48.097 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ValidateHostHeader. 2024-06-24 09:59:48.097 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+EvaluateValidatedTokens. 2024-06-24 09:59:48.097 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromAuthorizationHeader. 2024-06-24 09:59:48.097 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromBodyForm. 2024-06-24 09:59:48.097 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.AspNetCore.OpenIddictValidationAspNetCoreHandlers+ExtractAccessTokenFromQueryString. 2024-06-24 09:59:48.097 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateRequiredTokens. 2024-06-24 09:59:48.097 +02:00 [DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was marked as rejected by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateRequiredTokens. 2024-06-24 09:59:48.097 +02:00 [DBG] AuthenticationScheme: OpenIddict.Validation.AspNetCore was not authenticated. 2024-06-24 09:59:48.097 +02:00 [ERR] Authentication failed. 2024-06-24 09:59:48.097 +02:00 [ERR] [null] 2024-06-24 09:59:48.135 +02:00 [DBG] Static files was skipped as the request already matched an endpoint. 2024-06-24 09:59:48.176 +02:00 [INF] Executing endpoint '/Account/Login' 2024-06-24 09:59:48.234 +02:00 [INF] Route matched with {page = "/Account/Login", area = "", action = "", controller = ""}. Executing page /Account/Login
-
0
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 haveidentity.application
cookies. -
0
-
0
hi
You can check the request cookies of
GET /
in not working case. -
0
-
0
hi
You mean before I sign in?
When "remember me" doesn't work.
-
0
hi
You mean before I sign in?
When "remember me" doesn't work.
Yes, that was the case with the first screenshot. This is what it looks like when I restart the application and log in for the first time (with the "Remember me" checkbox selected).
https://support.abp.io/QA/Questions/7383/Remember-me-does-not-work-properly-during-development#answer-3a135bb3-cfe0-abe2-f24c-7264e541c34d
-
0
-
0
I think we have a misunderstanding here.
When I am logged in, the cookie is correctly present. In the case where it does NOT work, I am not yet logged in. It would be the second screenshots from the login page that are relevant.
But we are probably looking in the wrong place. I have now found out that the cookies are there as long as the browser is open. After closing the browser (not just the tab, but the entire browser), these cookies are gone again.
Here are a few screenshots of the cookie cache:
However, I have not set any rules that would delete the cookies after closing the browser.
I checked various browsers again and found out that this behavior only occurs in the Edge browser (Chrome and Firefox work correctly). Any ideas?
-
0
I have found the problem... actually the setting was enabled to delete the cookies when closing the browser :-( I don't know that I ever enabled this... but now, after disabling it, it works as it should.
The setting can be found under: edge://settings/clearBrowsingDataOnClose
Thanks for your support!
-
0
😁