forked from MDCPS/DamageAssessment_Backend
		
	Updated CORS statements Policy
This commit is contained in:
		| @ -9,6 +9,10 @@ using System.Reflection; | |||||||
| using System.Text; | using System.Text; | ||||||
|  |  | ||||||
| var builder = WebApplication.CreateBuilder(args); | var builder = WebApplication.CreateBuilder(args); | ||||||
|  | builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { | ||||||
|  |     build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); | ||||||
|  | })); | ||||||
|  |  | ||||||
| var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | ||||||
| builder.Services.AddAuthentication(item => | builder.Services.AddAuthentication(item => | ||||||
| { | { | ||||||
| @ -85,6 +89,7 @@ if (app.Environment.IsDevelopment()) | |||||||
|     app.UseSwagger(); |     app.UseSwagger(); | ||||||
|     app.UseSwaggerUI(); |     app.UseSwaggerUI(); | ||||||
| } | } | ||||||
|  | app.UseCors("DamageAppCorsPolicy"); | ||||||
| app.UseAuthentication(); | app.UseAuthentication(); | ||||||
| app.UseAuthorization(); | app.UseAuthorization(); | ||||||
|  |  | ||||||
|  | |||||||
| @ -11,7 +11,11 @@ using System.Reflection; | |||||||
| using System.Text; | using System.Text; | ||||||
|  |  | ||||||
| var builder = WebApplication.CreateBuilder(args); | var builder = WebApplication.CreateBuilder(args); | ||||||
|  | builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { | ||||||
|  |     build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); | ||||||
|  | })); | ||||||
| var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | ||||||
|  |  | ||||||
| builder.Services.AddAuthentication(item => | builder.Services.AddAuthentication(item => | ||||||
| { | { | ||||||
|     item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; |     item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; | ||||||
| @ -94,7 +98,7 @@ if (app.Environment.IsDevelopment()) | |||||||
|     app.UseSwagger(); |     app.UseSwagger(); | ||||||
|     app.UseSwaggerUI(); |     app.UseSwaggerUI(); | ||||||
| } | } | ||||||
|  | app.UseCors("DamageAppCorsPolicy"); | ||||||
| app.UseAuthentication(); | app.UseAuthentication(); | ||||||
| app.UseAuthorization(); | app.UseAuthorization(); | ||||||
| app.UseHttpsRedirection(); | app.UseHttpsRedirection(); | ||||||
|  | |||||||
| @ -9,9 +9,12 @@ using System.Text; | |||||||
| using Microsoft.OpenApi.Models; | using Microsoft.OpenApi.Models; | ||||||
|  |  | ||||||
| var builder = WebApplication.CreateBuilder(args); | var builder = WebApplication.CreateBuilder(args); | ||||||
|  | builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { | ||||||
|  |     build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); | ||||||
|  | })); | ||||||
| // Add services to the container. | // Add services to the container. | ||||||
| var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | ||||||
|  |  | ||||||
| builder.Services.AddAuthentication(item => | builder.Services.AddAuthentication(item => | ||||||
| { | { | ||||||
|     item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; |     item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; | ||||||
| @ -85,7 +88,7 @@ if (app.Environment.IsDevelopment()) | |||||||
|     app.UseSwagger(); |     app.UseSwagger(); | ||||||
|     app.UseSwaggerUI(); |     app.UseSwaggerUI(); | ||||||
| } | } | ||||||
|  | app.UseCors("DamageAppCorsPolicy"); | ||||||
| app.UseAuthentication(); | app.UseAuthentication(); | ||||||
| app.UseAuthorization(); | app.UseAuthorization(); | ||||||
|  |  | ||||||
|  | |||||||
| @ -9,9 +9,12 @@ using System.Reflection; | |||||||
| using System.Text; | using System.Text; | ||||||
|  |  | ||||||
| var builder = WebApplication.CreateBuilder(args); | var builder = WebApplication.CreateBuilder(args); | ||||||
|  | builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { | ||||||
|  |     build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); | ||||||
|  | })); | ||||||
| // Add services to the container. | // Add services to the container. | ||||||
| var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | ||||||
|  |  | ||||||
| builder.Services.AddAuthentication(item => | builder.Services.AddAuthentication(item => | ||||||
| { | { | ||||||
|     item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; |     item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; | ||||||
| @ -93,7 +96,7 @@ if (app.Environment.IsDevelopment()) | |||||||
|         employeesProvider.SeedData(); |         employeesProvider.SeedData(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | app.UseCors("DamageAppCorsPolicy"); | ||||||
| app.UseAuthentication(); | app.UseAuthentication(); | ||||||
| app.UseAuthorization(); | app.UseAuthorization(); | ||||||
|  |  | ||||||
|  | |||||||
| @ -9,9 +9,12 @@ using System.Reflection; | |||||||
| using System.Text; | using System.Text; | ||||||
|  |  | ||||||
| var builder = WebApplication.CreateBuilder(args); | var builder = WebApplication.CreateBuilder(args); | ||||||
|  | builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { | ||||||
|  |     build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); | ||||||
|  | })); | ||||||
| // Add services to the container. | // Add services to the container. | ||||||
| var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | ||||||
|  |  | ||||||
| builder.Services.AddAuthentication(item => | builder.Services.AddAuthentication(item => | ||||||
| { | { | ||||||
|     item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; |     item.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; | ||||||
| @ -96,7 +99,7 @@ if (app.Environment.IsDevelopment()) | |||||||
|         regionProvider.SeedData(); |         regionProvider.SeedData(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | app.UseCors("DamageAppCorsPolicy"); | ||||||
| app.UseAuthentication(); | app.UseAuthentication(); | ||||||
| app.UseAuthorization(); | app.UseAuthorization(); | ||||||
|  |  | ||||||
|  | |||||||
| @ -9,6 +9,9 @@ using System.Reflection; | |||||||
| using System.Text; | using System.Text; | ||||||
|  |  | ||||||
| var builder = WebApplication.CreateBuilder(args); | var builder = WebApplication.CreateBuilder(args); | ||||||
|  | builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { | ||||||
|  |     build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); | ||||||
|  | })); | ||||||
| // Add services to the container. | // Add services to the container. | ||||||
| var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | ||||||
| builder.Services.AddAuthentication(item => | builder.Services.AddAuthentication(item => | ||||||
| @ -93,6 +96,7 @@ if (app.Environment.IsDevelopment()) | |||||||
|         questionProvider.SeedData(); |         questionProvider.SeedData(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | app.UseCors("DamageAppCorsPolicy"); | ||||||
| app.UseAuthentication(); | app.UseAuthentication(); | ||||||
| app.UseAuthorization(); | app.UseAuthorization(); | ||||||
|  |  | ||||||
|  | |||||||
| @ -16,6 +16,9 @@ const int intervalToRetry = 2; //2 seconds | |||||||
| const int maxRetryForCircuitBraker = 5; | const int maxRetryForCircuitBraker = 5; | ||||||
| const int intervalForCircuitBraker = 5; //5 seconds | const int intervalForCircuitBraker = 5; //5 seconds | ||||||
|  |  | ||||||
|  | builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { | ||||||
|  |     build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); | ||||||
|  | })); | ||||||
|  |  | ||||||
| // Add services to the container. | // Add services to the container. | ||||||
| var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | ||||||
| @ -106,7 +109,7 @@ if (app.Environment.IsDevelopment()) | |||||||
|     app.UseSwagger(); |     app.UseSwagger(); | ||||||
|     app.UseSwaggerUI(); |     app.UseSwaggerUI(); | ||||||
| } | } | ||||||
|  | app.UseCors("DamageAppCorsPolicy"); | ||||||
| app.UseAuthentication(); | app.UseAuthentication(); | ||||||
| app.UseAuthorization(); | app.UseAuthorization(); | ||||||
|  |  | ||||||
|  | |||||||
| @ -9,7 +9,9 @@ using System.Reflection; | |||||||
| using Microsoft.OpenApi.Models; | using Microsoft.OpenApi.Models; | ||||||
|  |  | ||||||
| var builder = WebApplication.CreateBuilder(args); | var builder = WebApplication.CreateBuilder(args); | ||||||
|  | builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { | ||||||
|  |     build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); | ||||||
|  | })); | ||||||
| // Add services to the container. | // Add services to the container. | ||||||
| var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | ||||||
| builder.Services.AddAuthentication(item => | builder.Services.AddAuthentication(item => | ||||||
| @ -93,6 +95,7 @@ if (app.Environment.IsDevelopment()) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | app.UseCors("DamageAppCorsPolicy"); | ||||||
| app.UseAuthentication(); | app.UseAuthentication(); | ||||||
| app.UseAuthorization(); | app.UseAuthorization(); | ||||||
|  |  | ||||||
|  | |||||||
| @ -17,7 +17,9 @@ const int maxRetryForCircuitBraker = 5; | |||||||
| const int intervalForCircuitBraker = 5; //5 seconds | const int intervalForCircuitBraker = 5; //5 seconds | ||||||
|  |  | ||||||
| var builder = WebApplication.CreateBuilder(args); | var builder = WebApplication.CreateBuilder(args); | ||||||
|  | builder.Services.AddCors(p => p.AddPolicy("DamageAppCorsPolicy", build => { | ||||||
|  |     build.WithOrigins("*").AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); | ||||||
|  | })); | ||||||
| // Add services to the container. | // Add services to the container. | ||||||
| var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | var authkey = builder.Configuration.GetValue<string>("JwtSettings:securitykey"); | ||||||
|  |  | ||||||
| @ -139,6 +141,7 @@ if (app.Environment.IsDevelopment()) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | app.UseCors("DamageAppCorsPolicy"); | ||||||
| app.UseAuthentication(); | app.UseAuthentication(); | ||||||
| app.UseAuthorization(); | app.UseAuthorization(); | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user