コード例 #1
0
        public static IdentityServerServiceFactory Configure(this IdentityServerServiceFactory factory,
                                                             string connectionString)
        {
            var serviceOptions = new EntityFrameworkServiceOptions {
                ConnectionString = connectionString, Schema = "AuthServer".ToUpper()
            };

            SetupScopes(InMemoryManager.GetScopes(), serviceOptions);
            SetupUsers(InMemoryManager.GetUsers(), serviceOptions);
            SetupClients(InMemoryManager.GetClients(), serviceOptions);
            factory.RegisterOperationalServices(serviceOptions);
            factory.RegisterConfigurationServices(serviceOptions);
            //factory.Register(new Registration<OperationsDbContext>(resolver=>new OperationsDbContext(serviceOptions.ConnectionString,serviceOptions.Schema)));
            factory.Register(new Registration <Context>(resolver => new Context(connectionString)));
            factory.Register(new Registration <UserStore>());
            factory.Register(new Registration <UserManager>());
            new TokenCleanup(serviceOptions, 1).Start();
            var context = new Context(serviceOptions.ConnectionString);

            var userService =
                new AspNetIdentityUserService <IdentityUser, string>(new UserManager(new UserStore(context)));

            factory.UserService = new Registration <IUserService>(userService);
            return(factory);
        }
コード例 #2
0
        public void Configuration(IAppBuilder app)
        {
            var factory = new IdentityServerServiceFactory()
                          .UseInMemoryUsers(InMemoryManager.GetUsers())
                          .UseInMemoryScopes(InMemoryManager.GetScopes())
                          .UseInMemoryClients(InMemoryManager.GetClients());

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

            app.UseIdentityServer(options);
        }
コード例 #3
0
        public void Configuration(IAppBuilder app)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Verbose()
                         .WriteTo.RollingFile("C:\\logs\\oauth.log", retainedFileCountLimit: 7,
                                              outputTemplate: "{Timestamp} [{Level}] {Message}{NewLine}{Exception}")
                         .CreateLogger();

            var inMemoryManager = new InMemoryManager();

            var users = inMemoryManager.GetUsers();

            var factory = new IdentityServerServiceFactory()
                          .UseInMemoryUsers(inMemoryManager.GetUsers())
                          .UseInMemoryClients(inMemoryManager.GetClients())
                          .UseInMemoryScopes(inMemoryManager.GetScopes());

            factory.SecretValidators.Clear();
            factory.SecretValidators.Add(new Registration <ISecretValidator>(resolver => new SecretValidator()));

            factory.SecretParsers.Clear();
            factory.SecretParsers.Add(new Registration <ISecretParser>(resolver => new SecretParser()));

            factory.CustomTokenResponseGenerator = new Registration <ICustomTokenResponseGenerator, SofTokenResponseGenerator>();

            /*var viewOptions = new DefaultViewServiceOptions();
             * viewOptions.Stylesheets.Add("TBD...");
             * factory.ConfigureDefaultViewService(viewOptions);*/

            var options = new IdentityServerOptions
            {
                SiteName           = "NextGen Healthcare",
                SigningCertificate = Certificate.Load(),
                Factory            = factory,
                RequireSsl         = false,
                LoggingOptions     = new LoggingOptions
                {
                    EnableHttpLogging          = true,
                    EnableKatanaLogging        = true,
                    EnableWebApiDiagnostics    = true,
                    WebApiDiagnosticsIsVerbose = true
                }
            };

            app.Map("", idsrvApp => { idsrvApp.UseIdentityServer(options); });
        }