diff --git a/.env.example b/.env.example
index 9fe313e..4eba71f 100644
--- a/.env.example
+++ b/.env.example
@@ -11,7 +11,7 @@ MONGO_INITDB_ROOT_PASSWORD=admin
COMANDA_MONGO_CONNECTIONSTRING=mongodb://admin:admin@localhost:27017/comanda?authSource=admin
COMANDA_MONGO_DATABASENAME=comanda
-COMANDA_FEDERATION_BASEURL=http://localhost:8080
+COMANDA_FEDERATION_AUTHORITY=http://localhost:8080
COMANDA_FEDERATION_REALM=comanda
COMANDA_FEDERATION_CLIENTID=client-identifier
COMANDA_FEDERATION_CLIENTSECRET=client-secret
diff --git a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.Application/Comanda.Orchestrator.Application.csproj b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.Application/Comanda.Orchestrator.Application.csproj
index 3a8c8d7..9a93538 100644
--- a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.Application/Comanda.Orchestrator.Application.csproj
+++ b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.Application/Comanda.Orchestrator.Application.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.CrossCutting/Configurations/FederationSettings.cs b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.CrossCutting/Configurations/FederationSettings.cs
index 64b727b..61cd457 100644
--- a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.CrossCutting/Configurations/FederationSettings.cs
+++ b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.CrossCutting/Configurations/FederationSettings.cs
@@ -5,5 +5,6 @@ public sealed record FederationSettings
public string ClientId { get; init; } = default!;
public string ClientSecret { get; init; } = default!;
public string Realm { get; init; } = default!;
- public string BaseUrl { get; init; } = default!;
+ public string Authority { get; init; } = default!;
+ public string[] Audiences { get; init; } = default!;
}
diff --git a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Comanda.Orchestrator.WebApi.csproj b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Comanda.Orchestrator.WebApi.csproj
index 6431dc7..b56765e 100644
--- a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Comanda.Orchestrator.WebApi.csproj
+++ b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Comanda.Orchestrator.WebApi.csproj
@@ -22,7 +22,7 @@
-
+
diff --git a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Extensions/OpenApiExtension.cs b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Extensions/OpenApiExtension.cs
index 577c679..8ce79e7 100644
--- a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Extensions/OpenApiExtension.cs
+++ b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Extensions/OpenApiExtension.cs
@@ -30,7 +30,7 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
{
ClientCredentials = new OpenApiOAuthFlow
{
- TokenUrl = new Uri(settings.Federation.BaseUrl + "/api/v1/protocol/open-id/connect/token")
+ TokenUrl = new Uri(settings.Federation.Authority + "/api/v1/protocol/open-id/connect/token")
}
}
};
@@ -41,12 +41,6 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
[document.Components.SecuritySchemes[SecuritySchemes.Bearer]] = Array.Empty(),
});
- document.Info.Contact = new OpenApiContact
- {
- Name = "Richard Garcia",
- Email = "code.richardys@gmail.com",
- };
-
return Task.CompletedTask;
});
});
diff --git a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Extensions/WebInfrastructureExtension.cs b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Extensions/WebInfrastructureExtension.cs
index 0e5657e..f251018 100644
--- a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Extensions/WebInfrastructureExtension.cs
+++ b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/Extensions/WebInfrastructureExtension.cs
@@ -22,10 +22,11 @@ public static void AddWebComposition(this IServiceCollection services)
services.AddOpenApiSpecification();
services.AddFederation(options =>
{
- options.BaseUrl = settings.Federation.BaseUrl;
+ options.Authority = settings.Federation.Authority;
options.ClientId = settings.Federation.ClientId;
options.Realm = settings.Federation.Realm;
options.ClientSecret = settings.Federation.ClientSecret;
+ options.Audiences = settings.Federation.Audiences;
});
services.AddIdempotency()
diff --git a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/appsettings.json b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/appsettings.json
index 450e6fc..192f4ed 100644
--- a/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/appsettings.json
+++ b/Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.WebApi/appsettings.json
@@ -1,10 +1,11 @@
{
"Settings": {
"Federation": {
- "BaseUrl": "${Settings__Federation__BaseUrl}",
+ "Authority": "${Settings__Federation__BaseUrl}",
"Realm": "${Settings__Federation__Realm}",
"ClientId": "${Settings__Federation__ClientId}",
- "ClientSecret": "${Settings__Federation__ClientSecret}"
+ "ClientSecret": "${Settings__Federation__ClientSecret}",
+ "Audiences": [ "${Settings__Federation__Audiences__0}" ]
},
"Downstream": {
"ProfilesUrl": "${Settings__Downstream__ProfilesUrl}",
diff --git a/Boundaries/Comanda.Orchestrator/Tests/Fixtures/WebApplicationFixture.cs b/Boundaries/Comanda.Orchestrator/Tests/Fixtures/WebApplicationFixture.cs
index b521cc0..1cf90a0 100644
--- a/Boundaries/Comanda.Orchestrator/Tests/Fixtures/WebApplicationFixture.cs
+++ b/Boundaries/Comanda.Orchestrator/Tests/Fixtures/WebApplicationFixture.cs
@@ -9,7 +9,7 @@ public sealed class WebApplicationFixture : IAsyncLifetime
public IServiceProvider Services { get; private set; } = default!;
private WebApplicationFactory _factory = default!;
- public async ValueTask InitializeAsync()
+ public ValueTask InitializeAsync()
{
_factory = new WebApplicationFactory().WithWebHostBuilder(builder =>
{
@@ -22,7 +22,7 @@ public async ValueTask InitializeAsync()
options.DefaultScheme = Defaults.AuthenticationScheme;
});
- policy.AddScheme(Defaults.AuthenticationScheme, _ => { });
+ policy.AddScheme(Defaults.AuthenticationScheme, _ => { });
services.AddAuthorizationBuilder()
.SetDefaultPolicy(new AuthorizationPolicyBuilder(Defaults.AuthenticationScheme)
.RequireAuthenticatedUser()
@@ -32,6 +32,8 @@ public async ValueTask InitializeAsync()
HttpClient = _factory.CreateClient();
Services = _factory.Services;
+
+ return ValueTask.CompletedTask;
}
public async ValueTask DisposeAsync()
diff --git a/Boundaries/Comanda.Orders/Source/Comanda.Orders.Application/Comanda.Orders.Application.csproj b/Boundaries/Comanda.Orders/Source/Comanda.Orders.Application/Comanda.Orders.Application.csproj
index d552514..540bb6a 100644
--- a/Boundaries/Comanda.Orders/Source/Comanda.Orders.Application/Comanda.Orders.Application.csproj
+++ b/Boundaries/Comanda.Orders/Source/Comanda.Orders.Application/Comanda.Orders.Application.csproj
@@ -8,9 +8,9 @@
-
-
-
+
+
+
diff --git a/Boundaries/Comanda.Orders/Source/Comanda.Orders.CrossCutting/Configurations/FederationSettings.cs b/Boundaries/Comanda.Orders/Source/Comanda.Orders.CrossCutting/Configurations/FederationSettings.cs
index 07b9247..9e569d4 100644
--- a/Boundaries/Comanda.Orders/Source/Comanda.Orders.CrossCutting/Configurations/FederationSettings.cs
+++ b/Boundaries/Comanda.Orders/Source/Comanda.Orders.CrossCutting/Configurations/FederationSettings.cs
@@ -5,5 +5,6 @@ public sealed record FederationSettings
public string ClientId { get; init; } = default!;
public string ClientSecret { get; init; } = default!;
public string Realm { get; init; } = default!;
- public string BaseUrl { get; init; } = default!;
+ public string Authority { get; init; } = default!;
+ public string[] Audiences { get; init; } = default!;
}
diff --git a/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Comanda.Orders.WebApi.csproj b/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Comanda.Orders.WebApi.csproj
index 152595d..2136476 100644
--- a/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Comanda.Orders.WebApi.csproj
+++ b/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Comanda.Orders.WebApi.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Extensions/OpenApiExtension.cs b/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Extensions/OpenApiExtension.cs
index 4733020..46d589b 100644
--- a/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Extensions/OpenApiExtension.cs
+++ b/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Extensions/OpenApiExtension.cs
@@ -30,7 +30,7 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
{
ClientCredentials = new OpenApiOAuthFlow
{
- TokenUrl = new Uri(settings.Federation.BaseUrl + "/api/v1/protocol/open-id/connect/token")
+ TokenUrl = new Uri(settings.Federation.Authority + "/api/v1/protocol/open-id/connect/token")
}
}
};
@@ -41,12 +41,6 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
[document.Components.SecuritySchemes[SecuritySchemes.Bearer]] = Array.Empty(),
});
- document.Info.Contact = new OpenApiContact
- {
- Name = "Richard Garcia",
- Email = "code.richardy@gmail.com",
- };
-
return Task.CompletedTask;
});
});
diff --git a/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Extensions/WebInfrastructureExtension.cs b/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Extensions/WebInfrastructureExtension.cs
index bc5ca9b..f028039 100644
--- a/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Extensions/WebInfrastructureExtension.cs
+++ b/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/Extensions/WebInfrastructureExtension.cs
@@ -20,10 +20,11 @@ public static void AddWebComposition(this IServiceCollection services)
services.AddOpenApiSpecification();
services.AddFederation(options =>
{
- options.BaseUrl = settings.Federation.BaseUrl;
+ options.Authority = settings.Federation.Authority;
options.ClientId = settings.Federation.ClientId;
options.Realm = settings.Federation.Realm;
options.ClientSecret = settings.Federation.ClientSecret;
+ options.Audiences = settings.Federation.Audiences;
});
}
}
diff --git a/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/appsettings.json b/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/appsettings.json
index 8221508..0a7e158 100644
--- a/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/appsettings.json
+++ b/Boundaries/Comanda.Orders/Source/Comanda.Orders.WebApi/appsettings.json
@@ -5,10 +5,11 @@
"DatabaseName": "${Settings__Database__DatabaseName}"
},
"Federation": {
- "BaseUrl": "${Settings__Federation__BaseUrl}",
+ "Authority": "${Settings__Federation__Authority}",
"Realm": "${Settings__Federation__Realm}",
"ClientId": "${Settings__Federation__ClientId}",
- "ClientSecret": "${Settings__Federation__ClientSecret}"
+ "ClientSecret": "${Settings__Federation__ClientSecret}",
+ "Audiences": [ "${Settings__Federation__Audiences__0}" ]
},
"Observability": {
"SeqServerUrl": "${Settings__Observability__SeqServerUrl}",
diff --git a/Boundaries/Comanda.Orders/Tests/Fixtures/WebApplicationFixture.cs b/Boundaries/Comanda.Orders/Tests/Fixtures/WebApplicationFixture.cs
index 1a3a2f7..e34e310 100644
--- a/Boundaries/Comanda.Orders/Tests/Fixtures/WebApplicationFixture.cs
+++ b/Boundaries/Comanda.Orders/Tests/Fixtures/WebApplicationFixture.cs
@@ -25,6 +25,7 @@ public async ValueTask InitializeAsync()
_factory = new WebApplicationFactory()
.WithWebHostBuilder(builder =>
{
+ builder.UseEnvironment("Testing");
builder.ConfigureServices(services =>
{
services.AddAuthentication(options =>
diff --git a/Boundaries/Comanda.Orders/Tests/Usings.cs b/Boundaries/Comanda.Orders/Tests/Usings.cs
index 9e758ad..0afeff1 100644
--- a/Boundaries/Comanda.Orders/Tests/Usings.cs
+++ b/Boundaries/Comanda.Orders/Tests/Usings.cs
@@ -9,6 +9,7 @@
global using Microsoft.AspNetCore.Authorization;
global using Microsoft.AspNetCore.Mvc.Testing;
+global using Microsoft.AspNetCore.Hosting;
global using Microsoft.Extensions.DependencyInjection;
global using Comanda.Orders.WebApi;
diff --git a/Boundaries/Comanda.Payments/Source/Comanda.Payments.Application/Comanda.Payments.Application.csproj b/Boundaries/Comanda.Payments/Source/Comanda.Payments.Application/Comanda.Payments.Application.csproj
index d3d9bc1..93a901e 100644
--- a/Boundaries/Comanda.Payments/Source/Comanda.Payments.Application/Comanda.Payments.Application.csproj
+++ b/Boundaries/Comanda.Payments/Source/Comanda.Payments.Application/Comanda.Payments.Application.csproj
@@ -8,9 +8,9 @@
-
-
-
+
+
+
diff --git a/Boundaries/Comanda.Payments/Source/Comanda.Payments.CrossCutting/Configurations/FederationSettings.cs b/Boundaries/Comanda.Payments/Source/Comanda.Payments.CrossCutting/Configurations/FederationSettings.cs
index a18745e..95a634c 100644
--- a/Boundaries/Comanda.Payments/Source/Comanda.Payments.CrossCutting/Configurations/FederationSettings.cs
+++ b/Boundaries/Comanda.Payments/Source/Comanda.Payments.CrossCutting/Configurations/FederationSettings.cs
@@ -5,5 +5,6 @@ public sealed record FederationSettings
public string ClientId { get; init; } = default!;
public string ClientSecret { get; init; } = default!;
public string Realm { get; init; } = default!;
- public string BaseUrl { get; init; } = default!;
+ public string Authority { get; init; } = default!;
+ public string[] Audiences { get; init; } = default!;
}
diff --git a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Comanda.Payments.WebApi.csproj b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Comanda.Payments.WebApi.csproj
index f0277b6..d6db461 100644
--- a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Comanda.Payments.WebApi.csproj
+++ b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Comanda.Payments.WebApi.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/MonitoringExtension.cs b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/MonitoringExtension.cs
index 2ecb475..735507b 100644
--- a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/MonitoringExtension.cs
+++ b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/MonitoringExtension.cs
@@ -4,6 +4,10 @@ public static class MonitoringExtension
{
public static void AddMonitoring(this WebApplicationBuilder builder)
{
+ // prevents sentry from being initialized in non-production/non-development environments (e.g., testing)
+ if (!builder.Environment.IsDevelopment() && !builder.Environment.IsProduction())
+ return;
+
var settings = builder.Services
.BuildServiceProvider()
.GetRequiredService();
diff --git a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/ObservabilityExtension.cs b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/ObservabilityExtension.cs
index c6a3912..0d45676 100644
--- a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/ObservabilityExtension.cs
+++ b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/ObservabilityExtension.cs
@@ -5,6 +5,10 @@ public static class ObservabilityExtension
{
public static void AddObservability(this WebApplicationBuilder builder)
{
+ // prevents seq from being initialized in non-production/non-development environments (e.g., testing)
+ if (!builder.Environment.IsDevelopment() && !builder.Environment.IsProduction())
+ return;
+
builder.Host.UseSerilog((context, services, logger) =>
{
var settings = services.GetRequiredService();
diff --git a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/OpenApiExtension.cs b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/OpenApiExtension.cs
index c814756..6d50a62 100644
--- a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/OpenApiExtension.cs
+++ b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/OpenApiExtension.cs
@@ -29,7 +29,7 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
{
ClientCredentials = new OpenApiOAuthFlow
{
- TokenUrl = new Uri(settings.Federation.BaseUrl + "/api/v1/protocol/open-id/connect/token")
+ TokenUrl = new Uri(settings.Federation.Authority + "/api/v1/protocol/open-id/connect/token")
}
}
};
@@ -40,12 +40,6 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
[document.Components.SecuritySchemes[SecuritySchemes.Bearer]] = Array.Empty(),
});
- document.Info.Contact = new OpenApiContact
- {
- Name = "Richard Garcia",
- Email = "code.richardy@gmail.com",
- };
-
return Task.CompletedTask;
});
});
diff --git a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/WebInfrastructureExtension.cs b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/WebInfrastructureExtension.cs
index 1e57b2f..8a9b883 100644
--- a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/WebInfrastructureExtension.cs
+++ b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Extensions/WebInfrastructureExtension.cs
@@ -3,7 +3,7 @@ namespace Comanda.Payments.WebApi.Extensions;
[ExcludeFromCodeCoverage(Justification = "contains only web infrastructure configuration with no business logic.")]
public static class WebInfrastructureExtension
{
- public static void AddWebComposition(this IServiceCollection services, IWebHostEnvironment environment)
+ public static void AddWebComposition(this IServiceCollection services)
{
var provider = services.BuildServiceProvider();
var settings = provider.GetRequiredService();
@@ -22,10 +22,11 @@ public static void AddWebComposition(this IServiceCollection services, IWebHostE
services.AddOpenApiSpecification();
services.AddFederation(options =>
{
- options.BaseUrl = settings.Federation.BaseUrl;
+ options.Authority = settings.Federation.Authority;
options.ClientId = settings.Federation.ClientId;
options.Realm = settings.Federation.Realm;
options.ClientSecret = settings.Federation.ClientSecret;
+ options.Audiences = settings.Federation.Audiences;
});
}
}
diff --git a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Program.cs b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Program.cs
index ca3befd..6b609f3 100644
--- a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Program.cs
+++ b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/Program.cs
@@ -10,7 +10,7 @@ private static async Task Main(string[] args)
var configuration = builder.Configuration;
builder.Services.AddInfrastructure(configuration);
- builder.Services.AddWebComposition(environment);
+ builder.Services.AddWebComposition();
builder.Configuration.AddEnvironmentVariables();
diff --git a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/appsettings.json b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/appsettings.json
index 4db67bc..43c07f3 100644
--- a/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/appsettings.json
+++ b/Boundaries/Comanda.Payments/Source/Comanda.Payments.WebApi/appsettings.json
@@ -5,10 +5,11 @@
"DatabaseName": "${Settings__Database__DatabaseName}"
},
"Federation": {
- "BaseUrl": "${Settings__Federation__BaseUrl}",
+ "Authority": "${Settings__Federation__Authority}",
"Realm": "${Settings__Federation__Realm}",
"ClientId": "${Settings__Federation__ClientId}",
- "ClientSecret": "${Settings__Federation__ClientSecret}"
+ "ClientSecret": "${Settings__Federation__ClientSecret}",
+ "Audiences": [ "${Settings__Federation__Audiences__0}" ]
},
"AbacatePay": {
"Url": "${Settings__AbacatePay__Url}"
@@ -28,4 +29,4 @@
"FromLogContext"
]
}
-}
\ No newline at end of file
+}
diff --git a/Boundaries/Comanda.Payments/Tests/Fixtures/WebApplicationFixture.cs b/Boundaries/Comanda.Payments/Tests/Fixtures/WebApplicationFixture.cs
index cf5eb2f..b877891 100644
--- a/Boundaries/Comanda.Payments/Tests/Fixtures/WebApplicationFixture.cs
+++ b/Boundaries/Comanda.Payments/Tests/Fixtures/WebApplicationFixture.cs
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Hosting;
namespace Comanda.Payments.TestSuite.Fixtures;
@@ -28,6 +29,7 @@ public async ValueTask InitializeAsync()
_factory = new WebApplicationFactory()
.WithWebHostBuilder(builder =>
{
+ builder.UseEnvironment("Testing");
builder.ConfigureServices(services =>
{
services.AddAuthentication(options =>
diff --git a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.Application/Comanda.Profiles.Application.csproj b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.Application/Comanda.Profiles.Application.csproj
index f8b4c8a..b1a55f2 100644
--- a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.Application/Comanda.Profiles.Application.csproj
+++ b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.Application/Comanda.Profiles.Application.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.CrossCutting/Configurations/FederationSettings.cs b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.CrossCutting/Configurations/FederationSettings.cs
index 8bbf4df..4d892b5 100644
--- a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.CrossCutting/Configurations/FederationSettings.cs
+++ b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.CrossCutting/Configurations/FederationSettings.cs
@@ -5,5 +5,6 @@ public sealed record FederationSettings
public string ClientId { get; init; } = default!;
public string ClientSecret { get; init; } = default!;
public string Realm { get; init; } = default!;
- public string BaseUrl { get; init; } = default!;
+ public string Authority { get; init; } = default!;
+ public string[] Audiences { get; init; } = default!;
}
diff --git a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Comanda.Profiles.WebApi.csproj b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Comanda.Profiles.WebApi.csproj
index fa86294..c1512ff 100644
--- a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Comanda.Profiles.WebApi.csproj
+++ b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Comanda.Profiles.WebApi.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Extensions/OpenApiExtension.cs b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Extensions/OpenApiExtension.cs
index d9e4e68..55e6c68 100644
--- a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Extensions/OpenApiExtension.cs
+++ b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Extensions/OpenApiExtension.cs
@@ -29,7 +29,7 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
{
ClientCredentials = new OpenApiOAuthFlow
{
- TokenUrl = new Uri(settings.Federation.BaseUrl + "/api/v1/protocol/open-id/connect/token")
+ TokenUrl = new Uri(settings.Federation.Authority + "/api/v1/protocol/open-id/connect/token")
}
}
};
@@ -40,12 +40,6 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
[document.Components.SecuritySchemes[SecuritySchemes.Bearer]] = Array.Empty(),
});
- document.Info.Contact = new OpenApiContact
- {
- Name = "vinder.io",
- Email = "vinder.desenvolvimento@gmail.com",
- };
-
return Task.CompletedTask;
});
});
diff --git a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Extensions/WebInfrastructureExtension.cs b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Extensions/WebInfrastructureExtension.cs
index decc91a..3db592c 100644
--- a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Extensions/WebInfrastructureExtension.cs
+++ b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/Extensions/WebInfrastructureExtension.cs
@@ -20,10 +20,11 @@ public static void AddWebComposition(this IServiceCollection services)
services.AddOpenApiSpecification();
services.AddFederation(options =>
{
- options.BaseUrl = settings.Federation.BaseUrl;
+ options.Authority = settings.Federation.Authority;
options.ClientId = settings.Federation.ClientId;
options.Realm = settings.Federation.Realm;
options.ClientSecret = settings.Federation.ClientSecret;
+ options.Audiences = settings.Federation.Audiences;
});
}
}
diff --git a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/appsettings.json b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/appsettings.json
index 8221508..0a7e158 100644
--- a/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/appsettings.json
+++ b/Boundaries/Comanda.Profiles/Source/Comanda.Profiles.WebApi/appsettings.json
@@ -5,10 +5,11 @@
"DatabaseName": "${Settings__Database__DatabaseName}"
},
"Federation": {
- "BaseUrl": "${Settings__Federation__BaseUrl}",
+ "Authority": "${Settings__Federation__Authority}",
"Realm": "${Settings__Federation__Realm}",
"ClientId": "${Settings__Federation__ClientId}",
- "ClientSecret": "${Settings__Federation__ClientSecret}"
+ "ClientSecret": "${Settings__Federation__ClientSecret}",
+ "Audiences": [ "${Settings__Federation__Audiences__0}" ]
},
"Observability": {
"SeqServerUrl": "${Settings__Observability__SeqServerUrl}",
diff --git a/Boundaries/Comanda.Profiles/Tests/Fixtures/WebApplicationFixture.cs b/Boundaries/Comanda.Profiles/Tests/Fixtures/WebApplicationFixture.cs
index c2b3894..c31fa29 100644
--- a/Boundaries/Comanda.Profiles/Tests/Fixtures/WebApplicationFixture.cs
+++ b/Boundaries/Comanda.Profiles/Tests/Fixtures/WebApplicationFixture.cs
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Hosting;
namespace Comanda.Profiles.TestSuite.Fixtures;
@@ -28,6 +29,7 @@ public async ValueTask InitializeAsync()
_factory = new WebApplicationFactory()
.WithWebHostBuilder(builder =>
{
+ builder.UseEnvironment("Testing");
builder.ConfigureServices(services =>
{
services.AddAuthentication(options =>
diff --git a/Boundaries/Comanda.Stores/Source/Comanda.Stores.Application/Comanda.Stores.Application.csproj b/Boundaries/Comanda.Stores/Source/Comanda.Stores.Application/Comanda.Stores.Application.csproj
index d220f81..38a839c 100644
--- a/Boundaries/Comanda.Stores/Source/Comanda.Stores.Application/Comanda.Stores.Application.csproj
+++ b/Boundaries/Comanda.Stores/Source/Comanda.Stores.Application/Comanda.Stores.Application.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/Boundaries/Comanda.Stores/Source/Comanda.Stores.CrossCutting/Configurations/FederationSettings.cs b/Boundaries/Comanda.Stores/Source/Comanda.Stores.CrossCutting/Configurations/FederationSettings.cs
index 039cc04..b196505 100644
--- a/Boundaries/Comanda.Stores/Source/Comanda.Stores.CrossCutting/Configurations/FederationSettings.cs
+++ b/Boundaries/Comanda.Stores/Source/Comanda.Stores.CrossCutting/Configurations/FederationSettings.cs
@@ -5,5 +5,6 @@ public sealed record FederationSettings
public string ClientId { get; init; } = default!;
public string ClientSecret { get; init; } = default!;
public string Realm { get; init; } = default!;
- public string BaseUrl { get; init; } = default!;
+ public string Authority { get; init; } = default!;
+ public string[] Audiences { get; init; } = default!;
}
diff --git a/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Comanda.Stores.WebApi.csproj b/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Comanda.Stores.WebApi.csproj
index 6d17862..fdaa8cf 100644
--- a/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Comanda.Stores.WebApi.csproj
+++ b/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Comanda.Stores.WebApi.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/MonitoringExtension.cs b/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/MonitoringExtension.cs
index c558166..03019cc 100644
--- a/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/MonitoringExtension.cs
+++ b/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/MonitoringExtension.cs
@@ -19,7 +19,6 @@ public static void AddMonitoring(this WebApplicationBuilder builder)
options.Dsn = settings.Observability.SentryDsn;
options.Environment = builder.Environment.EnvironmentName;
options.TracesSampleRate = 1.0;
- options.Debug = true;
options.EnableLogs = true;
});
}
diff --git a/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/OpenApiExtension.cs b/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/OpenApiExtension.cs
index 161b0b8..27d05b3 100644
--- a/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/OpenApiExtension.cs
+++ b/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/OpenApiExtension.cs
@@ -30,7 +30,7 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
{
ClientCredentials = new OpenApiOAuthFlow
{
- TokenUrl = new Uri(settings.Federation.BaseUrl + "/api/v1/protocol/open-id/connect/token")
+ TokenUrl = new Uri(settings.Federation.Authority + "/api/v1/protocol/open-id/connect/token")
}
}
};
@@ -41,12 +41,6 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
[document.Components.SecuritySchemes[SecuritySchemes.Bearer]] = Array.Empty(),
});
- document.Info.Contact = new OpenApiContact
- {
- Name = "vinder.io",
- Email = "vinder.desenvolvimento@gmail.com",
- };
-
return Task.CompletedTask;
});
});
diff --git a/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/WebInfrastructureExtension.cs b/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/WebInfrastructureExtension.cs
index d0cf031..30b19bd 100644
--- a/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/WebInfrastructureExtension.cs
+++ b/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/Extensions/WebInfrastructureExtension.cs
@@ -22,10 +22,11 @@ public static void AddWebComposition(this IServiceCollection services, IWebHostE
services.AddOpenApiSpecification();
services.AddFederation(options =>
{
- options.BaseUrl = settings.Federation.BaseUrl;
+ options.Authority = settings.Federation.Authority;
options.ClientId = settings.Federation.ClientId;
options.Realm = settings.Federation.Realm;
options.ClientSecret = settings.Federation.ClientSecret;
+ options.Audiences = settings.Federation.Audiences;
});
}
}
diff --git a/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/appsettings.json b/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/appsettings.json
index 8221508..0a7e158 100644
--- a/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/appsettings.json
+++ b/Boundaries/Comanda.Stores/Source/Comanda.Stores.WebApi/appsettings.json
@@ -5,10 +5,11 @@
"DatabaseName": "${Settings__Database__DatabaseName}"
},
"Federation": {
- "BaseUrl": "${Settings__Federation__BaseUrl}",
+ "Authority": "${Settings__Federation__Authority}",
"Realm": "${Settings__Federation__Realm}",
"ClientId": "${Settings__Federation__ClientId}",
- "ClientSecret": "${Settings__Federation__ClientSecret}"
+ "ClientSecret": "${Settings__Federation__ClientSecret}",
+ "Audiences": [ "${Settings__Federation__Audiences__0}" ]
},
"Observability": {
"SeqServerUrl": "${Settings__Observability__SeqServerUrl}",
diff --git a/Boundaries/Comanda.Stores/Tests/Fixtures/WebApplicationFixture.cs b/Boundaries/Comanda.Stores/Tests/Fixtures/WebApplicationFixture.cs
index ecff682..addc569 100644
--- a/Boundaries/Comanda.Stores/Tests/Fixtures/WebApplicationFixture.cs
+++ b/Boundaries/Comanda.Stores/Tests/Fixtures/WebApplicationFixture.cs
@@ -1,3 +1,5 @@
+using Microsoft.AspNetCore.Hosting;
+
namespace Comanda.Stores.TestSuite.Fixtures;
public sealed class WebApplicationFixture : IAsyncLifetime
@@ -25,6 +27,7 @@ public async ValueTask InitializeAsync()
_factory = new WebApplicationFactory()
.WithWebHostBuilder(builder =>
{
+ builder.UseEnvironment("Testing");
builder.ConfigureServices(services =>
{
services.AddBypassAuthentication();
diff --git a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.Application/Comanda.Subscriptions.Application.csproj b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.Application/Comanda.Subscriptions.Application.csproj
index c1e69f0..25caf83 100644
--- a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.Application/Comanda.Subscriptions.Application.csproj
+++ b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.Application/Comanda.Subscriptions.Application.csproj
@@ -8,8 +8,8 @@
-
-
+
+
diff --git a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.CrossCutting/Configurations/FederationSettings.cs b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.CrossCutting/Configurations/FederationSettings.cs
index 58cc96d..df07795 100644
--- a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.CrossCutting/Configurations/FederationSettings.cs
+++ b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.CrossCutting/Configurations/FederationSettings.cs
@@ -5,5 +5,6 @@ public sealed record FederationSettings
public string ClientId { get; init; } = default!;
public string ClientSecret { get; init; } = default!;
public string Realm { get; init; } = default!;
- public string BaseUrl { get; init; } = default!;
+ public string Authority { get; init; } = default!;
+ public string[] Audiences { get; init; } = default!;
}
diff --git a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Comanda.Subscriptions.WebApi.csproj b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Comanda.Subscriptions.WebApi.csproj
index bd2d238..245a4dd 100644
--- a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Comanda.Subscriptions.WebApi.csproj
+++ b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Comanda.Subscriptions.WebApi.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Extensions/OpenApiExtension.cs b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Extensions/OpenApiExtension.cs
index 63d3554..f1b3721 100644
--- a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Extensions/OpenApiExtension.cs
+++ b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Extensions/OpenApiExtension.cs
@@ -29,7 +29,7 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
{
ClientCredentials = new OpenApiOAuthFlow
{
- TokenUrl = new Uri(settings.Federation.BaseUrl + "/api/v1/protocol/open-id/connect/token")
+ TokenUrl = new Uri(settings.Federation.Authority + "/api/v1/protocol/open-id/connect/token")
}
}
};
@@ -40,12 +40,6 @@ public static void AddOpenApiSpecification(this IServiceCollection services)
[document.Components.SecuritySchemes[SecuritySchemes.Bearer]] = Array.Empty(),
});
- document.Info.Contact = new OpenApiContact
- {
- Name = "vinder.io",
- Email = "vinder.desenvolvimento@gmail.com",
- };
-
return Task.CompletedTask;
});
});
diff --git a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Extensions/WebInfrastructureExtension.cs b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Extensions/WebInfrastructureExtension.cs
index 1287de9..54bfe8b 100644
--- a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Extensions/WebInfrastructureExtension.cs
+++ b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/Extensions/WebInfrastructureExtension.cs
@@ -20,10 +20,11 @@ public static void AddWebComposition(this IServiceCollection services)
services.AddOpenApiSpecification();
services.AddFederation(options =>
{
- options.BaseUrl = settings.Federation.BaseUrl;
+ options.Authority = settings.Federation.Authority;
options.ClientId = settings.Federation.ClientId;
options.Realm = settings.Federation.Realm;
options.ClientSecret = settings.Federation.ClientSecret;
+ options.Audiences = settings.Federation.Audiences;
});
}
}
diff --git a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/appsettings.json b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/appsettings.json
index 4a06dd6..e6d12de 100644
--- a/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/appsettings.json
+++ b/Boundaries/Comanda.Subscriptions/Source/Comanda.Subscriptions.WebApi/appsettings.json
@@ -5,10 +5,11 @@
"DatabaseName": "${Settings__Database__DatabaseName}"
},
"Federation": {
- "BaseUrl": "${Settings__Federation__BaseUrl}",
+ "Authority": "${Settings__Federation__Authority}",
"Realm": "${Settings__Federation__Realm}",
"ClientId": "${Settings__Federation__ClientId}",
- "ClientSecret": "${Settings__Federation__ClientSecret}"
+ "ClientSecret": "${Settings__Federation__ClientSecret}",
+ "Audiences": [ "${Settings__Federation__Audiences__0}" ]
},
"Stripe": {
"Secret": "${Settings__Stripe__Secret}"
diff --git a/docker-compose.yml b/docker-compose.yml
index fbd4d1e..d01929d 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -63,7 +63,7 @@ services:
Settings__Database__DatabaseName: ${COMANDA_MONGO_DATABASENAME}
# federation settings
- Settings__Federation__BaseUrl: ${COMANDA_FEDERATION_BASEURL}
+ Settings__Federation__Authority: ${COMANDA_FEDERATION_AUTHORITY}
Settings__Federation__Realm: ${COMANDA_FEDERATION_REALM}
Settings__Federation__ClientId: ${COMANDA_FEDERATION_CLIENTID}
Settings__Federation__ClientSecret: ${COMANDA_FEDERATION_CLIENTSECRET}
@@ -90,7 +90,7 @@ services:
Settings__Database__DatabaseName: ${COMANDA_MONGO_DATABASENAME}
# federation settings
- Settings__Federation__BaseUrl: ${COMANDA_FEDERATION_BASEURL}
+ Settings__Federation__Authority: ${COMANDA_FEDERATION_AUTHORITY}
Settings__Federation__Realm: ${COMANDA_FEDERATION_REALM}
Settings__Federation__ClientId: ${COMANDA_FEDERATION_CLIENTID}
Settings__Federation__ClientSecret: ${COMANDA_FEDERATION_CLIENTSECRET}
@@ -120,7 +120,7 @@ services:
Settings__Database__DatabaseName: ${COMANDA_MONGO_DATABASENAME}
# federation settings
- Settings__Federation__BaseUrl: ${COMANDA_FEDERATION_BASEURL}
+ Settings__Federation__Authority: ${COMANDA_FEDERATION_AUTHORITY}
Settings__Federation__Realm: ${COMANDA_FEDERATION_REALM}
Settings__Federation__ClientId: ${COMANDA_FEDERATION_CLIENTID}
Settings__Federation__ClientSecret: ${COMANDA_FEDERATION_CLIENTSECRET}
@@ -147,7 +147,7 @@ services:
Settings__Database__DatabaseName: ${COMANDA_MONGO_DATABASENAME}
# federation settings
- Settings__Federation__BaseUrl: ${COMANDA_FEDERATION_BASEURL}
+ Settings__Federation__Authority: ${COMANDA_FEDERATION_AUTHORITY}
Settings__Federation__Realm: ${COMANDA_FEDERATION_REALM}
Settings__Federation__ClientId: ${COMANDA_FEDERATION_CLIENTID}
Settings__Federation__ClientSecret: ${COMANDA_FEDERATION_CLIENTSECRET}
@@ -177,7 +177,7 @@ services:
Settings__Database__DatabaseName: ${COMANDA_MONGO_DATABASENAME}
# federation settings
- Settings__Federation__BaseUrl: ${COMANDA_FEDERATION_BASEURL}
+ Settings__Federation__Authority: ${COMANDA_FEDERATION_AUTHORITY}
Settings__Federation__Realm: ${COMANDA_FEDERATION_REALM}
Settings__Federation__ClientId: ${COMANDA_FEDERATION_CLIENTID}
Settings__Federation__ClientSecret: ${COMANDA_FEDERATION_CLIENTSECRET}
@@ -200,7 +200,7 @@ services:
- comanda.infrastructure.seq
environment:
# federation settings
- Settings__Federation__BaseUrl: ${COMANDA_FEDERATION_BASEURL}
+ Settings__Federation__Authority: ${COMANDA_FEDERATION_AUTHORITY}
Settings__Federation__Realm: ${COMANDA_FEDERATION_REALM}
Settings__Federation__ClientId: ${COMANDA_FEDERATION_CLIENTID}
Settings__Federation__ClientSecret: ${COMANDA_FEDERATION_CLIENTSECRET}