Skip to content

Commit

Permalink
Hotfix: Fixed Audit Trail Issue in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymar921 committed Jan 11, 2024
1 parent a26b536 commit 89296c3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Text.RegularExpressions;
using System.Threading.Channels;
using QuizMaster.API.Gateway.Helper;
using QuizMaster.Library.Common.Entities.Roles;

namespace QuizMaster.API.Gateway.Controllers
{
Expand Down Expand Up @@ -285,7 +286,15 @@ private async Task<AuthStore> GetAuthStoreInfo(string token)
public async Task<IActionResult> CreateRoom(CreateRoomDTO roomDTO)
{
var request = new CreateRoomRequest { Room = JsonConvert.SerializeObject(roomDTO) };
var reply = await roomChannelClient.CreateRoomAsync(request);
var token = this.GetToken();
AuthStore authStore = await GetAuthStoreInfo(token ?? "");
var headers = new Metadata
{
{ "username", authStore.UserData.UserName ?? "unknown" },
{ "id", authStore.UserData.Id.ToString() ?? "unknown" },
{ "role", authStore.Roles.ToString() ?? "unknown" }
};
var reply = await roomChannelClient.CreateRoomAsync(request, headers);

if (reply.Code == 200)
{
Expand Down
2 changes: 1 addition & 1 deletion WebApp/backend/QuizMaster.API.Gatewway/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ FROM base AS final
WORKDIR /app
COPY QuizMaster.API.Gatewway/localhost_cert.pfx ./localhost_cert.pfx
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "QuizMaster.API.Gateway.dll", "https://*:80"]
ENTRYPOINT ["dotnet", "QuizMaster.API.Gateway.dll", "https://*:443;http://*:80;"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public class QuizSessionApplicationSettings
public string RabbitMq_Quiz_ExchangeName { get; set; } = string.Empty;
public string RabbitMq_Quiz_QuizInitQueue { get; set; } = string.Empty;
public string RabbitMq_Hostname { get; set; } = string.Empty;
public string Monitoring_Service { get; set; } = string.Empty;
}
}
16 changes: 14 additions & 2 deletions WebApp/backend/QuizMaster.API.QuizSession/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
using QuizMaster.API.QuizSession.Services.Repositories;
using QuizMaster.API.QuizSession.Services.Workers;

/*
* You have any issues? Contact Jayharron: jabejar@fullscale.io for more info :D
* Date: 1/11/2024
*/
namespace QuizMaster.API.QuizSession
{
public class Program
Expand All @@ -21,12 +25,20 @@ public static void Main(string[] args)
builder.Services.AddGrpc();
builder.Services.AddScoped(sp =>
{
var channel = GrpcChannel.ForAddress("https://localhost:7065");
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;

// Creating Scoped Service Quiz Audit service
var channel = GrpcChannel.ForAddress(builder.Configuration["AppSettings:Monitoring_Service"], new GrpcChannelOptions { HttpHandler = handler });
return new QuizAuditService.QuizAuditServiceClient(channel);
});
builder.Services.AddScoped(sp =>
{
var channel = GrpcChannel.ForAddress("https://localhost:7065");
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;

// Creating Scoped Service Room Audit service
var channel = GrpcChannel.ForAddress(builder.Configuration["AppSettings:Monitoring_Service"], new GrpcChannelOptions { HttpHandler = handler });
return new RoomAuditService.RoomAuditServiceClient(channel);
});
builder.Services.AddControllers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"AppSettings": {
"RabbitMq_Quiz_ExchangeName": "QuizMasterExchange_Quiz",
"RabbitMq_Quiz_QuizInitQueue": "QuizMasterInitQueue_Quiz",
"RabbitMq_Hostname": "localhost"
"RabbitMq_Hostname": "localhost",
"Monitoring_Service": "https://localhost:7065"
},
"Logging": {
"LogLevel": {
Expand Down
3 changes: 2 additions & 1 deletion WebApp/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ services:
- GrpcServerConfiguration:Quiz_Category_Service=https://backend_api_quiz:6005
- GrpcServerConfiguration:Session_Service=https://backend_api_quizsession:6006
- Kestrel:EndpointDefaults:Protocols=Http1AndHttp2
- Kestrel:Endpoints:Https:Url=http://*:80
- Kestrel:Endpoints:Https:Url=https://*:443
- Kestrel:Certificates:Default:Path=/app/localhost_cert.pfx
- Kestrel:Certificates:Default:Password=123456
networks:
Expand Down Expand Up @@ -175,6 +175,7 @@ services:
- AppSettings:RabbitMq_Quiz_ExchangeName=QuizMasterExchange_Quiz
- AppSettings:RabbitMq_Quiz_QuizInitQueue=QuizMasterInitQueue_Quiz
- AppSettings:RabbitMq_Hostname=rabbitmq
- AppSettings:Monitoring_Service=https://backend_api_monitoring:6004
- Kestrel:EndpointDefaults:Protocols=Http1AndHttp2
- Kestrel:Endpoints:Https:Url=https://*:6006
- Kestrel:Certificates:Default:Path=/app/localhost_cert.pfx
Expand Down

0 comments on commit 89296c3

Please sign in to comment.