I am wokring on a .NET 5 POC with custom storage provider and adding authorization server with OpenIDDict. I am able to get the custom store implementation working but I am unable to wire up the authorization server to use the custom store implementation as documentation exists only for EntityFramework implementation.
Here is my startup configurationservices snippet
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IUserStore<ApplicationUser>, UserStore>();
services.AddTransient<IRoleStore<ApplicationRole>, RoleStore>();
services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddDefaultTokenProviders();
string connectionString = Configuration.GetConnectionString("DefaultConnection");
services.AddTransient<SqlConnection>(e => new SqlConnection(connectionString));
services.AddOpenIddict()
.AddServer(options =>
{
options.AllowClientCredentialsFlow();
options.SetTokenEndpointUris("connect/token");
// Encryption and signing of tokens
options
.AddEphemeralEncryptionKey()
.AddEphemeralSigningKey();
// Register scopes (permissions)
options.RegisterScopes("api");
options.UseAspNetCore().EnableTokenEndpointPassthrough();
});
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "ServerAPI", Version = "v1" });
});
}
typical EF implementation looks like this
services.AddDbContext<DbContext>(options =>
{
// Configure the context to use an in-memory store.
options.UseInMemoryDatabase(nameof(DbContext));
// Register the entity sets needed by OpenIddict.
options.UseOpenIddict();
});
any pointers on what custom store implementation should be? Also the documentation provided here for custom authorization server seems to be outdated and not maintained anymore https://kevinchalet.com/2016/07/13/creating-your-own-openid-connect-server-with-asos-creating-your-own-authorization-provider/ as well.