Skip to content
This repository was archived by the owner on Aug 26, 2026. It is now read-only.

webfarmsetup

Terje Sandstrøm edited this page Oct 22, 2020 · 1 revision

Setting up to run in a webfarm

If you run on a webfarm you need to persist the keys protecting your cookies.

Fhi.HelseId package comes with a default sql storage based persistence. It can be enabled by adding a configuration section and enabling that in the startup file, and then call the extension method for the dataprotection.

Assuming you have stored the injected configuration in a Configuration property.

        public IConfiguration Configuration { get; }

        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

you enable it by adding this at the bottom of the ConfigureServices method

   services.AddSqlDataProtection(Configuration);

In the appsettings file, there should be a config section like:

"DataProtectionConfig": {
    "Enabled": "true",
    // Make sure the database exists, and that the service user running the 
    // application has permission to create a table
    "ConnectionString": "Server=.;Database=SomeGoodDatabaseName;Trusted_Connection=True;",
    "Schema": "DataProtection",  // default value, so you dont need to add this if you dont want to change it
    "TableName": "Keys" // default value, so you dont need to add this if you dont want to change it
  },

Notes

  • Currently the keys are not encrypted in the database.

Clone this wiki locally