Entity Framework Authentication Scheme Store
This quickstart shows how to use an Entity Framework store for your authentication schemes. This uses a nuget package from Rock Solid Knowledge, and provides a custom implementation of IAuthenticationSchemeStore
and store options as JSON.
Using this implementation, only option values that are serializable as JSON will be stored in the database.
We provide EntityFramework Core implementations for relational databases by default. This means that you can use any EF-supported database with our component. When using EntityFramework, we recommend initializing your database and running migrations following the advice in EntityFramework Core Migrations documentation.
Nuget Installation
install-package Rsk.DynamicAuthenticationProviders.EntityFramework
Configuration
To start using the Entity Framework store, simply use the AddEntityFrameworkStore
extension on IDynamicAuthenticationBuilder
, passing in your DbContextOptionsBuilder
. The underlying DbContext has no dependencies on database type.
services.AddDynamicProviders()
.AddOpenIdConnect()
.AddEntityFrameworkStore(optionsBuilder => optionsBuilder.UseSqlServer("<connection_string>"));
This will change your registration of IAuthenticationSchemeStore
to use the type AuthenticationSchemeStore
.
Schema
The default schema uses JSON serializers to store provider specific options, using the following schema:
- Name: the authentication scheme name/id (
string
) - DisplayName: the authentication scheme display name (
string
) - HandlerType: the
IAuthenticationHandler
type to use for this authentication scheme (Type
) - Options:
AuthenticationSchemeOptions
options serialized as JSON (string
)