Startup.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.AspNetCore.Hosting;
  3. using Microsoft.AspNetCore.Http;
  4. using Microsoft.Extensions.DependencyInjection;
  5. namespace CasinosManager.IdentityServer
  6. {
  7. public class Startup
  8. {
  9. // This method gets called by the runtime. Use this method to add services to the container.
  10. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
  11. public void ConfigureServices(IServiceCollection services)
  12. {
  13. services.AddIdentityServer()
  14. .AddDeveloperSigningCredential()
  15. .AddInMemoryApiResources(Config.GetApiResources())
  16. .AddInMemoryClients(Config.GetClients())
  17. .AddResourceOwnerValidator<AccountValidator>();
  18. //.AddTestUsers(Config.GetUsers());
  19. services.AddCors(options =>
  20. {
  21. options.AddPolicy("angular", policy =>
  22. {
  23. policy.WithOrigins("http://localhost:3000")
  24. .AllowAnyHeader()
  25. .AllowAnyMethod()
  26. .AllowCredentials();
  27. });
  28. });
  29. }
  30. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  31. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  32. {
  33. if (env.IsDevelopment())
  34. {
  35. app.UseDeveloperExceptionPage();
  36. }
  37. app.UseIdentityServer();
  38. app.UseCors("angular");
  39. app.Run(async (context) =>
  40. {
  41. await context.Response.WriteAsync("CasinosManager.IdentityServer!");
  42. });
  43. }
  44. }
  45. }