forked from brunobritodev/JPProject.IdentityServer4.AdminUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIdentityServerConfig.cs
More file actions
34 lines (29 loc) · 1.39 KB
/
IdentityServerConfig.cs
File metadata and controls
34 lines (29 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;
namespace Jp.Infra.Data.Sqlite.Configuration
{
public static class IdentityServerConfig
{
public static IIdentityServerBuilder UseIdentityServerSqlite(this IIdentityServerBuilder builder, string connectionString)
{
var migrationsAssembly = typeof(IdentityServerConfig).GetTypeInfo().Assembly.GetName().Name;
// this adds the config data from DB (clients, resources)
builder.AddConfigurationStore(options =>
{
options.ConfigureDbContext = b =>
b.UseSqlite(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly));
})
// this adds the operational data from DB (codes, tokens, consents)
.AddOperationalStore(options =>
{
options.ConfigureDbContext = b =>
b.UseSqlite(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly));
// this enables automatic token cleanup. this is optional.
options.EnableTokenCleanup = true;
options.TokenCleanupInterval = 15; // frequency in seconds to cleanup stale grants. 15 is useful during debugging
});
return builder;
}
}
}