// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var liteDatabase = new LiteDatabase("Filename=db/user.db;Connection=Shared"); LiteDbHelper.InitDb(liteDatabase); var applications = LiteDbHelper.Instance.GetCollection <ApplicationEntity>(nameof(ApplicationEntity)).Find(x => x.AuthorizationStatus && x.IsEnable); if (applications != null && applications.Any()) { foreach (var application in applications) { SchedulerUtil.AddScheduler(application.Id); } } services.AddLiteDBIdentity("Filename=db/user.db;Connection=Shared").AddDefaultTokenProviders(); services.AddDataProtection().PersistKeysToFileSystem(new System.IO.DirectoryInfo(@"/app")); // services.AddSingleton<LiteDbContext>(); // services.AddSingleton<ILiteDbContext, LiteDbContext>(x => new LiteDbContext(liteDatabase)); // // services.AddIdentity<ApplicationUser, AspNetCore.Identity.LiteDB.IdentityRole>(options => // { // options.Password.RequireDigit = false; // options.Password.RequireUppercase = false; // options.Password.RequireLowercase = false; // options.Password.RequireNonAlphanumeric = false; // options.Password.RequiredLength = 6; // }) // //.AddEntityFrameworkStores<ApplicationDbContext>() // .AddUserStore<LiteDbUserStore<ApplicationUser>>() // .AddRoleStore<LiteDbRoleStore<AspNetCore.Identity.LiteDB.IdentityRole>>() // .AddDefaultTokenProviders(); services.ConfigureApplicationCookie(options => { options.AccessDeniedPath = "/Account/AccessDenied"; options.Cookie.Name = "renewal"; options.LoginPath = "/User/Login"; options.LogoutPath = "/User/Logout"; options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter; options.SlidingExpiration = true; }); services.AddAuthentication(configureOptions => { }) .AddCookie(cookieOptions => { cookieOptions.LoginPath = new PathString("/Home/Login"); cookieOptions.LogoutPath = new PathString("/Home/Logout"); cookieOptions.AccessDeniedPath = new PathString("/Home/Error"); }) .AddMicrosoftAccount(microsoftOptions => { microsoftOptions.ClientId = Configuration["Authentication:Microsoft:ClientId"]; microsoftOptions.ClientSecret = Configuration["Authentication:Microsoft:ClientSecret"]; //microsoftOptions.CallbackPath = new PathString("/signin-microsoft"); }) .AddGitHub(builder => { builder.ClientId = Configuration["Authentication:Github:ClientId"]; builder.ClientSecret = Configuration["Authentication:Github:ClientSecret"]; builder.Scope.Add("user:email"); }); services.Configure <ForwardedHeadersOptions>(options => { options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; }); services.AddControllersWithViews(); }