OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Data protection keys got vanished by cache keys when using `OrchardCore.Redis.DataProtection` together with `OrchardCore.Redis.Cache`

Open lamualfa opened this issue 1 month ago • 1 comments

When using OrchardCore.Redis.DataProtection only: Image


When using OrchardCore.Redis.DataProtection together with OrchardCore.Redis.Cache:

Image

Startup.cs

public class Startup
{
    // Another code

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllers();
        services.AddHttpClient();

        services.AddHsts(options =>
        {
            options.MaxAge = TimeSpan.FromDays(365);
            options.IncludeSubDomains = true;
            options.Preload = true;
        });

        services.Configure<CookiePolicyOptions>(options =>
        {
            options.Secure = CookieSecurePolicy.Always;
            options.HttpOnly = HttpOnlyPolicy.Always;
            options.MinimumSameSitePolicy = SameSiteMode.Lax;
        });

        var orchardBuilder = services.AddOrchardCms();

        orchardBuilder
            .AddSetupFeatures("OrchardCore.AutoSetup")
            .AddTenantFeatures(
                "OrchardCore.Redis",
                "OrchardCore.Redis.Cache",
                "OrchardCore.Redis.Lock",
                "OrchardCore.Redis.DataProtection"
            );
    }
}

Dependencies

  • OrchardCore.Application.Cms.Targets 3.0.0-preview-18841
  • OrchardCore.Redis 3.0.0-preview-18841

lamualfa avatar Dec 10 '25 05:12 lamualfa

Please elaborate when this vanishing happens.

Piedone avatar Dec 10 '25 20:12 Piedone

Also, have you enabled Redis persistence? (on your redis server)

sebastienros avatar Dec 11 '25 19:12 sebastienros

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

github-actions[bot] avatar Dec 11 '25 19:12 github-actions[bot]

Please elaborate when this vanishing happens.

When using OrchardCore.Redis.DataProtection alone:

  1. Running new mssql & redis using docker compose
  2. Restore bak file to mssql (containing dump from latest saved content from production)
  3. Restore assets to s3
  4. Running orchard core cms with auto setup in it
  5. Checking redis, nothing saved yet
  6. Visiting orchard core cms on http://localhost:8080
  7. Response 404
  8. Checking redis, now it's have 1 key containing dataprotection key (see first screenshot on original comment)

When using OrchardCore.Redis.DataProtection & OrchardCore.Redis.Cache:

  1. Running new mssql & redis using docker compose
  2. Restore bak file to mssql (containing dump from latest saved content from production)
  3. Restore assets to s3
  4. Running orchard core cms with auto setup in it
  5. Checking redis, nothing saved yet
  6. Visiting orchard core cms on http://localhost:8080
  7. Response 404
  8. Checking redis, now it's full with orchard caches, no dataprotection key saved (see second screenshot on original comment)

Both are tested from empty volumes. So no states/caches are related between each others.

Let see if i can make this one reproducible through public repo example.

Thanks.

lamualfa avatar Dec 12 '25 04:12 lamualfa

Also, have you enabled Redis persistence? (on your redis server)

No. But as long as the redis container doesn't restarted, it must be there i think unless something delete it.

Without OrchardCore.Redis.Cache installed using AddSetupFeatures, the dataprotection cache is still there no matter i visited the web many times.

lamualfa avatar Dec 12 '25 04:12 lamualfa

Thank you! It seems to me that it's not necessarily that the DataProtection keys vanish, but they maybe aren't created in the first place when OrchardCore.Redis.Cache is enabled.

I checked out the code but nothing struck me as able to cause the behavior you're seeing.

Do you see any errors in the log?

Just to confirm, getting a 404 response on step 7 is expected, right?

Piedone avatar Dec 12 '25 21:12 Piedone