示例#1
0
        public void Configuration(IAppBuilder app)
        {
            var efConfig = new EntityFrameworkServiceOptions
            {
                ConnectionString = IdentityServerDb
            };

            var cleanup = new TokenCleanup(efConfig, 10);

            cleanup.Start();

            // Add in the Clients and Scopes to the EF database
            IdentityServerTestData.SetUp(efConfig);
            MembershipTestData.SetUp(MembershipDb, MembershipApplicationName);

            var factory = new IdentityServerServiceFactory();

            factory.RegisterOperationalServices(efConfig);

            factory.Register(new Registration <IClientConfigurationDbContext>(resolver => new ClientConfigurationDbContext(efConfig.ConnectionString)));
            factory.RegisterClientDataStore(new Registration <IClientDataStore>(resolver => new ClientDataStore(resolver.Resolve <IClientConfigurationDbContext>())));
            factory.CorsPolicyService = new ClientConfigurationCorsPolicyRegistration(efConfig);

            factory.Register(new Registration <IScopeConfigurationDbContext>(resolver => new ScopeConfigurationDbContext(efConfig.ConnectionString)));
            factory.RegisterScopeDataStore(new Registration <IScopeDataStore>(resolver => new ScopeDataStore(resolver.Resolve <IScopeConfigurationDbContext>())));

            factory.AddVaultClientSecretStore(
                new VaultClientSecretStoreAppIdOptions
            {
                AppId  = Program.IdentityServerAppId,
                UserId = Program.IdentityServerUserId
            });

            factory.UseMembershipService(
                new MembershipOptions
            {
                ConnectionString = ConfigurationManager.ConnectionStrings["Membership"].ConnectionString,
                ApplicationName  = MembershipApplicationName
            });

            var options = new IdentityServerOptions
            {
                Factory    = factory,
                RequireSsl = false
            };

            // Wire up Vault as being the X509 Certificate Signing Store
            options.AddVaultCertificateStore(new VaultCertificateStoreAppIdOptions
            {
                AppId  = Program.IdentityServerAppId,
                UserId = Program.IdentityServerUserId,

                RoleName   = RoleName,
                CommonName = CommonName
            });

            app.UseIdentityServer(options);
        }
 public static void AddVaultAppRoleCertificateStore(this IdentityServerOptions options, VaultCertificateStoreAppRoleOptions vaultOptions)
 {
     options.AddVaultCertificateStore(vaultOptions, new VaultAppRoleAuth(vaultOptions.RoleId, vaultOptions.SecretId));
 }
 public static void AddVaultCertificateStore(this IdentityServerOptions options, VaultCertificateStoreAppIdOptions vaultOptions)
 {
     options.AddVaultCertificateStore(vaultOptions, new VaultAppIdAuth(vaultOptions.AppId, vaultOptions.UserId));
 }