Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

2020IP/TwentyTwenty.IdentityServer3.EntityFramework7

Repository files navigation

20|20 IdentityServer3.EntityFramework7

Deprecated: This repository is no longer in active development or maintenance. Use the official library instead: IdentityServer3.EntityFramework

Entity Framework 7 persistence layer for IdentityServer v3

Build status NuGet

Usage

The primary key type can be configured for ClientStore and ScopeStore. To facilitate this, subclass the ClientConfigurationContext<TKey> and ScopeConfigurationContext<TKey> with the desired key type.

public class ClientConfigurationContext : ClientConfigurationContext<Guid>
{
	public ClientConfigurationContext(DbContextOptions options)
		: base(options)
	{ }
}

public class ScopeConfigurationContext : ScopeConfigurationContext<Guid>
{
	public ScopeConfigurationContext(DbContextOptions options)
		: base(options)
	{ }
}

In the Startup.cs, register your DbContexts with Entity Framework

public void ConfigureServices(IServiceCollection services)
{
	...
	services.AddEntityFramework()
		.AddSqlServer()
		.AddDbContext<ClientConfigurationContext>(o => o.UseSqlServer(connectionString))
		.AddDbContext<ScopeConfigurationContext>(o => o.UseSqlServer(connectionString))
		.AddDbContext<OperationalContext>(o => o.UseSqlServer(connectionString));
	...
}

Configure the IdentityServerServiceFactory to use the EF stores.

public void Configure(IApplicationBuilder app)
{
	...
	var factory = new IdentityServerServiceFactory();
	factory.ConfigureEntityFramework(app.ApplicationServices)
		.RegisterOperationalStores()
		.RegisterClientStore<Guid, ClientConfigurationContext>()
		.RegisterScopeStore<Guid, ScopeConfigurationContext>();

	owinAppBuilder.UseIdentityServer(new IdentityServerOptions
	{
		...
		Factory = factory,
		...
	});
	...
}

About

An Entity Framework 7 persistence layer for IdentityServer v3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published