public void Configuration(IAppBuilder app)
        {
            //var factory2 = new IdentityServerServiceFactory();

            //LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            //var factory = InMemoryFactory.Create(
            //    scopes: Scopes.Get(),
            //    clients: Clients.Get(),
            //    users: Users2.Get()
            //    );
            var factory = new IdentityServerServiceFactory();
            var scopeStore = new InMemoryScopeStore(Scopes.Get());
            factory.ScopeStore = new Registration<IScopeStore>(scopeStore);
            var clientStore = new InMemoryClientStore(Clients.Get());
            factory.ClientStore = new Registration<IClientStore>(clientStore);
            factory.TokenService = new Registration<ITokenService>(typeof(MyCustomTokenService));
            factory.RefreshTokenStore = new Registration<IRefreshTokenStore>(typeof(MyCustomRefreshTokenStore));
            factory.CustomTokenValidator = new Registration<ICustomTokenValidator>(new MyCustomTokenValidator());
            factory.TokenHandleStore = new Registration<ITokenHandleStore>(new MyCustomTokenHandleStore());
            factory.ConfigureUserService("AspId");
            LogProvider.SetCurrentLogProvider(new NLogLogProvider());
            //LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
            //factory.TokenHandleStore = new Registration<ITokenHandleStore>();
            //factory.RefreshTokenStore = new Registration<IRefreshTokenStore>();
            //factory.CustomTokenValidator = new Registration<ICustomTokenValidator>(new MyCustomTokenValidator());
            //factory.Register(new Registration<IUserService, MyCustomUserService>());
            //factory.Register(new Registration<IMyCustomLogger, MyCustomLogger>());
            //factory.UserService = new Registration<IUserService>(typeof(IUserService));
            var options = new IdentityServerOptions
            {
                Factory = factory,
                //IssuerUri = "https://idsrv3.com",
                SiteName = "Thinktecture IdentityServer3 Halo",
                SigningCertificate = Certificate.Get(),
                RequireSsl = false,
                CspOptions = new CspOptions
                {
                    Enabled =true,
                },
                Endpoints = new EndpointOptions
                {
                    EnableAccessTokenValidationEndpoint = true,
                    EnableTokenEndpoint = true,
                    EnableTokenRevocationEndpoint = true,
                    EnableIdentityTokenValidationEndpoint = true,

                    //remove in production
                    EnableDiscoveryEndpoint = true,

                    EnableAuthorizeEndpoint= false,
                    EnableClientPermissionsEndpoint= false,
                    EnableCspReportEndpoint= false,

                    EnableEndSessionEndpoint=false,
                    EnableCheckSessionEndpoint = false,
                    EnableUserInfoEndpoint = false
                },
                AuthenticationOptions = new AuthenticationOptions
                {
                    EnableLocalLogin = true,
                    EnableLoginHint = false,
                },
                LoggingOptions = new LoggingOptions
                {
                    EnableHttpLogging=true,
                    EnableWebApiDiagnostics=true,
                    IncludeSensitiveDataInLogs=true,
                    WebApiDiagnosticsIsVerbose=true
                },
                EnableWelcomePage = false,
                IssuerUri = "https://HFL0100:44333"

            };
            options.CorsPolicy.AllowedOrigins.Add("http://localhost:14869/");

            app.UseHsts();
            app.UseIdentityServer(options);
        }
示例#2
0
        public void Configuration(IAppBuilder app)
        {
            #if DEBUG
            const string serverName = "devservername";
            #else
               const string serverName = "prodservername";
            #endif

            LogProvider.SetCurrentLogProvider(new TraceSourceLogProvider());

            const string connectionName = "AspId";

            var factory = new IdentityServerServiceFactory();
            factory.ConfigureClientService(connectionName);
            factory.ConfigureScopeService(connectionName);
            factory.ConfigureUserService(connectionName);
            //factory.ConfigureClientStoreCache();
            //factory.ConfigureScopeStoreCache();
            //factory.ConfigureUserServiceCache();

            app.Map("/core1", coreApp =>
            {
                var options = new IdentityServerOptions
                {
                    IssuerUri = "https://" + serverName + "/identityserver",
                    SiteName = "Identity Server Name",
                    SigningCertificate = Cert.Load(serverName),
                    Factory = factory,
                    CorsPolicy = CorsPolicy.AllowAll,
                    RequireSsl = true,
                    EnableWelcomePage = true,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        EnableLoginHint = true,
                        EnableSignOutPrompt = false,
                        EnableLocalLogin = false,
                        EnablePostSignOutAutoRedirect = true,
                        PostSignOutAutoRedirectDelay = 0,
                        RequireAuthenticatedUserForSignOutMessage = false,
                        RememberLastUsername = false,
                        SignInMessageThreshold = 3,
                        IdentityProviders = ConfigureAdditionalIdentityProviders1,
                        CookieOptions = new Thinktecture.IdentityServer.Core.Configuration.CookieOptions()
                        {
                            Prefix = "Core1",
                            SecureMode = CookieSecureMode.Always
                        }
                    },
                    LoggingOptions = new LoggingOptions
                    {
                        EnableHttpLogging = true,
                        EnableWebApiDiagnostics = true,
                        IncludeSensitiveDataInLogs = true,
                        WebApiDiagnosticsIsVerbose = false
                    },
                    EventsOptions = new EventsOptions
                    {
                        RaiseSuccessEvents = true,
                        RaiseErrorEvents = true,
                        RaiseFailureEvents = true,
                        RaiseInformationEvents = true
                    }
                };

                coreApp.UseIdentityServer(options);
            });

            app.Map("/core2", coreApp =>
            {
                var options = new IdentityServerOptions
                {
                    IssuerUri = "https://" + serverName + "/identityserver",
                    SiteName = "Identity Server Name",
                    SigningCertificate = Cert.Load(serverName),
                    Factory = factory,
                    CorsPolicy = CorsPolicy.AllowAll,
                    RequireSsl = true,
                    EnableWelcomePage = false,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        EnableLoginHint = true,
                        EnableSignOutPrompt = false,
                        EnableLocalLogin = false,
                        EnablePostSignOutAutoRedirect = true,
                        PostSignOutAutoRedirectDelay = 0,
                        RequireAuthenticatedUserForSignOutMessage = false,
                        RememberLastUsername = false,
                        SignInMessageThreshold = 3,
                        IdentityProviders = ConfigureAdditionalIdentityProviders2,
                        CookieOptions = new Thinktecture.IdentityServer.Core.Configuration.CookieOptions()
                        {
                            Prefix = "Core2",
                            SecureMode = CookieSecureMode.Always
                        }
                    },
                    LoggingOptions = new LoggingOptions
                    {
                        EnableHttpLogging = true,
                        EnableWebApiDiagnostics = true,
                        IncludeSensitiveDataInLogs = true
                    },
                    EventsOptions = new EventsOptions
                    {
                        RaiseSuccessEvents = true,
                        RaiseErrorEvents = true,
                        RaiseFailureEvents = true,
                        RaiseInformationEvents = true
                    }
                };
                coreApp.UseIdentityServer(options);
            });
        }