You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Luticate2.Auth.Controllers;
  6. using Microsoft.AspNetCore.Builder;
  7. using Microsoft.AspNetCore.Hosting;
  8. using Microsoft.EntityFrameworkCore;
  9. using Microsoft.Extensions.Configuration;
  10. using Microsoft.Extensions.DependencyInjection;
  11. using Microsoft.Extensions.Logging;
  12. namespace WebApiAuth
  13. {
  14. public class Startup
  15. {
  16. public Startup(IHostingEnvironment env)
  17. {
  18. var builder = new ConfigurationBuilder()
  19. .SetBasePath(env.ContentRootPath)
  20. .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
  21. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
  22. if (env.IsEnvironment("Development"))
  23. {
  24. // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
  25. builder.AddApplicationInsightsSettings(developerMode: true);
  26. }
  27. builder.AddEnvironmentVariables();
  28. Configuration = builder.Build();
  29. }
  30. public IConfigurationRoot Configuration { get; }
  31. // This method gets called by the runtime. Use this method to add services to the container
  32. public void ConfigureServices(IServiceCollection services)
  33. {
  34. services.AddLuticateAuth(options => options.Version = "dev", options =>
  35. {
  36. options.UseNpgsql(Configuration.GetConnectionString("default"));
  37. }, options => options.SecureCookies = false);
  38. services.AddMvc()
  39. .AddLuticateAuth();
  40. }
  41. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
  42. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  43. {
  44. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  45. loggerFactory.AddDebug();
  46. app.UseLuticateAuth();
  47. app.UseMvc();
  48. }
  49. }
  50. }