Skip to content

Cannot login after setup when using Postgres DB (v7.22+) #1316

Description

@pergerch

I am trying to setup Squidex using Postgres as database. The migrations are applied and the initial setup of an admin account (just providing email and password) works, but then the login fails with an openiddict error. The issue can be easily reproduced with the attached docker-compose.yml file. Just test the different image versions:

  • 7.21.0 -> works
  • 7.22.0 -> fails with the error below
  • 7.23.0 -> fails as well

Steps to reproduce:

  1. docker-compose up
  2. Navigate to http://localhost:8080
  3. Create an admin account by entering email, password, confirm password
  4. Try to log in with these credentials again --> Squid saying "something went wrong"

Error log entry

squidex_postgres-1  |   "category": "Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware",
squidex_postgres-1  |   "exception": {
squidex_postgres-1  |     "type": "Microsoft.EntityFrameworkCore.DbUpdateException",
squidex_postgres-1  |     "message": "An error occurred while saving the entity changes. See the inner exception for details.",
squidex_postgres-1  |     "stackTrace": "   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable\u00601 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable\u00601 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable\u00601 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChangesAsync(IList\u00601 entries, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList\u00601 entriesToSave, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)\n   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func\u00604 operation, Func\u00604 verifySucceeded, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)\n   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)\n   at OpenIddict.EntityFrameworkCore.OpenIddictEntityFrameworkCoreTokenStore\u00603.CreateAsync(TToken token, CancellationToken cancellationToken)\n   at OpenIddict.Core.OpenIddictTokenManager\u00601.CreateAsync(TToken token, CancellationToken cancellationToken)\n   at OpenIddict.Core.OpenIddictTokenManager\u00601.CreateAsync(OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken)\n   at OpenIddict.Core.OpenIddictTokenManager\u00601.OpenIddict.Abstractions.IOpenIddictTokenManager.CreateAsync(OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken)\n   at OpenIddict.Server.OpenIddictServerHandlers.Protection.CreateTokenEntry.HandleAsync(GenerateTokenContext context)\n   at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)\n   at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)\n   at OpenIddict.Server.OpenIddictServerHandlers.GenerateAuthorizationCode.HandleAsync(ProcessSignInContext context)\n   at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)\n   at OpenIddict.Server.OpenIddictServerDispatcher.DispatchAsync[TContext](TContext context)\n   at OpenIddict.Server.AspNetCore.OpenIddictServerAspNetCoreHandler.SignInAsync(ClaimsPrincipal user, AuthenticationProperties properties)\n   at Microsoft.AspNetCore.Authentication.AuthenticationService.SignInAsync(HttpContext context, String scheme, ClaimsPrincipal principal, AuthenticationProperties properties)\n   at Microsoft.AspNetCore.Authentication.AuthenticationServiceImpl.SignInAsync(HttpContext context, String scheme, ClaimsPrincipal principal, AuthenticationProperties properties)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeResultAsync\u003Eg__Logged|22_0(ResourceInvoker invoker, IActionResult result)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeNextResultFilterAsync\u003Eg__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State\u0026 next, Scope\u0026 scope, Object\u0026 state, Boolean\u0026 isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeResultFilters\u003Eg__Awaited|28_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeNextResourceFilter\u003Eg__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State\u0026 next, Scope\u0026 scope, Object\u0026 state, Boolean\u0026 isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeFilterPipelineAsync\u003Eg__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeAsync\u003Eg__Logged|17_1(ResourceInvoker invoker)\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.\u003CInvokeAsync\u003Eg__Logged|17_1(ResourceInvoker invoker)\n   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\n   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.\u003CInvoke\u003Eg__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)"
squidex_postgres-1  |   }
squidex_postgres-1  | }

Script to reproduce

It looks like there is a regression bug starting from 7.22 onwards.

Here is a minimal docker-compose.yml for testing, based on your TestSuite docker-compose:

services:
  db_postgres:
    image: "postgis/postgis"
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_PASSWORD=postgres
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      retries: 10

  squidex_postgres:
    image: squidex/squidex:7.23.0   # <--- Change here to 7.21.0 and it works
    ports:
      - "5000:5000"
    environment:
      - ASPNETCORE_URLS=http://+:5000
      - TEMPLATES__LOCALURL=http://localhost:5000

      - EVENTSTORE__TYPE=Sql
      - STORE__TYPE=Sql
      - IDENTITY__TYPE=Sql
      - STORE__SQL__CONNECTIONSTRING=Server=db_postgres;Port=5432;Database=postgres;Pooling=true;Username=postgres;Password=postgres;SSL Mode=Disable;Include Error Detail=true;
      - STORE__SQL__PROVIDER=Postgres
      - MESSAGING__TYPE=Sql
      - URLS__BASEURL=http://localhost:8080
    depends_on:
      db_postgres:
        condition: service_healthy

  proxy_postgres:
    image: squidex/caddy-proxy-path:2.6.2
    ports:
      - "8080:8080"
    environment:
      - SITE_ADDRESS=http://localhost:8080
      - SITE_PATH=*
      - SITE_SERVER="squidex_postgres:5000"
    depends_on:
      - squidex_postgres
    restart: unless-stopped

  webhookcatcher:
    image: tarampampam/webhook-tester:2
    command: serve --port 1026
    ports:
      - "1026:1026"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions