3

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.

Bala P
  • 143
  • 1
  • 12
  • Hi there, did you ever get an answer to this? – Phil Nov 14 '21 at 01:38
  • @Phil NO I couldnt get far with this issue and I had to abandon that POC. But I am still curious to know if that can be accomplished? – Bala P Nov 15 '21 at 20:30
  • No luck for me. I ended up just making a simple IdentityDBContext that worked with my database, and going from there. kind of a PITA – Phil Nov 15 '21 at 21:03

0 Answers0