public static IAppBuilder UseIdentityServer(this IAppBuilder app) { // uncomment to enable HSTS headers for the host // see: https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security //app.UseHsts(); app.Map("/core", coreApp => { var factory = new IdentityServerServiceFactory() .UseInMemoryUsers(Users.Get()) .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); factory.AddCustomGrantValidators(); factory.AddCustomTokenResponseGenerator(); factory.ConfigureClientStoreCache(); factory.ConfigureScopeStoreCache(); factory.ConfigureUserServiceCache(); var idsrvOptions = new IdentityServerOptions { Factory = factory, SigningCertificate = Cert.Load(), Endpoints = new EndpointOptions { // replaced by the introspection endpoint in v2.2 EnableAccessTokenValidationEndpoint = false }, AuthenticationOptions = new AuthenticationOptions { IdentityProviders = ConfigureIdentityProviders, EnablePostSignOutAutoRedirect = true }, //LoggingOptions = new LoggingOptions //{ // EnableKatanaLogging = true //}, //EventsOptions = new EventsOptions //{ // RaiseFailureEvents = true, // RaiseInformationEvents = true, // RaiseSuccessEvents = true, // RaiseErrorEvents = true //} }; coreApp.UseIdentityServer(idsrvOptions); }); return(app); }
public static IAppBuilder UseIdentityServer(this IAppBuilder app) { // uncomment to enable HSTS headers for the host // see: https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security //app.UseHsts(); app.Map("/core", coreApp => { var factory = new IdentityServerServiceFactory() .UseInMemoryUsers(Users.Get()) .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); factory.AddCustomGrantValidators(); factory.AddCustomTokenResponseGenerator(); factory.ConfigureClientStoreCache(); factory.ConfigureScopeStoreCache(); factory.ConfigureUserServiceCache(); var idsrvOptions = new IdentityServerOptions { Factory = factory, SigningCertificate = Cert.Load(), Endpoints = new EndpointOptions { // replaced by the introspection endpoint in v2.2 EnableAccessTokenValidationEndpoint = false }, AuthenticationOptions = new AuthenticationOptions { IdentityProviders = ConfigureIdentityProviders, EnablePostSignOutAutoRedirect = true }, //LoggingOptions = new LoggingOptions //{ // EnableKatanaLogging = true //}, //EventsOptions = new EventsOptions //{ // RaiseFailureEvents = true, // RaiseInformationEvents = true, // RaiseSuccessEvents = true, // RaiseErrorEvents = true //} }; coreApp.UseIdentityServer(idsrvOptions); }); return app; }
public static IAppBuilder UseIdentityServer(this IAppBuilder app) { // uncomment to enable HSTS headers for the host // see: https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security //app.UseHsts(); app.Map("/core", coreApp => { var factory = new IdentityServerServiceFactory() //.UseInMemoryUsers(Users.Get()) Fabio .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); factory.AddCustomGrantValidators(); factory.AddCustomTokenResponseGenerator(); factory.ConfigureClientStoreCache(); factory.ConfigureScopeStoreCache(); //factory.ConfigureUserServiceCache(); Fabio // Fabio custom User on EF var userService = new LocalRegistrationUserService(); factory.UserService = new Registration <IUserService>(resolver => userService); factory.CorsPolicyService = new Registration <ICorsPolicyService>(new DefaultCorsPolicyService { AllowAll = true }); var idsrvOptions = new IdentityServerOptions { Factory = factory, SigningCertificate = Cert.Load(), RequireSsl = false, Endpoints = new EndpointOptions { // replaced by the introspection endpoint in v2.2 EnableAccessTokenValidationEndpoint = false }, // Fabio inibito configurazione provider esterni (facebook, google, etc ...) //AuthenticationOptions = new AuthenticationOptions //{ // IdentityProviders = ConfigureIdentityProviders, // EnableAutoCallbackForFederatedSignout = true //}, }; coreApp.UseIdentityServer(idsrvOptions); }); return(app); }
public static IAppBuilder UseIdentityServer(this IAppBuilder app) { // uncomment to enable HSTS headers for the host // see: https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security //app.UseHsts(); app.Map("/core", coreApp => { var factory = new IdentityServerServiceFactory() .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); //.UseInMemoryUsers(Users.GetCustomUsers()); //var userService = new Host.Configuration.Services.CustomUserService(); //factory.UserService = new Registration<IUserService>(resolver => userService); factory.UserService = new Registration <IUserService, Host.Configuration.Services.CustomUserService>(); factory.AddCustomGrantValidators(); factory.AddCustomTokenResponseGenerator(); factory.ConfigureClientStoreCache(); factory.ConfigureScopeStoreCache(); factory.ConfigureUserServiceCache(); var idsrvOptions = new IdentityServerOptions { Factory = factory, SigningCertificate = Cert.Load(), Endpoints = new EndpointOptions { // replaced by the introspection endpoint in v2.2 EnableAccessTokenValidationEndpoint = false } //, //AuthenticationOptions = new AuthenticationOptions //{ // IdentityProviders = ConfigureIdentityProviders, // EnableAutoCallbackForFederatedSignout = true //}, }; coreApp.UseIdentityServer(idsrvOptions); }); return(app); }
public static IAppBuilder UseCustomIdentityServer(this IAppBuilder app) { // uncomment to enable HSTS headers for the host // see: https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security //app.UseHsts(); app.Map("/core", coreApp => { var factory = new IdentityServerServiceFactory() .UseInMemoryUsers(Users.Get()) .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); factory.AddCustomGrantValidators(); factory.AddCustomTokenResponseGenerator(); factory.ConfigureClientStoreCache(); factory.ConfigureScopeStoreCache(); factory.ConfigureUserServiceCache(); var idsrvOptions = new IdentityServerOptions { Factory = factory, SigningCertificate = Cert.Load(), Endpoints = new EndpointOptions { // replaced by the introspection endpoint in v2.2 EnableAccessTokenValidationEndpoint = false }, AuthenticationOptions = new AuthenticationOptions { IdentityProviders = ConfigureIdentityProviders //EnablePostSignOutAutoRedirect = true }, NotBeforeLeeway = TimeSpan.FromMinutes(1) //LoggingOptions = new LoggingOptions //{ // EnableKatanaLogging = true //}, //EventsOptions = new EventsOptions //{ // RaiseFailureEvents = true, // RaiseInformationEvents = true, // RaiseSuccessEvents = true, // RaiseErrorEvents = true //} }; //START CUSTOM IdentityServer coreApp.Use<RequireSslMiddleware>(); idsrvOptions.Validate(); // turn off weird claim mappings for JWTs JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>(); JwtSecurityTokenHandler.OutboundClaimTypeMap = new Dictionary<string, string>(); if (idsrvOptions.LoggingOptions.EnableKatanaLogging) { coreApp.SetLoggerFactory(new LibLogKatanaLoggerFactory()); } coreApp.UseEmbeddedFileServer(); coreApp.ConfigureRequestId(); coreApp.ConfigureDataProtectionProvider(idsrvOptions); coreApp.ConfigureIdentityServerBaseUrl(idsrvOptions.PublicOrigin); coreApp.ConfigureIdentityServerIssuer(idsrvOptions); // this needs to be earlier than the autofac middleware so anything is disposed and re-initialized // if we send the request back into the pipeline to render the logged out page coreApp.ConfigureRenderLoggedOutPage(); var container = AutofacConfig.Configure(idsrvOptions); coreApp.UseAutofacMiddleware(container); coreApp.UseCors(container.Resolve<ICorsPolicyService>()); coreApp.ConfigureCookieAuthentication(idsrvOptions.AuthenticationOptions.CookieOptions, idsrvOptions.DataProtector); // this needs to be before external middleware coreApp.ConfigureSignOutMessageCookie(); if (idsrvOptions.PluginConfiguration != null) { idsrvOptions.PluginConfiguration(coreApp, idsrvOptions); } if (idsrvOptions.AuthenticationOptions.IdentityProviders != null) { idsrvOptions.AuthenticationOptions.IdentityProviders(coreApp, Constants.ExternalAuthenticationType); } coreApp.ConfigureHttpLogging(idsrvOptions.LoggingOptions); SignatureConversions.AddConversions(coreApp); var httpConfig = WebApiConfig.Configure(idsrvOptions, container); coreApp.UseAutofacWebApi(httpConfig); coreApp.UseWebApi(httpConfig); //using (var child = container.CreateScopeWithEmptyOwinContext()) //{ // var eventSvc = child.Resolve<IEventService>(); // // TODO -- perhaps use AsyncHelper instead? // DoStartupDiagnosticsAsync(options, eventSvc).Wait(); //} }); return app; }