OpenIddict: 401 errors when two or more service instance count

后端 未结 2 1845
长发绾君心
长发绾君心 2021-01-14 09:53

I have a .NET Core application with Angular2 UI running in a Service Fabric Cluster that I secured using OpenIddict. I followed this example: https://github.com/openiddict/o

2条回答
  •  孤城傲影
    2021-01-14 10:21

    I solved this by looking at this: https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/implementation/key-storage-providers#azure-and-redis

    Here are the basic steps I took:

    1. Create a blob storage account to store the shared keys.

    2. Add the following code to your Startup.cs:

    var storageAccount = CloudStorageAccount.Parse("blob storage connection string");
    
    //Create the blob client object.
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
    
    //Get a reference to a container to use for the sample code, and create it if it does not exist.
    CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
    container.CreateIfNotExists();
    
    services.AddDataProtection()
        .SetApplicationName("MyApplication")
        .PersistKeysToAzureBlobStorage(container, "myblobname");
    

    That was it.

提交回复
热议问题