IdentityServer4 not working in production

后端 未结 3 756
渐次进展
渐次进展 2020-12-11 01:42

I am using IdentityServer4 with React start project from ASP.NET Core 3.0. preview 4 and it works perfectly until I build the solution and try to run it from cmd prompt usin

3条回答
  •  轮回少年
    2020-12-11 02:21

    So I was able to solve my issues using this piece of documentation: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity-api-authorization?view=aspnetcore-3.0#example-deploy-to-azure-websites

    I had to enable "Copy if newer" to the appsettings.json properties so that it would get copied to the build folder.

    I also added the following to the appsettings.json file:

    "IdentityServer": {
    "Clients": {
      "Client": {
        "Profile": "IdentityServerSPA"
      }
    },
    "Key": {
      "Type": "Store",
      "StoreName": "My",
      "StoreLocation": "LocalMachine",
      "Name": "CN=SigningCertificate"
    }
    }
    

    Now the Key.Type is specified, which means that we can now just add the following to the startup.cs:

    // Configure IdentityServer4
    var identityBuilder = services.AddIdentityServer();
    identityBuilder.AddApiAuthorization();
    
    if (!Environment.IsDevelopment())
         identityBuilder.AddSigningCredentials();
    

    I still do not understand why other people are not experiencing this issue, since I am not able to find any other threads on this issue and the regular way seems to work for everyone else. The only downside to this is that I need to install the certificate on the machine now instead of getting it as file.

提交回复
热议问题