From 2d1d7019cbe051d2a42350a6f9d50e1f4ed8bd11 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sun, 23 Jan 2022 18:42:59 +0100 Subject: feat: Remove stale tokens on a regular basis --- src/server/Startup.cs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/server/Startup.cs') diff --git a/src/server/Startup.cs b/src/server/Startup.cs index a1b6eb1..4b7c097 100644 --- a/src/server/Startup.cs +++ b/src/server/Startup.cs @@ -1,5 +1,3 @@ -using System.Reflection; - namespace IOL.BookmarkThing.Server; public class Startup @@ -21,6 +19,16 @@ public class Startup return $"Server={host};Port={port};Database={database};User Id={user};Password={password}"; } + public string QuartzDatabaseConnectionString() { + var host = Configuration.GetValue("QUARTZ_DB_HOST"); + var port = Configuration.GetValue("QUARTZ_DB_PORT"); + var database = Configuration.GetValue("QUARTZ_DB_NAME"); + var user = Configuration.GetValue("QUARTZ_DB_USER"); + var password = Configuration.GetValue("QUARTZ_DB_PASSWORD"); + return $"Server={host};Port={port};Database={database};User Id={user};Password={password}"; + } + + // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDataProtection() @@ -46,6 +54,19 @@ public class Startup } }); + services.AddQuartz(options => { + options.UsePersistentStore(o => { + o.UsePostgres(QuartzDatabaseConnectionString()); + o.UseSerializer(); + }); + options.UseMicrosoftDependencyInjectionJobFactory(); + options.RegisterJobs(); + }); + + services.AddQuartzHostedService(options => { + options.WaitForJobsToComplete = true; + }); + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.Cookie.Name = "bookmarkthing_session"; -- cgit v1.3