Exemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            var options = new IdentityServerOptions
            {
                Factory = new IdentityServerServiceFactory()
                {
                    CustomRequestValidator = new Registration <ICustomRequestValidator>(new TestRequestValidator()),
                    ClaimsProvider         = new Registration <IClaimsProvider, TestClaimProvider>(),
                }
                .UseInMemoryClients(Clients.Get())
                .UseInMemoryScopes(Scopes.Get())
                .UseInMemoryUsers(Users.Get()),

                RequireSsl = false
            };

            app.UseIdentityServer(options);
        }
Exemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
            var builder = new ContainerBuilder();

            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            var container = builder.Build();

            JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary <string, string>();

            var factory = InMemoryFactory.Create(
                users: Users.Get(),
                clients: Clients.Get(),
                scopes: Scopes.Get());

            var options = new IdentityServerOptions
            {
                Factory = factory
            };

            app.UseIdentityServer(options);

            app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
            {
                Authority      = "https://localhost:44333",
                RequiredScopes = new[] { "api1" }
            });

            var config = new HttpConfiguration();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);

            app.UseAutofacMiddleware(container);
            app.UseAutofacWebApi(config);
            app.UseWebApi(config);
        }
Exemplo n.º 3
0
        public void Configuration(IAppBuilder app)
        {
            var options = new IdentityServerOptions
            {
                Factory = new IdentityServerServiceFactory()
                          .UseInMemoryClients(Clients.Get())
                          .UseInMemoryScopes(Scopes.Get())
                          .UseInMemoryUsers(Users.Get()),

                LoggingOptions = new LoggingOptions {
                    EnableHttpLogging = true, EnableKatanaLogging = true, EnableWebApiDiagnostics = true
                },
                EventsOptions = new EventsOptions {
                    RaiseErrorEvents = true, RaiseFailureEvents = true, RaiseInformationEvents = true, RaiseSuccessEvents = true
                },

                RequireSsl = false
            };

            app.UseIdentityServer(options);
        }
        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);
        }