public void Configuration(IAppBuilder app) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Trace() .CreateLogger(); app.Map("/core", coreApp => { var factory = new IdentityServerServiceFactory() .UseInMemoryUsers(Users.Get()) .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); var viewOptions = new DefaultViewServiceOptions(); viewOptions.Stylesheets.Add("/Content/Site.css"); viewOptions.CacheViews = false; factory.ConfigureDefaultViewService(viewOptions); var options = new IdentityServerOptions { SiteName = "IdentityServer3 - Configuring DefaultViewService", SigningCertificate = Certificate.Get(), Factory = factory, AuthenticationOptions = new AuthenticationOptions{ IdentityProviders = ConfigureAdditionalIdentityProviders, } }; coreApp.UseIdentityServer(options); }); }
public static IdentityServerServiceFactory Configure(ApplicationDbContext dbContext) { var efConfig = new EntityFrameworkServiceOptions { ConnectionString = dbContext.ConnectionStringName, }; // these two calls just pre-populate the test DB from the in-memory config //running with db.Clients.Any() ConfigureClients(Clients.Get(), efConfig); ConfigureScopes(Scopes.Get(), efConfig); var factory = new IdentityServerServiceFactory(); factory.RegisterConfigurationServices(efConfig); factory.RegisterOperationalServices(efConfig); var viewOptions = new DefaultViewServiceOptions(); viewOptions.Stylesheets.Add("/Content/Site.css"); factory.ConfigureDefaultViewService(viewOptions); factory.CorsPolicyService = new Registration<ICorsPolicyService>(new DefaultCorsPolicyService { AllowAll = true }); return factory; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultViewService"/> class. /// </summary> public DefaultViewService(DefaultViewServiceOptions config, IViewLoader viewLoader) { if (config == null) throw new ArgumentNullException("config"); if (viewLoader == null) throw new ArgumentNullException("viewLoader"); this.config = config; this.viewLoader = viewLoader; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultViewService"/> class. /// </summary> public DefaultViewService(DefaultViewServiceOptions config, IViewLoader viewLoader) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (viewLoader == null) { throw new ArgumentNullException(nameof(viewLoader)); } this.config = config; this.viewLoader = viewLoader; }
public static IdentityServerServiceFactory Configure() { var factory = new IdentityServerServiceFactory(); var scopeStore = new InMemoryScopeStore(Scopes.Get()); factory.ScopeStore = new Registration<IScopeStore>(resolver => scopeStore); var clientStore = new InMemoryClientStore(Clients.Get()); factory.ClientStore = new Registration<IClientStore>(resolver => clientStore); factory.CorsPolicyService = new Registration<ICorsPolicyService>(new DefaultCorsPolicyService { AllowAll = true }); var viewOptions = new DefaultViewServiceOptions(); viewOptions.Stylesheets.Add("/Content/wts.css"); viewOptions.CacheViews = false; factory.ConfigureDefaultViewService(viewOptions); return factory; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultViewServiceRegistration"/> class. /// </summary> /// <param name="options">The options.</param> public DefaultViewServiceRegistration(DefaultViewServiceOptions options) : base(options) { }
private static IdentityServerOptions ConfigureIdentityServer(string certFile) { //var certFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "idsrv3test.pfx"); var factory = new IdentityServerServiceFactory().UseInMemoryUsers(Users.Get()) .UseInMemoryClients(Clients.Get()) .UseInMemoryScopes(Scopes.Get()); var viewOptions = new DefaultViewServiceOptions(); viewOptions.Stylesheets.Add("/Content/Site.css"); viewOptions.CacheViews = false; factory.ConfigureDefaultViewService(viewOptions); factory.ViewService = new IdentityServer3.Core.Configuration.Registration<IViewService>(typeof(CustomViewService)); //var userService = new LocalRegistrationUserService(); //factory.UserService = new Registration<IUserService>(resolver => userService); // factory.UserService = new Registration<IUserService, UserService>(); // factory.ClaimsProvider = new IdentityServer3.Core.Configuration.Registration<IClaimsProvider>(typeof(CustomClaimsProvider)); // factory.UserService = new IdentityServer3.Core.Configuration.Registration<IUserService>(typeof(CustomUserService)); // factory.CustomGrantValidators.Add(new IdentityServer3.Core.Configuration.Registration<ICustomGrantValidator>(typeof(CustomGrantValidator))); factory.CorsPolicyService = new IdentityServer3.Core.Configuration.Registration<ICorsPolicyService>(new DefaultCorsPolicyService() { AllowAll = true }); var options = new IdentityServerOptions { RequireSsl = false, SiteName = "Janitor - Mequanta Identity Service", Factory = factory, SigningCertificate = new X509Certificate2(certFile, "idsrv3test"), AuthenticationOptions = new AuthenticationOptions { IdentityProviders = ConfigureIdentityProviders, LoginPageLinks = new LoginPageLink[] { new LoginPageLink() { Text = "Register", Href = "localregistration" } } }, PluginConfiguration = ConfigurePlugins, EventsOptions = new EventsOptions() { RaiseSuccessEvents = true, RaiseErrorEvents = true, RaiseFailureEvents = true, RaiseInformationEvents = true } }; return options; }
/// <summary> /// Method to decide which view service to use /// </summary> private void LoadViewService(IdentityServerServiceFactory factory) { var configService = new ApplicationSettingsConfigurationService(); var viewType = configService.GetSetting("ViewService", "Default"); switch(viewType) { case "CustomStyle": //For the default view, but with our own stylesheet var viewOptions = new DefaultViewServiceOptions(); viewOptions.Stylesheets.Add("/CustomView/Styles/DefaultViewStyles.css"); viewOptions.CacheViews = false; factory.ConfigureDefaultViewService(viewOptions); //Put the options with custom stylesheet or javascript into the factory break; case "FullCustomView": //For a complete custom view factory.ViewService = new Registration<IViewService>(typeof(CustomViewService)); break; default: //Do nothing! break; } }
/// <summary> /// Configures the default view service. /// </summary> /// <param name="factory">The factory.</param> /// <param name="options">The default view service options.</param> /// <exception cref="System.ArgumentNullException"> /// factory /// or /// options /// </exception> /// <exception cref="System.InvalidOperationException">ViewService is already configured</exception> public static void ConfigureDefaultViewService(this IdentityServerServiceFactory factory, DefaultViewServiceOptions options) { if (factory == null) throw new ArgumentNullException("factory"); if (options == null) throw new ArgumentNullException("options"); if (factory.ViewService != null) throw new InvalidOperationException("A ViewService is already configured"); factory.ViewService = new DefaultViewServiceRegistration(options); }