Ejemplo n.º 1
0
        public void Configuration(IAppBuilder appBuilder)
        {
            LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());

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

            var options = new IdentityServerOptions
            {
                IssuerUri = "https://idsrv3.com",
                SiteName  = "Thinktecture IdentityServer3 (self host)",

                SigningCertificate = Certificate.Get(),
                Factory            = factory,
            };

            appBuilder.UseIdentityServer(options);
        }
Ejemplo n.º 2
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var factory = new IdentityServerServiceFactory()
                          .UseInMemoryUsers(Users.Get())
                          .UseInMemoryScopes(Scopes.Get())
                          .UseInMemoryClients(Clients.Get());

            factory.CustomGrantValidators.Add(
                new Registration <ICustomGrantValidator>(typeof(CustomGrantValidator)));

            var options = new IdentityServerOptions
            {
                SiteName = "IdentityServer3 (CustomGrants)",

                SigningCertificate = Certificate.Get(),
                Factory            = factory,
            };

            appBuilder.UseIdentityServer(options);
        }
Ejemplo n.º 3
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var factory = new IdentityServerServiceFactory()
                          .UseInMemoryClients(Clients.Get())
                          .UseInMemoryScopes(Scopes.Get())
                          .UseInMemoryUsers(Users.Get());

            factory.ClaimsProvider =
                new Registration <IClaimsProvider, CustomClaimsProvider>();

            var options = new IdentityServerOptions
            {
                SiteName = "IdentityServer3 (self host)",

                SigningCertificate = Certificate.Get(),
                Factory            = factory,
            };

            appBuilder.UseIdentityServer(options);
        }
Ejemplo n.º 4
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/identity", idsrvApp =>
            {
                idsrvApp.UseIdentityServer(new IdentityServerOptions
                {
                    SiteName  = "Embedded IdentityServer",
                    IssuerUri = ExpenseTrackerConstants.IdSrvIssuerUri,

                    Factory = new IdentityServerServiceFactory()
                              .UseInMemoryUsers(Users.Get())
                              .UseInMemoryClients(Clients.Get())
                              .UseInMemoryScopes(Scopes.Get()),

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

            //ConfigureAuth(app);
        }
Ejemplo n.º 5
0
        public void Configuration(IAppBuilder app)
        {
            var factory = new IdentityServerServiceFactory()
               .UseInMemoryScopes(Scopes.Get())
               .UseInMemoryClients(Clients.Get())
               .UseInMemoryUsers(Users.Get());

            var options = new IdentityServerOptions
            {
                RequireSsl = false,
                Factory = factory,
                SigningCertificate = Certificate.Load()
            };

            //setting up the Owin for the Identity Server
            app.Map("/auth", idsrvapp =>
            {
                idsrvapp.UseIdentityServer(options);
            });
        }
Ejemplo n.º 6
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var factory = new IdentityServerServiceFactory();

            factory
            .UseInMemoryClients(Clients.Get())
            .UseInMemoryScopes(Scopes.Get())
            .UseInMemoryUsers(Users.Get());

            var options = new IdentityServerOptions
            {
                SiteName = "Third Party Identity Server",

                SigningCertificate    = Certificate.Get(),
                Factory               = factory,
                AuthenticationOptions = { EnableLocalLogin = true },
            };

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

                var options = new IdentityServerOptions()
                {
                    Factory            = idServerServiceFactory,
                    SiteName           = "DoorTracker Securirity Tracker Service (DTSTS)",
                    IssuerUri          = Constants.Constants.DoorTrackerIssuerUri,
                    PublicOrigin       = Constants.Constants.DoorTrackerSTSOrigin,
                    SigningCertificate = LoadCertificate()
                };
                idsrvApp.UseIdentityServer(options);
            });
        }
Ejemplo n.º 8
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var factory = InMemoryFactory.Create(
                users:   Users.Get(),
                clients: Clients.Get(),
                scopes:  Scopes.Get());

            factory.CustomGrantValidator = Registration.RegisterType <ICustomGrantValidator>(typeof(CustomGrantValidator));

            var options = new IdentityServerOptions
            {
                IssuerUri = "https://idsrv3.com",
                SiteName  = "Thinktecture IdentityServer v3 - beta 2 (SelfHost)",

                SigningCertificate = Certificate.Get(),
                Factory            = factory,
            };

            appBuilder.UseIdentityServer(options);
        }
 public void Configuration(IAppBuilder app)
 {
     app.Map(
         "/core",
         coreApp =>
     {
         coreApp.UseIdentityServer(
             new IdentityServerOptions
         {
             SiteName           = "Standalone Identity Server",
             SigningCertificate = Cert.Load(),
             Factory            =
                 new IdentityServerServiceFactory().UseInMemoryClients(Clients.Get())
                 .UseInMemoryScopes(Scopes.Get())
                 .UseInMemoryUsers(Users.Get()),
             RequireSsl          = true,
             PluginConfiguration = ConfigureWsFederation
         });
     });
 }
Ejemplo n.º 10
0
        private static void EnsureSeedData(ConfigurationDbContext context)
        {
            if (!context.Clients.Any())
            {
                foreach (var client in Clients.Get())
                {
                    context.Clients.Add(client.ToEntity());
                }
                context.SaveChanges();
            }

            if (!context.Scopes.Any())
            {
                foreach (var client in Scopes.Get())
                {
                    context.Scopes.Add(client.ToEntity());
                }
                context.SaveChanges();
            }
        }
Ejemplo n.º 11
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/identity", idApp =>
            {
                idApp.UseIdentityServer(new IdentityServerOptions
                {
                    SiteName  = "Solution Template Embedded Identity Server",
                    IssuerUri = "https://solutiontemplateidsrv3/embedded",

                    Factory = new IdentityServerServiceFactory()
                              .UseInMemoryUsers(Users.Get())
                              .UseInMemoryClients(Clients.Get())
                              .UseInMemoryScopes(Scopes.Get()),

                    SigningCertificate = new X509Certificate2(
                        string.Format(@"{0}\bin\Certificates\idsrv3test.pfx",
                                      AppDomain.CurrentDomain.BaseDirectory), "idsrv3test")
                });
            });
        }
        public void Configuration(IAppBuilder appBuilder)
        {
            var factory = InMemoryFactory.Create(
                users:   Users.Get(),
                clients: Clients.Get(),
                scopes:  Scopes.Get());

            var options = new IdentityServerOptions
            {
                IssuerUri      = "https://idsrv3.com",
                SiteName       = "Thinktecture IdentityServer v3 - beta 1-1 (SelfHost)",
                PublicHostName = "http://localhost:3333",

                SigningCertificate  = Certificate.Get(),
                Factory             = factory,
                PluginConfiguration = ConfigurePlugins
            };

            appBuilder.UseIdentityServer(options);
        }
Ejemplo n.º 13
0
        public void ConfigureServices(IServiceCollection services)
        {
            var cert = new X509Certificate2(Path.Combine(ApplicationBasePath, "server.pfx"), "");

            var builder = services.AddIdentityServer(options =>
            {
                options.SigningCertificate = cert;
                options.RequireSsl         = false;
            });

            builder.AddInMemoryClients(Clients.Get());
            builder.AddInMemoryScopes(Scopes.Get());
            //builder.AddInMemoryUsers(Users.Get());

            // AspNet Identity (instead in memory users)
            services.AddEntityFramework()
            .AddSqlServer()
            .AddDbContext <IdentityDbContext>(options => {
                options.UseSqlServer(Configuration["Data:Development:IdentityConnectionString"]);
            });

            services.AddIdentity <AppUser, AppRole>(options => {
                options.Password.RequireDigit   = true;
                options.Password.RequiredLength = 6;
            })
            .AddEntityFrameworkStores <IdentityDbContext>()
            .AddUserManager <IdentityUserManager>()
            .AddRoleManager <IdentityRoleManager>();

            // IdentityServer Service Hooks to Use Identity Server
            services.AddTransient <IResourceOwnerPasswordValidator, IdentityPasswordValidator>();
            services.AddTransient <IProfileService, IdentityProfileService>();

            // Identity Server UI
            services
            .AddMvc()
            .AddRazorOptions(razor =>
            {
                razor.ViewLocationExpanders.Add(new CustomViewLocationExpander());
            });
        }
Ejemplo n.º 14
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();

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

                var idsrvOptions = new IdentityServerOptions
                {
                    IssuerUri          = "https://idsrv3.com",
                    SiteName           = "Thinktecture IdentityServer v3 - beta 3",
                    Factory            = factory,
                    SigningCertificate = Cert.Load(),

                    CorsPolicy = CorsPolicy.AllowAll,
                    CspOptions = new CspOptions
                    {
                        ReportEndpoint = EndpointSettings.Enabled,
                    },

                    AuthenticationOptions = new AuthenticationOptions
                    {
                        IdentityProviders = ConfigureIdentityProviders,
                    }
                };

                coreApp.UseIdentityServer(idsrvOptions);
            });

            // only for showing the getting started index page
            app.UseStaticFiles();
        }
Ejemplo n.º 15
0
        public void Configure(IApplicationBuilder app)
        {
            app.Map("/core", core =>
            {
                var factory = InMemoryFactory.Create(
                    users: Users.Get(),
                    clients: Clients.Get(),
                    scopes: Scopes.Get());

                var idsrvOptions = new IdentityServerOptions
                {
                    IssuerUri          = "https://idsrv3.com",
                    SiteName           = "test vnext Identity server",
                    Factory            = factory,
                    SigningCertificate = Certificate.Get(),
                    RequireSsl         = false,

                    CorsPolicy = CorsPolicy.AllowAll,

                    AuthenticationOptions = new AuthenticationOptions
                    {
                    }
                };

                core.UseIdentityServer(idsrvOptions);
            });

            app.Map("/api", api =>
            {
                api.UseOAuthBearerAuthentication(options => {
                    options.Authority = Constants.AuthorizationUrl;
                    // didn't try yet if options.MetadataAddress is necessary...
                    options.MetadataAddress = Constants.AuthorizationUrl + "/.well-known/openid-configuration";
                    options.TokenValidationParameters.ValidAudience = "https://idsrv3.com/resources";
                });


                // for web api
                api.UseMvc();
            });
        }
Ejemplo n.º 16
0
        public void Configuration(IAppBuilder app)
        {
            //config identityServer
            app.Map("/identity", idsrvApp =>
            {
                idsrvApp.UseIdentityServer(new IdentityServerOptions
                {
                    SiteName           = "Embedded IdentityServer",
                    IssuerUri          = ExpenseTrackerConstants.IdSrvIssuerUri,
                    SigningCertificate = LoadCertificate(),

                    //Factory = InMemoryFactory.Create(
                    //                        users: Users.Get(),
                    //                        clients: Clients.Get(),
                    //                        scopes: Scopes.Get())
                    Factory = new IdentityServerServiceFactory()
                              .UseInMemoryClients(Clients.Get())
                              .UseInMemoryScopes(Scopes.Get())
                              .UseInMemoryUsers(Users.Get())
                });

                /*
                 * var idServerServiceFactory = new IdentityServerServiceFactory()
                 *             .UseInMemoryClients(Clients.Get())
                 *             .UseInMemoryScopes(Scopes.Get())
                 *             .UseInMemoryUsers(Users.Get());
                 *
                 * var options = new IdentityServerOptions
                 * {
                 *
                 *  SiteName = "Embedded IdentityServer",
                 *  IssuerUri = ExpenseTrackerConstants.IdSrvIssuerUri,
                 *  // PublicOrigin = TripGallery.Constants.TripGallerySTSOrigin,
                 *  SigningCertificate = LoadCertificate(),
                 *  Factory = idServerServiceFactory
                 *
                 * };
                 * idsrvApp.UseIdentityServer(options);
                 */
            });
        }
        public void Configuration(IAppBuilder app)
        {
            app.Map("/core", coreApp =>
            {
                var factory = new IdentityServerServiceFactory()
                              .UseInMemoryUsers(Users.Get())
                              .UseInMemoryClients(Clients.Get())
                              .UseInMemoryScopes(Scopes.Get());

                var options = new IdentityServerOptions
                {
                    SiteName = "IdentityServer3 with SiteFinity",

                    SigningCertificate  = Certificate.Get(),
                    Factory             = factory,
                    PluginConfiguration = ConfigurePlugins,
                };

                coreApp.UseIdentityServer(options);
            });
        }
Ejemplo n.º 18
0
        public void Configure(IApplicationBuilder app, IApplicationEnvironment env)
        {
            var certFile = env.ApplicationBasePath + "\\idsrv3test.pfx";

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

                var idsrvOptions = new IdentityServerOptions
                {
                    Factory            = factory,
                    RequireSsl         = false,
                    SigningCertificate = new X509Certificate2(certFile, "idsrv3test")
                };

                core.UseIdentityServer(idsrvOptions);
            });
        }
Ejemplo n.º 19
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var factory = InMemoryFactory.Create(
                users:  Users.Get(),
                clients: Clients.Get(),
                scopes:  Scopes.Get());

            factory.ClaimsProvider = new Registration <IClaimsProvider>(typeof(MyCustomClaimsProvider));
            factory.Register(new Registration <ICustomLogger>(typeof(MyCustomDebugLogger)));

            var options = new IdentityServerOptions
            {
                IssuerUri = "https://idsrv3.com",
                SiteName  = "Thinktecture IdentityServer3 - DependencyInjection",

                SigningCertificate = Certificate.Get(),
                Factory            = factory,
            };

            appBuilder.UseIdentityServer(options);
        }
Ejemplo n.º 20
0
        public void Configuration(IAppBuilder app)
        {
            var factory = new IdentityServerServiceFactory()
                          .UseInMemoryClients(Clients.Get())
                          .UseInMemoryScopes(Scopes.Get());

            factory.UserService = new Registration <IUserService>(typeof(ExternalRegistrationUserService));

            app.UseIdentityServer(new IdentityServerOptions
            {
                SiteName              = "Embedded IdentityServer",
                SigningCertificate    = Certificate.Load(),
                Factory               = factory,
                RequireSsl            = false,
                AuthenticationOptions = new AuthenticationOptions
                {
                    EnableLocalLogin  = false,
                    IdentityProviders = ConfigureIdentityProviders
                }
            });
        }
Ejemplo n.º 21
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/identity", idsrvApp =>
            {
                var idServerServiceFactory = new IdentityServerServiceFactory()
                                             .UseInMemoryClients(Clients.Get())
                                             .UseInMemoryScopes(Scopes.Get())
                                             .UseInMemoryUsers(Users.Get());

                var options = new IdentityServerOptions
                {
                    Factory            = idServerServiceFactory,
                    SiteName           = "TripCompany Security Token Service",
                    IssuerUri          = TripGallery.Constants.TripGalleryIssuerUri,
                    PublicOrigin       = TripGallery.Constants.TripGallerySTSOrigin,
                    SigningCertificate = LoadCertificate()
                };

                idsrvApp.UseIdentityServer(options);
            });
        }
        public void Configuration(IAppBuilder appBuilder)
        {
            var factory = InMemoryFactory.Create(
                users:   Users.Get(),
                clients: Clients.Get(),
                scopes:  Scopes.Get());

            var options = new IdentityServerOptions
            {
                IssuerUri  = "https://idsrv3.com",
                SiteName   = "Thinktecture IdentityServer v3 - beta 2 (SelfHost)",
                RequireSsl = false,

                SigningCertificate            = Certificate.Get(),
                Factory                       = factory,
                PluginConfiguration           = ConfigurePlugins,
                AccessTokenValidationEndpoint = EndpointSettings.Enabled
            };

            appBuilder.UseIdentityServer(options);
        }
Ejemplo n.º 23
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/identity", idsrvApp =>
            {
                var corsPolicyService = new DefaultCorsPolicyService {
                    AllowAll = true
                };

                var idServerServiceFactory = new IdentityServerServiceFactory
                {
                    CorsPolicyService = new Registration <ICorsPolicyService>(corsPolicyService)
                }
                .UseInMemoryClients(Clients.Get())
                .UseInMemoryScopes(Scopes.Get())
                .UseInMemoryUsers(Users.Get());

                idServerServiceFactory.ConfigureDefaultViewService(
                    new DefaultViewServiceOptions {
                    CacheViews = false
                });

                idsrvApp.UseIdentityServer(new IdentityServerOptions
                {
                    SiteName              = "WsFederationDemo",
                    SigningCertificate    = LoadCertificate(),
                    RequireSsl            = false,
                    Factory               = idServerServiceFactory,
                    AuthenticationOptions = new AuthenticationOptions
                    {
                        RememberLastUsername = true,
                        IdentityProviders    = ConfigureAdditionalIdProviders
                    },
                    EnableWelcomePage = false,
                    CspOptions        = new CspOptions
                    {
                        Enabled = false
                    }
                });
            });
        }
Ejemplo n.º 24
0
        public void Configuration(IAppBuilder appBuilder)
        {
            LogProvider.SetCurrentLogProvider(new ColouredConsoleLogProvider());

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

            var options = new IdentityServerOptions
            {
                IssuerUri = "https://idsrv3.com",
                SiteName  = "Thinktecture IdentityServer3 (self host)",

                SigningCertificate = Certificate.Get(),
                Factory            = factory,
                CorsPolicy         = CorsPolicy.AllowAll,
                RequireSsl         = false
            };

            appBuilder.UseIdentityServer(options);
        }
Ejemplo n.º 25
0
        public void Configuration(IAppBuilder app)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Trace()
                         .CreateLogger();

            app.Map("/core", coreApp =>
            {
                var factory = new IdentityServerServiceFactory()
                              .UseInMemoryClients(Clients.Get())
                              .UseInMemoryScopes(Scopes.Get());

                factory.UserService = new Registration <IUserService, HrdUserService>();

                var options = new IdentityServerOptions
                {
                    SiteName = "IdentityServer3 - Custom HRD",

                    SigningCertificate = Certificate.Get(),
                    Factory            = factory,

                    AuthenticationOptions = new AuthenticationOptions
                    {
                        IdentityProviders = ConfigureAdditionalIdentityProviders,
                    },

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

                coreApp.UseIdentityServer(options);
            });
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders()
            .AddIdentityServerUserClaimsPrincipalFactory();

            services.AddMvc();

            // Add application services.
            services.AddTransient <IEmailSender, AuthMessageSender>();
            services.AddTransient <ISmsSender, AuthMessageSender>();

            services.AddDeveloperIdentityServer()
            .AddInMemoryScopes(Scopes.Get())
            .AddInMemoryClients(Clients.Get())
            .AddAspNetIdentity <ApplicationUser>();
        }
Ejemplo n.º 27
0
        public void Configuration(IAppBuilder app)
        {
            app.Map("/identity", idsrvApp =>
            {
                var idServerServiceFactory = new IdentityServerServiceFactory()
                                             .UseInMemoryClients(Clients.Get())
                                             .UseInMemoryUsers(Users.Get())
                                             .UseInMemoryScopes(Scopes.Get());

                var options = new IdentityServerOptions
                {
                    Factory            = idServerServiceFactory,
                    SiteName           = "Xamarin Sample STS",
                    IssuerUri          = "https://xamarinsamplests/identity",
                    PublicOrigin       = "https://xamarinoidcsamplests.azurewebsites.net/",
                    SigningCertificate = LoadCertificate(),
                    RequireSsl         = true
                };

                idsrvApp.UseIdentityServer(options);
            });
        }
Ejemplo n.º 28
0
        public void Configuration(IAppBuilder app)
        {
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Trace(outputTemplate: "{Timestamp} [{Level}] ({Name}){NewLine} {Message}{NewLine}{Exception}")
                         .CreateLogger();

            var factory = new IdentityServerServiceFactory()
                          .UseInMemoryUsers(Users.Get())
                          .UseInMemoryClients(Clients.Get())
                          .UseInMemoryScopes(Scopes.Get());

            var options = new IdentityServerOptions
            {
                SigningCertificate = Certificate.Load(),
                Factory            = factory,
            };

            app.Map("/core", idsrvApp =>
            {
                idsrvApp.UseIdentityServer(options);
            });
        }
Ejemplo n.º 29
0
        public void ConfigureServices(IServiceCollection services)
        {
            var cert = new X509Certificate2(Path.Combine(_environment.ApplicationBasePath, "idsrv4test.pfx"), "idsrv3test");

            var builder = services.AddIdentityServer(options =>
            {
                options.SigningCertificate = cert;
            });

            builder.AddInMemoryClients(Clients.Get());
            builder.AddInMemoryScopes(Scopes.Get());
            builder.AddInMemoryUsers(Users.Get());

            // for the UI
            services
            .AddMvc()
            .AddRazorOptions(razor =>
            {
                razor.ViewLocationExpanders.Add(new IdSvrHost.UI.CustomViewLocationExpander());
            });
            services.AddTransient <IdSvrHost.UI.Login.LoginService>();
        }
        public IdentityServerOptions GetOptions()
        {
            var factory = new IdentityServerServiceFactory()
                          .UseInMemoryClients(Clients.Get())
                          .UseInMemoryScopes(Scopes.Get());

            var userService = new EulaAtLoginUserService();

            // note: for the sample this registration is a singletone (not what you want in production probably)
            factory.UserService = new Registration <IUserService>(resolver => userService);

            var options = new IdentityServerOptions
            {
                SiteName = "IdentityServer3 - CustomUserService",

                SigningCertificate = Certificate.Get(),
                Factory            = factory,

                AuthenticationOptions = new AuthenticationOptions
                {
                    LoginPageLinks = new LoginPageLink[] {
                        new LoginPageLink {
                            Text = "Register",
                            Href = "localregistration"
                        }
                    }
                },

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

            return(options);
        }