Browse Source

Added Identity server code to handle if the IdentityServer is being hosted on https or not

pull/1259/head
Tim McCarthy 5 years ago
parent
commit
f97a187723
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      src/Services/Identity/Identity.API/Startup.cs

+ 11
- 0
src/Services/Identity/Identity.API/Startup.cs View File

@ -75,11 +75,22 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API
var connectionString = Configuration["ConnectionString"]; var connectionString = Configuration["ConnectionString"];
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name; var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
// Check to see if the Identity server is using https
var identityUrl = this.Configuration.GetValue<string>("IdentityUrl");
var identityUri = new Uri(identityUrl);
var isUsingHttps = identityUri.Scheme == Uri.UriSchemeHttps;
// Adds IdentityServer // Adds IdentityServer
services.AddIdentityServer(x => services.AddIdentityServer(x =>
{ {
x.IssuerUri = "null"; x.IssuerUri = "null";
x.Authentication.CookieLifetime = TimeSpan.FromHours(2); x.Authentication.CookieLifetime = TimeSpan.FromHours(2);
// Need this if using https
if (isUsingHttps)
{
x.PublicOrigin = identityUrl;
}
}) })
.AddDevspacesIfNeeded(Configuration.GetValue("EnableDevspaces", false)) .AddDevspacesIfNeeded(Configuration.GetValue("EnableDevspaces", false))
.AddSigningCredential(Certificate.Get()) .AddSigningCredential(Certificate.Get())


Loading…
Cancel
Save