예제 #1
0
        public static IServiceCollection AddIdentityApplication(
            this IServiceCollection services, IConfiguration configuration
            )
        {
            services.AddDocumentStore(configuration,
                                      new CollectionMapping(typeof(IdentityResource), "IdentityResources")
                                      );

            services.AddRavenDBIdentity(
                DocumentStoreHolder.Store,
                DocumentStoreHolder.DatabaseName
                );

            services.Configure <IdentityOptions>(options =>
            {
                // Password settings
                options.Password.RequireDigit           = false;
                options.Password.RequiredLength         = 6;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = false;
                options.Password.RequireLowercase       = false;
                options.Password.RequiredUniqueChars    = 1;
            });

            services.ConfigureApplicationCookie(options =>
            {
                // Cookie settings
                options.Cookie.HttpOnly   = true;
                options.Cookie.Expiration = TimeSpan.FromDays(150);
                options.LoginPath         = "/Accounts/Login";
                options.LogoutPath        = "/Accounts/Logout";
                options.AccessDeniedPath  = "/Accounts/AccessDenied";
                options.SlidingExpiration = true;
            });

            services
            .AddIdentityServer()
            .AddDeveloperSigningCredential()
            .AddRavenDBConfigurationStore(
                DocumentStoreHolder.Store,
                DocumentStoreHolder.DatabaseName,
                async(clientStore, resourceStore) => await BaseConfig.LoadSeed(
                    clientStore, resourceStore, configuration
                    )
                )
            .AddRavenDBOperationalStore(
                DocumentStoreHolder.Store,
                DocumentStoreHolder.DatabaseName
                )
            .AddAspNetIdentity <User>()
            .AddProfileService <ProfileService>();

            return(services);
        }