Skip to content

Commit

Permalink
Merge pull request #82 from Tynab/develop
Browse files Browse the repository at this point in the history
fix cont
  • Loading branch information
Tynab committed Feb 1, 2024
2 parents 7b96d53 + feebe5d commit 257b20d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class UnauthorizedHandlerMiddleware

public UnauthorizedHandlerMiddleware(RequestDelegate next) => _next = next;

public async Task Invoke(HttpContext context)
public async ValueTask Invoke(HttpContext context)
{
var writeCustomResponse = false;
var originalResponse = context.Response.Body;
Expand Down
100 changes: 50 additions & 50 deletions host/YANLib.HttpApi.Host/YANLibHttpApiHostModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,26 @@ private static void ConfigureAuthentication(ServiceConfigurationContext context,
o.RequireHttpsMetadata = ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
o.Audience = configuration["AuthServer:ApiName"];
//#if !DEBUG
// o.Events = new JwtBearerEvents
// {
// OnMessageReceived = async c =>
// {
// string authorization = c.Request.Headers.Authorization;
// if (authorization == configuration["Authorization:Bearer"])
// {
// await CompletedTask;
// }
// else
// {
// c.Response.StatusCode = Unauthorized.ToInt();
// c.Response.ContentType = "application/json";
// await c.Response.WriteAsync("Access Denied");
// }
// }
// };
//#endif
//#if !DEBUG
// o.Events = new JwtBearerEvents
// {
// OnMessageReceived = async c =>
// {
// string authorization = c.Request.Headers.Authorization;
// if (authorization == configuration["Authorization:Bearer"])
// {
// await CompletedTask;
// }
// else
// {
// c.Response.StatusCode = Unauthorized.ToInt();
// c.Response.ContentType = "application/json";
// await c.Response.WriteAsync("Access Denied");
// }
// }
// };
//#endif
});

private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
Expand All @@ -165,29 +165,29 @@ private static void ConfigureSwaggerServices(ServiceConfigurationContext context
Version = "test"
});
//#if !DEBUG
// o.AddSecurityDefinition("Authorization", new OpenApiSecurityScheme
// {
// In = Header,
// Description = "Please insert JWT with Bearer into field",
// Name = "Authorization",
// Type = ApiKey
// });
// o.AddSecurityRequirement(new OpenApiSecurityRequirement
// {
// {
// new OpenApiSecurityScheme
// {
// Reference = new OpenApiReference
// {
// Id = "Authorization",
// Type = ReferenceType.SecurityScheme
// }
// }, new List<string>()
// }
// });
//#endif
//#if !DEBUG
// o.AddSecurityDefinition("Authorization", new OpenApiSecurityScheme
// {
// In = Header,
// Description = "Please insert JWT with Bearer into field",
// Name = "Authorization",
// Type = ApiKey
// });
// o.AddSecurityRequirement(new OpenApiSecurityRequirement
// {
// {
// new OpenApiSecurityScheme
// {
// Reference = new OpenApiReference
// {
// Id = "Authorization",
// Type = ReferenceType.SecurityScheme
// }
// }, new List<string>()
// }
// });
//#endif
o.CustomSchemaIds(t => t.FullName.Replace("+", "."));
o.HideAbpEndpoints();
Expand Down Expand Up @@ -257,7 +257,7 @@ private static void ConfigureHealthChecks(ServiceConfigurationContext context, I
connectionString: configuration["ConnectionStrings:Default"],
name: "database",
failureStatus: Degraded,
tags: ["db", "sql", "sqlserver"]
tags: new string[] { "db", "sql", "sqlserver" }
);

public override void OnApplicationInitialization(ApplicationInitializationContext context)
Expand All @@ -272,9 +272,9 @@ public override void OnApplicationInitialization(ApplicationInitializationContex

_ = app.UseAbpRequestLocalization(o =>
{
o.SetDefaultCulture("vi");
o.AddSupportedCultures("vi");
o.AddSupportedUICultures("vi");
_ = o.SetDefaultCulture("vi");
_ = o.AddSupportedCultures("vi");
_ = o.AddSupportedUICultures("vi");
});

_ = app.UseSwagger();
Expand All @@ -295,9 +295,9 @@ public override void OnApplicationInitialization(ApplicationInitializationContex

_ = app.UseCapDashboard();

//#if !DEBUG
// _ = app.UseMiddleware<UnauthorizedHandlerMiddleware>();
//#endif
//#if !DEBUG
// _ = app.UseMiddleware<UnauthorizedHandlerMiddleware>();
//#endif

_ = app.UseCors();
_ = app.UseAuthentication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public CreateCertificateSubscriber(ILogger<CreateCertificateSubscriber> logger,
}

[CapSubscribe(CERT_CRT)]
public async Task Subscibe(CertificateCreateEto eventData)
public async ValueTask Subscibe(CertificateCreateEto eventData)
{
_logger.LogInformation("CreateCertificateSubscriber-Subscribe: {EventData}", eventData.Serialize());
_logger.LogInformation("CreateCertificateSubscriber-CreateCertificateService: {Responses}", await _certificateService.Create(ObjectMapper.Map<CertificateCreateEto, CertificateRequest>(eventData)));
Expand Down

0 comments on commit 257b20d

Please sign in to comment.