public IActionResult RenewTicket() { ServiceConfig.ReadTicket(); return(NoContent()); }
public void ConfigureServices(IServiceCollection services) { ServiceConfig serviceConfig = new ServiceConfig() { SecurityKey = Configuration["SecurityKey"], SessionName = Configuration["SessionName"], SMSUrl = Configuration["SMSUrl"], SMSApiKey = Configuration["SMSApiKey"], ConnectionString = Configuration.GetConnectionString("reservationData"), RegisterationTicket = ServiceConfig.ReadTicket(), NotificationPath = "notification.json", ServiceStatePath = "state.txt", ServiceReasonPath = "service_reason.json" }; services.AddSingleton <ServiceConfig>(serviceConfig); services.AddMvc(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(30); options.Cookie.Name = serviceConfig.SessionName; }); services.AddDbContext <ReservationDbContext>(options => options.UseSqlServer(serviceConfig.ConnectionString)); services.AddSingleton <NPOLJwtTokenService>(provider => { SymmetricSecurityKey key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(serviceConfig.SecurityKey)); TokenValidationParameters tokenParam = new TokenValidationParameters() { ValidateIssuerSigningKey = true, IssuerSigningKey = key, ValidateIssuer = false, ValidateAudience = false, ValidateLifetime = true, ClockSkew = TimeSpan.Zero }; TokenProviderOptions options = new TokenProviderOptions() { Audience = "MyServer", Issuer = "MyClient", SigningCredentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256), Expiration = TimeSpan.FromDays(1), ValidationParameters = tokenParam }; NPOLJwtTokenService serv = new NPOLJwtTokenService(Options.Create(options)); return(serv); }); services.AddSingleton <SMSService>(); services.AddDNTCaptcha(); string defaultLanguage = Configuration["Language:Default"]; IEnumerable <string> supportedLanguages = Configuration.GetSection("Language:Supported").AsEnumerable().Where(x => x.Value != null).Select(x => x.Value); services.AddSingleton <CultureOptions>(provider => new CultureOptions(defaultLanguage, supportedLanguages)); services.AddScoped <CultureContext>(); services.AddSingleton <LocalizedViewFindExecutor>(); services.AddSingleton <INotificationProvider, NotificationProvider>(service => new NotificationProvider(serviceConfig.NotificationPath)); services.AddSingleton <IServiceState, ServiceState>(service => new ServiceState(serviceConfig.ServiceStatePath)); services.AddSingleton <IServiceNotAvailableReasonProvider, ServiceNotAvailableReasonProvider>(service => new ServiceNotAvailableReasonProvider(serviceConfig.ServiceReasonPath)); }