/// <summary> /// Registers the OpenIddict entity sets in the Entity Framework context /// using the specified entities and the specified key type. /// </summary> /// <param name="builder">The builder used to configure the Entity Framework context.</param> /// <returns>The Entity Framework context builder.</returns> public static DbContextOptionsBuilder UseOpenIddict<TApplication, TAuthorization, TScope, TToken, TKey>([NotNull] this DbContextOptionsBuilder builder) where TApplication : OpenIddictApplication<TKey, TToken> where TAuthorization : OpenIddictAuthorization<TKey, TToken> where TScope : OpenIddictScope<TKey> where TToken : OpenIddictToken<TKey> where TKey : IEquatable<TKey> { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } var extension = new OpenIddictExtension<TApplication, TAuthorization, TScope, TToken, TKey>(); ((IDbContextOptionsBuilderInfrastructure) builder).AddOrUpdateExtension(extension); return builder; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseSwaggerWithOAuth(); app.UseAuthentication(); OpenIddictExtension.InitializeAsync(app.ApplicationServices).GetAwaiter().GetResult(); app.UseMvc(); }