Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 09d7d09

Browse files
committed
Merge branch 'features/IdSrvTimeoutReview' into dev
2 parents 28f7baa + a064795 commit 09d7d09

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

src/Services/Identity/Identity.API/Configuration/Config.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUr
5858
"marketing",
5959
"webshoppingagg",
6060
"orders.signalrhub"
61-
}
61+
},
6262
},
6363
new Client
6464
{
@@ -124,6 +124,8 @@ public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUr
124124
"webshoppingagg",
125125
"orders.signalrhub"
126126
},
127+
AccessTokenLifetime = 60*60*2, // 2 hours
128+
IdentityTokenLifetime= 60*60*2 // 2 hours
127129
},
128130
new Client
129131
{
@@ -248,7 +250,6 @@ public static IEnumerable<Client> GetClients(Dictionary<string,string> clientsUr
248250
"webshoppingagg"
249251
}
250252
}
251-
252253
};
253254
}
254255
}

src/Services/Identity/Identity.API/Startup.cs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,34 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
8080
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
8181

8282
// Adds IdentityServer
83-
services.AddIdentityServer(x => x.IssuerUri = "null")
84-
.AddSigningCredential(Certificate.Get())
85-
.AddAspNetIdentity<ApplicationUser>()
86-
.AddConfigurationStore(options =>
83+
services.AddIdentityServer(x =>
84+
{
85+
x.IssuerUri = "null";
86+
x.Authentication.CookieLifetime = TimeSpan.FromHours(2);
87+
})
88+
.AddSigningCredential(Certificate.Get())
89+
.AddAspNetIdentity<ApplicationUser>()
90+
.AddConfigurationStore(options =>
91+
{
92+
options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString,
93+
sqlServerOptionsAction: sqlOptions =>
94+
{
95+
sqlOptions.MigrationsAssembly(migrationsAssembly);
96+
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
97+
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
98+
});
99+
})
100+
.AddOperationalStore(options =>
87101
{
88102
options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString,
89-
sqlServerOptionsAction: sqlOptions =>
90-
{
91-
sqlOptions.MigrationsAssembly(migrationsAssembly);
92-
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
93-
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
94-
});
103+
sqlServerOptionsAction: sqlOptions =>
104+
{
105+
sqlOptions.MigrationsAssembly(migrationsAssembly);
106+
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
107+
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
108+
});
95109
})
96-
.AddOperationalStore(options =>
97-
{
98-
options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString,
99-
sqlServerOptionsAction: sqlOptions =>
100-
{
101-
sqlOptions.MigrationsAssembly(migrationsAssembly);
102-
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
103-
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
104-
});
105-
})
106-
.Services.AddTransient<IProfileService, ProfileService>();
110+
.Services.AddTransient<IProfileService, ProfileService>();
107111

108112
var container = new ContainerBuilder();
109113
container.Populate(services);

src/Web/WebMVC/Startup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public static IServiceCollection AddCustomAuthentication(this IServiceCollection
238238
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
239239
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
240240
})
241-
.AddCookie()
241+
.AddCookie(setup=>setup.ExpireTimeSpan = TimeSpan.FromHours(2))
242242
.AddOpenIdConnect(options =>
243243
{
244244
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
@@ -257,7 +257,7 @@ public static IServiceCollection AddCustomAuthentication(this IServiceCollection
257257
options.Scope.Add("marketing");
258258
options.Scope.Add("locations");
259259
options.Scope.Add("webshoppingagg");
260-
options.Scope.Add("orders.signalrhub");
260+
options.Scope.Add("orders.signalrhub");
261261
});
262262

263263
return services;

0 commit comments

Comments
 (0)