Ejemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/identity", idsrvApp =>
            {
                var factory = new IdentityServerServiceFactory()
                              //.UseInMemoryUsers(Users.Get())
                              .UseInMemoryClients(Clients.Get())
                              .UseInMemoryScopes(Scopes.Get());

                var userService           = new LocalUserService();
                factory.UserService       = new Registration <IUserService>(resolver => userService);
                factory.CorsPolicyService = new Registration <ICorsPolicyService>(new DefaultCorsPolicyService {
                    AllowAll = true
                });

                var viewOptions = new DefaultViewServiceOptions();
                viewOptions.Stylesheets.Add("/Content/Site.css");
                viewOptions.CacheViews = false;
                factory.ConfigureDefaultViewService(viewOptions);

                var options = new IdentityServerOptions
                {
                    SiteName = "Goloc",

                    AuthenticationOptions = new AuthenticationOptions
                    {
                        EnablePostSignOutAutoRedirect = true
                    },

                    SigningCertificate = LoadCertificate(),
                    Factory            = factory,
                };

                idsrvApp.UseIdentityServer(options);
            });
        }
Ejemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            //LogProvider.SetCurrentLogProvider(new TraceSourceLogProvider());

            // uncomment to enable HSTS headers for the host
            // see: https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security
            //app.UseHsts();
            bool _enableIdentityLogging = bool.Parse(ConfigurationManager.AppSettings["EnableIdentityLogging"]);

            app.Map("/core", coreApp =>
            {
                var _factory = InMemoryFactory.Create(
                    users: Users.Get(),
                    clients: Clients.Get(),
                    scopes: Scopes.Get());

                //var _factory = new IdentityServerServiceFactory();

                var _userService = new LocalUserService();

                _factory.UserService = new Registration <Core.Services.IUserService>(resolver => _userService);

                var _localClaimsProvider = new LocalClaimsProvider(_userService);

                _factory.ClaimsProvider = new Registration <Core.Services.IClaimsProvider>(resolver => _localClaimsProvider);

                _factory.CustomGrantValidator =
                    new Registration <ICustomGrantValidator>(typeof(CustomGrantValidator));

                _factory.ConfigureClientStoreCache();
                _factory.ConfigureScopeStoreCache();
                _factory.ConfigureUserServiceCache();

                var idsrvOptions = new IdentityServerOptions
                {
                    IssuerUri          = ConfigurationManager.AppSettings["IdentityIssuerUri"],
                    SiteName           = ConfigurationManager.AppSettings["IdentitySiteName"],
                    Factory            = _factory,
                    SigningCertificate = Cert.Load(),

                    CorsPolicy = CorsPolicy.AllowAll,

                    AuthenticationOptions = new AuthenticationOptions
                    {
                        IdentityProviders = ConfigureIdentityProviders,
                    },



                    LoggingOptions = new LoggingOptions
                    {
                        EnableHttpLogging          = _enableIdentityLogging,
                        EnableWebApiDiagnostics    = _enableIdentityLogging,
                        IncludeSensitiveDataInLogs = _enableIdentityLogging
                    },

                    EventsOptions = new EventsOptions
                    {
                        RaiseFailureEvents     = true,
                        RaiseInformationEvents = true,
                        RaiseSuccessEvents     = true,
                        RaiseErrorEvents       = true
                    }
                };

                coreApp.UseIdentityServer(idsrvOptions);
            });
        }