public static void UseIdentityServer(this IApplicationBuilder app, IdentityServerOptions options) { app.UseOwin(pipeline => { pipeline(next => { var builder = new Microsoft.Owin.Builder.AppBuilder(); var provider = app.ApplicationServices.GetService <DataProtection.IDataProtectionProvider>(); builder.Properties["security.DataProtectionProvider"] = new DataProtectionProviderDelegate(purposes => { var dataProtection = provider.CreateProtector(String.Join(",", purposes)); return(new DataProtectionTuple(dataProtection.Protect, dataProtection.Unprotect)); }); builder.Map("/admin", adminApp => { var factory = new IdentityManagerServiceFactory(); factory.ConfigureSimpleIdentityManagerService("AspId"); //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK"); adminApp.UseIdentityManager(new IdentityManagerOptions() { Factory = factory }); }); builder.UseIdentityServer(options); builder.UseAesDataProtectorProvider(); var appFunc = builder.Build(typeof(Func <IDictionary <string, object>, Task>)) as Func <IDictionary <string, object>, Task>; return(appFunc); }); }); }
public static void UseIdentityServer(this IApplicationBuilder app, IdentityServerOptions options) { app.UseOwin(pipeline => { pipeline(next => { var builder = new Microsoft.Owin.Builder.AppBuilder(); var provider = app.ApplicationServices.GetService<DataProtection.IDataProtectionProvider>(); builder.Properties["security.DataProtectionProvider"] = new DataProtectionProviderDelegate(purposes => { var dataProtection = provider.CreateProtector(String.Join(",", purposes)); return new DataProtectionTuple(dataProtection.Protect, dataProtection.Unprotect); }); builder.Map("/admin", adminApp => { var factory = new IdentityManagerServiceFactory(); factory.ConfigureSimpleIdentityManagerService("AspId"); //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK"); adminApp.UseIdentityManager(new IdentityManagerOptions() { Factory = factory }); }); builder.UseIdentityServer(options); builder.UseAesDataProtectorProvider(); var appFunc = builder.Build(typeof(Func<IDictionary<string, object>, Task>)) as Func<IDictionary<string, object>, Task>; return appFunc; }); }); }
public void Configure(IApplicationBuilder app, IApplicationEnvironment env) { Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Trace().CreateLogger(); BasePath = env.ApplicationBasePath; var certFile = Path.Combine(BasePath, "idsrv3test.pfx"); var options = ConfigureIdentityServer(certFile); app.UseOwin(pipeline => { pipeline(next => { var builder = new Microsoft.Owin.Builder.AppBuilder(); var provider = app.ApplicationServices.GetService<Microsoft.AspNet.DataProtection.IDataProtectionProvider>(); builder.Properties["security.DataProtectionProvider"] = new DataProtectionProviderDelegate(purposes => { var dataProtection = provider.CreateProtector(String.Join(",", purposes)); return new DataProtectionTuple(dataProtection.Protect, dataProtection.Unprotect); }); builder.UseAesDataProtectorProvider(); builder.Map("/admin", adminApp => { var factory = new IdentityManagerServiceFactory(); factory.ConfigureSimpleIdentityManagerService("AspId"); //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK"); adminApp.UseIdentityManager(new IdentityManagerOptions() { Factory = factory }); }); builder.UseIdentityServer(options); var appFunc = builder.Build(typeof(Func<IDictionary<string, object>, Task>)) as Func<IDictionary<string, object>, Task>; return appFunc; }); }); app.UseIdentityServer(options); }
public void Configure(IApplicationBuilder app, IApplicationEnvironment env) { Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Trace().CreateLogger(); BasePath = env.ApplicationBasePath; var certFile = Path.Combine(BasePath, "idsrv3test.pfx"); var options = ConfigureIdentityServer(certFile); app.UseOwin(pipeline => { pipeline(next => { var builder = new Microsoft.Owin.Builder.AppBuilder(); var provider = app.ApplicationServices.GetService <Microsoft.AspNet.DataProtection.IDataProtectionProvider>(); builder.Properties["security.DataProtectionProvider"] = new DataProtectionProviderDelegate(purposes => { var dataProtection = provider.CreateProtector(String.Join(",", purposes)); return(new DataProtectionTuple(dataProtection.Protect, dataProtection.Unprotect)); }); builder.UseAesDataProtectorProvider(); builder.Map("/admin", adminApp => { var factory = new IdentityManagerServiceFactory(); factory.ConfigureSimpleIdentityManagerService("AspId"); //factory.ConfigureCustomIdentityManagerServiceWithIntKeys("AspId_CustomPK"); adminApp.UseIdentityManager(new IdentityManagerOptions() { Factory = factory }); }); builder.UseIdentityServer(options); var appFunc = builder.Build(typeof(Func <IDictionary <string, object>, Task>)) as Func <IDictionary <string, object>, Task>; return(appFunc); }); }); app.UseIdentityServer(options); }