diff --git a/DysonNetwork.Develop/DysonNetwork.Develop.csproj b/DysonNetwork.Develop/DysonNetwork.Develop.csproj index 49cbd38..8bd923c 100644 --- a/DysonNetwork.Develop/DysonNetwork.Develop.csproj +++ b/DysonNetwork.Develop/DysonNetwork.Develop.csproj @@ -18,7 +18,7 @@ - + diff --git a/DysonNetwork.Develop/Program.cs b/DysonNetwork.Develop/Program.cs index 3dae1e0..c9af0c2 100644 --- a/DysonNetwork.Develop/Program.cs +++ b/DysonNetwork.Develop/Program.cs @@ -13,12 +13,16 @@ builder.ConfigureAppKestrel(builder.Configuration); builder.Services.AddAppServices(builder.Configuration); builder.Services.AddAppAuthentication(); -builder.Services.AddAppSwagger(); builder.Services.AddDysonAuth(); builder.Services.AddPublisherService(); builder.Services.AddAccountService(); builder.Services.AddDriveService(); +builder.AddSwaggerManifest( + "DysonNetwork.Develop", + "The developer portal in the Solar Network." +); + var app = builder.Build(); app.MapDefaultEndpoints(); @@ -31,4 +35,6 @@ using (var scope = app.Services.CreateScope()) app.ConfigureAppMiddleware(builder.Configuration); +app.UseSwaggerManifest(); + app.Run(); \ No newline at end of file diff --git a/DysonNetwork.Develop/Startup/ApplicationConfiguration.cs b/DysonNetwork.Develop/Startup/ApplicationConfiguration.cs index 18d5533..4c5a2d4 100644 --- a/DysonNetwork.Develop/Startup/ApplicationConfiguration.cs +++ b/DysonNetwork.Develop/Startup/ApplicationConfiguration.cs @@ -3,6 +3,7 @@ using DysonNetwork.Develop.Identity; using DysonNetwork.Shared.Auth; using DysonNetwork.Shared.Http; using Microsoft.AspNetCore.HttpOverrides; +using Microsoft.OpenApi.Models; using Prometheus; namespace DysonNetwork.Develop.Startup; @@ -14,9 +15,6 @@ public static class ApplicationConfiguration app.MapMetrics(); app.MapOpenApi(); - app.UseSwagger(); - app.UseSwaggerUI(); - app.UseRequestLocalization(); app.ConfigureForwardedHeaders(configuration); diff --git a/DysonNetwork.Develop/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Develop/Startup/ServiceCollectionExtensions.cs index 0ce5715..3ae8b0f 100644 --- a/DysonNetwork.Develop/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Develop/Startup/ServiceCollectionExtensions.cs @@ -57,23 +57,7 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddAppAuthentication(this IServiceCollection services) { - services.AddCors(); services.AddAuthorization(); return services; } - - public static IServiceCollection AddAppSwagger(this IServiceCollection services) - { - services.AddEndpointsApiExplorer(); - services.AddSwaggerGen(options => - { - options.SwaggerDoc("v1", new OpenApiInfo - { - Version = "v1", - Title = "Develop API", - }); - }); - services.AddOpenApi(); - return services; - } } diff --git a/DysonNetwork.Develop/appsettings.json b/DysonNetwork.Develop/appsettings.json index b81e2d8..6863c3d 100644 --- a/DysonNetwork.Develop/appsettings.json +++ b/DysonNetwork.Develop/appsettings.json @@ -16,6 +16,9 @@ "127.0.0.1", "::1" ], + "Swagger": { + "PublicBasePath": "/develop" + }, "Etcd": { "Insecure": true }, diff --git a/DysonNetwork.Drive/DysonNetwork.Drive.csproj b/DysonNetwork.Drive/DysonNetwork.Drive.csproj index 8a03ea2..8d231a7 100644 --- a/DysonNetwork.Drive/DysonNetwork.Drive.csproj +++ b/DysonNetwork.Drive/DysonNetwork.Drive.csproj @@ -56,8 +56,8 @@ - - + + diff --git a/DysonNetwork.Drive/Program.cs b/DysonNetwork.Drive/Program.cs index 62204f9..7ffba7f 100644 --- a/DysonNetwork.Drive/Program.cs +++ b/DysonNetwork.Drive/Program.cs @@ -18,21 +18,20 @@ builder.ConfigureAppKestrel(builder.Configuration, maxRequestBodySize: long.MaxV builder.Services.AddAppServices(builder.Configuration); builder.Services.AddAppRateLimiting(); builder.Services.AddAppAuthentication(); -builder.Services.AddAppSwagger(); builder.Services.AddDysonAuth(); builder.Services.AddAccountService(); builder.Services.AddAppFileStorage(builder.Configuration); -// Add flush handlers and websocket handlers builder.Services.AddAppFlushHandlers(); - -// Add business services builder.Services.AddAppBusinessServices(); - -// Add scheduled jobs builder.Services.AddAppScheduledJobs(); +builder.AddSwaggerManifest( + "DysonNetwork.Drive", + "The file upload and storage service in the Solar Network." +); + var app = builder.Build(); app.MapDefaultEndpoints(); @@ -50,4 +49,6 @@ app.ConfigureAppMiddleware(tusDiskStore); // Configure gRPC app.ConfigureGrpcServices(); +app.UseSwaggerManifest(); + app.Run(); diff --git a/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs b/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs index 9b7733d..b343ddb 100644 --- a/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs +++ b/DysonNetwork.Drive/Startup/ApplicationBuilderExtensions.cs @@ -8,10 +8,6 @@ public static class ApplicationBuilderExtensions { public static WebApplication ConfigureAppMiddleware(this WebApplication app, ITusStore tusStore) { - // Configure the HTTP request pipeline. - app.UseSwagger(); - app.UseSwaggerUI(); - app.UseAuthorization(); app.MapControllers(); diff --git a/DysonNetwork.Drive/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Drive/Startup/ServiceCollectionExtensions.cs index 66e7369..25f9430 100644 --- a/DysonNetwork.Drive/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Drive/Startup/ServiceCollectionExtensions.cs @@ -61,9 +61,7 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddAppAuthentication(this IServiceCollection services) { - services.AddCors(); services.AddAuthorization(); - return services; } @@ -74,52 +72,6 @@ public static class ServiceCollectionExtensions return services; } - public static IServiceCollection AddAppSwagger(this IServiceCollection services) - { - services.AddEndpointsApiExplorer(); - services.AddSwaggerGen(options => - { - options.SwaggerDoc("v1", new OpenApiInfo - { - Version = "v1", - Title = "Dyson Drive", - Description = - "The file service of the Dyson Network. Mainly handling file storage and sharing. Also provide image processing and media analysis. Powered the Solar Network Drive as well.", - TermsOfService = new Uri("https://solsynth.dev/terms"), // Update with actual terms - License = new OpenApiLicense - { - Name = "APGLv3", // Update with actual license - Url = new Uri("https://www.gnu.org/licenses/agpl-3.0.html") - } - }); - options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme - { - In = ParameterLocation.Header, - Description = "Please enter a valid token", - Name = "Authorization", - Type = SecuritySchemeType.Http, - BearerFormat = "JWT", - Scheme = "Bearer" - }); - options.AddSecurityRequirement(new OpenApiSecurityRequirement - { - { - new OpenApiSecurityScheme - { - Reference = new OpenApiReference - { - Type = ReferenceType.SecurityScheme, - Id = "Bearer" - } - }, - [] - } - }); - }); - - return services; - } - public static IServiceCollection AddAppFileStorage(this IServiceCollection services, IConfiguration configuration) { var tusStorePath = configuration.GetSection("Tus").GetValue("StorePath")!; diff --git a/DysonNetwork.Drive/appsettings.json b/DysonNetwork.Drive/appsettings.json index 3a1f32b..b63b4eb 100644 --- a/DysonNetwork.Drive/appsettings.json +++ b/DysonNetwork.Drive/appsettings.json @@ -27,15 +27,6 @@ "PublicKeyPath": "Keys/PublicKey.pem", "PrivateKeyPath": "Keys/PrivateKey.pem" }, - "OidcProvider": { - "IssuerUri": "https://nt.solian.app", - "PublicKeyPath": "Keys/PublicKey.pem", - "PrivateKeyPath": "Keys/PrivateKey.pem", - "AccessTokenLifetime": "01:00:00", - "RefreshTokenLifetime": "30.00:00:00", - "AuthorizationCodeLifetime": "00:30:00", - "RequireHttpsMetadata": true - }, "Tus": { "StorePath": "Uploads" }, diff --git a/DysonNetwork.Pass/DysonNetwork.Pass.csproj b/DysonNetwork.Pass/DysonNetwork.Pass.csproj index 2bb67fb..8f4ef30 100644 --- a/DysonNetwork.Pass/DysonNetwork.Pass.csproj +++ b/DysonNetwork.Pass/DysonNetwork.Pass.csproj @@ -44,8 +44,8 @@ - - + + diff --git a/DysonNetwork.Pass/Program.cs b/DysonNetwork.Pass/Program.cs index 1c56847..300fec2 100644 --- a/DysonNetwork.Pass/Program.cs +++ b/DysonNetwork.Pass/Program.cs @@ -15,20 +15,19 @@ builder.ConfigureAppKestrel(builder.Configuration); builder.Services.AddAppServices(builder.Configuration); builder.Services.AddAppRateLimiting(); builder.Services.AddAppAuthentication(); -builder.Services.AddAppSwagger(); builder.Services.AddRingService(); builder.Services.AddDriveService(); builder.Services.AddDevelopService(); -// Add flush handlers and websocket handlers builder.Services.AddAppFlushHandlers(); - -// Add business services builder.Services.AddAppBusinessServices(builder.Configuration); - -// Add scheduled jobs builder.Services.AddAppScheduledJobs(); +builder.AddSwaggerManifest( + "DysonNetwork.Pass", + "The authentication and authorization service in the Solar Network." +); + var app = builder.Build(); app.MapDefaultEndpoints(); @@ -46,4 +45,6 @@ app.ConfigureAppMiddleware(builder.Configuration); // Configure gRPC app.ConfigureGrpcServices(); -app.Run(); +app.UseSwaggerManifest(); + +app.Run(); \ No newline at end of file diff --git a/DysonNetwork.Pass/Startup/ApplicationConfiguration.cs b/DysonNetwork.Pass/Startup/ApplicationConfiguration.cs index 2958e3b..668e1f7 100644 --- a/DysonNetwork.Pass/Startup/ApplicationConfiguration.cs +++ b/DysonNetwork.Pass/Startup/ApplicationConfiguration.cs @@ -16,9 +16,6 @@ public static class ApplicationConfiguration app.MapMetrics(); app.MapOpenApi(); - app.UseSwagger(); - app.UseSwaggerUI(); - app.UseRequestLocalization(); app.ConfigureForwardedHeaders(configuration); diff --git a/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs index f29a0cf..e84b0d2 100644 --- a/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Pass/Startup/ServiceCollectionExtensions.cs @@ -108,7 +108,6 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddAppAuthentication(this IServiceCollection services) { - services.AddCors(); services.AddAuthorization(); services.AddAuthentication(options => { @@ -120,53 +119,6 @@ public static class ServiceCollectionExtensions return services; } - public static IServiceCollection AddAppSwagger(this IServiceCollection services) - { - services.AddEndpointsApiExplorer(); - services.AddSwaggerGen(options => - { - options.SwaggerDoc("v1", new OpenApiInfo - { - Version = "v1", - Title = "Dyson Pass", - Description = - "The authentication service of the Dyson Network. Mainly handling authentication and authorization.", - TermsOfService = new Uri("https://solsynth.dev/terms"), - License = new OpenApiLicense - { - Name = "APGLv3", - Url = new Uri("https://www.gnu.org/licenses/agpl-3.0.html") - } - }); - options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme - { - In = ParameterLocation.Header, - Description = "Please enter a valid token", - Name = "Authorization", - Type = SecuritySchemeType.Http, - BearerFormat = "JWT", - Scheme = "Bearer" - }); - options.AddSecurityRequirement(new OpenApiSecurityRequirement - { - { - new OpenApiSecurityScheme - { - Reference = new OpenApiReference - { - Type = ReferenceType.SecurityScheme, - Id = "Bearer" - } - }, - [] - } - }); - }); - services.AddOpenApi(); - - return services; - } - public static IServiceCollection AddAppFlushHandlers(this IServiceCollection services) { services.AddSingleton(); diff --git a/DysonNetwork.Ring/DysonNetwork.Ring.csproj b/DysonNetwork.Ring/DysonNetwork.Ring.csproj index 09a50ce..50b63a1 100644 --- a/DysonNetwork.Ring/DysonNetwork.Ring.csproj +++ b/DysonNetwork.Ring/DysonNetwork.Ring.csproj @@ -31,8 +31,8 @@ - - + + diff --git a/DysonNetwork.Ring/Program.cs b/DysonNetwork.Ring/Program.cs index eda4ae7..fe32742 100644 --- a/DysonNetwork.Ring/Program.cs +++ b/DysonNetwork.Ring/Program.cs @@ -16,19 +16,18 @@ builder.ConfigureAppKestrel(builder.Configuration); builder.Services.AddAppServices(builder.Configuration); builder.Services.AddAppRateLimiting(); builder.Services.AddAppAuthentication(); -builder.Services.AddAppSwagger(); builder.Services.AddDysonAuth(); builder.Services.AddAccountService(); -// Add flush handlers and websocket handlers builder.Services.AddAppFlushHandlers(); - -// Add business services builder.Services.AddAppBusinessServices(); - -// Add scheduled jobs builder.Services.AddAppScheduledJobs(); +builder.AddSwaggerManifest( + "DysonNetwork.Ring", + "The realtime service in the Solar Network." +); + var app = builder.Build(); app.MapDefaultEndpoints(); @@ -46,4 +45,6 @@ app.ConfigureAppMiddleware(builder.Configuration); // Configure gRPC app.ConfigureGrpcServices(); +app.UseSwaggerManifest(); + app.Run(); diff --git a/DysonNetwork.Ring/Startup/ApplicationConfiguration.cs b/DysonNetwork.Ring/Startup/ApplicationConfiguration.cs index 166ed7c..d6ecd6e 100644 --- a/DysonNetwork.Ring/Startup/ApplicationConfiguration.cs +++ b/DysonNetwork.Ring/Startup/ApplicationConfiguration.cs @@ -1,7 +1,5 @@ -using System.Net; using DysonNetwork.Ring.Services; using DysonNetwork.Shared.Http; -using Microsoft.AspNetCore.HttpOverrides; namespace DysonNetwork.Ring.Startup; @@ -9,11 +7,6 @@ public static class ApplicationConfiguration { public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration) { - app.MapOpenApi(); - - app.UseSwagger(); - app.UseSwaggerUI(); - app.UseRequestLocalization(); app.ConfigureForwardedHeaders(configuration); diff --git a/DysonNetwork.Ring/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Ring/Startup/ServiceCollectionExtensions.cs index 0480fcd..cefe754 100644 --- a/DysonNetwork.Ring/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Ring/Startup/ServiceCollectionExtensions.cs @@ -9,7 +9,6 @@ using DysonNetwork.Ring.Notification; using DysonNetwork.Ring.Services; using DysonNetwork.Shared.Cache; using Microsoft.AspNetCore.RateLimiting; -using Microsoft.OpenApi.Models; using NodaTime; using NodaTime.Serialization.SystemTextJson; using StackExchange.Redis; @@ -69,55 +68,7 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddAppAuthentication(this IServiceCollection services) { - services.AddCors(); services.AddAuthorization(); - - return services; - } - - public static IServiceCollection AddAppSwagger(this IServiceCollection services) - { - services.AddEndpointsApiExplorer(); - services.AddSwaggerGen(options => - { - options.SwaggerDoc("v1", new OpenApiInfo - { - Version = "v1", - Title = "Dyson Ring", - Description = "The pusher service of the Dyson Network. Mainly handling emailing, notifications and websockets.", - TermsOfService = new Uri("https://solsynth.dev/terms"), - License = new OpenApiLicense - { - Name = "APGLv3", - Url = new Uri("https://www.gnu.org/licenses/agpl-3.0.html") - } - }); - options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme - { - In = ParameterLocation.Header, - Description = "Please enter a valid token", - Name = "Authorization", - Type = SecuritySchemeType.Http, - BearerFormat = "JWT", - Scheme = "Bearer" - }); - options.AddSecurityRequirement(new OpenApiSecurityRequirement - { - { - new OpenApiSecurityScheme - { - Reference = new OpenApiReference - { - Type = ReferenceType.SecurityScheme, - Id = "Bearer" - } - }, - [] - } - }); - }); - services.AddOpenApi(); - return services; } diff --git a/DysonNetwork.Shared/DysonNetwork.Shared.csproj b/DysonNetwork.Shared/DysonNetwork.Shared.csproj index a79c88a..6b0aca0 100644 --- a/DysonNetwork.Shared/DysonNetwork.Shared.csproj +++ b/DysonNetwork.Shared/DysonNetwork.Shared.csproj @@ -27,6 +27,8 @@ + + diff --git a/DysonNetwork.Shared/Http/SwaggerGen.cs b/DysonNetwork.Shared/Http/SwaggerGen.cs new file mode 100644 index 0000000..4d6bff7 --- /dev/null +++ b/DysonNetwork.Shared/Http/SwaggerGen.cs @@ -0,0 +1,117 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; + +namespace DysonNetwork.Shared.Http; + +public static class SwaggerGen +{ + public static WebApplicationBuilder AddSwaggerManifest( + this WebApplicationBuilder builder, + string serviceName, + string? serviceDescription + ) + { + builder.Services.AddEndpointsApiExplorer(); + builder.Services.AddSwaggerGen(options => + { + options.SwaggerDoc("v1", new OpenApiInfo + { + Version = "v1", + Title = serviceName, + Description = serviceDescription, + TermsOfService = new Uri("https://solsynth.dev/terms"), + License = new OpenApiLicense + { + Name = "APGLv3", + Url = new Uri("https://www.gnu.org/licenses/agpl-3.0.html") + } + }); + options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme + { + In = ParameterLocation.Header, + Description = "Solar Network Unified Authentication", + Name = "Authorization", + Type = SecuritySchemeType.Http, + BearerFormat = "JWT", + Scheme = "Bearer" + }); + options.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "Bearer" + } + }, + [] + } + }); + }); + builder.Services.AddOpenApi(); + + return builder; + } + + public static WebApplication UseSwaggerManifest(this WebApplication app) + { + app.MapOpenApi(); + + var configuration = app.Configuration; + app.UseSwagger(c => + { + c.PreSerializeFilters.Add((swaggerDoc, httpReq) => + { + var publicBasePath = configuration["Swagger:PublicBasePath"]?.TrimEnd('/') ?? ""; + + // 1. Adjust servers + swaggerDoc.Servers = new List + { + new() { Url = publicBasePath } + }; + + // 2. Rewrite all path keys (remove /api or replace it) + var newPaths = new OpenApiPaths(); + foreach (var (path, pathItem) in swaggerDoc.Paths) + { + // e.g. original path = "/api/drive/chunk/{taskId}/{chunkIndex}" + // We want to produce "/sphere/drive/chunk/{taskId}/{chunkIndex}" or maybe "/sphere/chunk/..." + var newPathKey = path; + + // If "path" starts with "/api", strip it + if (newPathKey.StartsWith("/api", StringComparison.OrdinalIgnoreCase)) + { + newPathKey = newPathKey["/api".Length..]; + if (!newPathKey.StartsWith("/")) + newPathKey = "/" + newPathKey; + } + + // Then prepend the public base path (if not root) + if (!string.IsNullOrEmpty(publicBasePath) && publicBasePath != "/") + { + // ensure slash composition + newPathKey = publicBasePath.TrimEnd('/') + newPathKey; + } + + newPaths.Add(newPathKey, pathItem); + } + + swaggerDoc.Paths = newPaths; + }); + }); + + app.UseSwaggerUI(options => + { + // Swagger UI must point to the JSON location + var publicBasePath = configuration["Swagger:PublicBasePath"]?.TrimEnd('/') ?? ""; + options.SwaggerEndpoint( + $"{publicBasePath}/swagger/v1/swagger.json", + "Develop API v1"); + }); + + return app; + } +} \ No newline at end of file diff --git a/DysonNetwork.Sphere/DysonNetwork.Sphere.csproj b/DysonNetwork.Sphere/DysonNetwork.Sphere.csproj index 984af69..af6a32b 100644 --- a/DysonNetwork.Sphere/DysonNetwork.Sphere.csproj +++ b/DysonNetwork.Sphere/DysonNetwork.Sphere.csproj @@ -56,9 +56,9 @@ - - - + + + diff --git a/DysonNetwork.Sphere/Program.cs b/DysonNetwork.Sphere/Program.cs index b7ddf7c..5ae7279 100644 --- a/DysonNetwork.Sphere/Program.cs +++ b/DysonNetwork.Sphere/Program.cs @@ -17,21 +17,20 @@ builder.ConfigureAppKestrel(builder.Configuration); builder.Services.AddAppServices(builder.Configuration); builder.Services.AddAppRateLimiting(); builder.Services.AddAppAuthentication(); -builder.Services.AddAppSwagger(); builder.Services.AddDysonAuth(); builder.Services.AddAccountService(); builder.Services.AddRingService(); builder.Services.AddDriveService(); -// Add flush handlers and websocket handlers builder.Services.AddAppFlushHandlers(); - -// Add business services builder.Services.AddAppBusinessServices(builder.Configuration); - -// Add scheduled jobs builder.Services.AddAppScheduledJobs(); +builder.AddSwaggerManifest( + "DysonNetwork.Sphere", + "The social network service in the Solar Network." +); + var app = builder.Build(); app.MapDefaultEndpoints(); @@ -46,4 +45,6 @@ using (var scope = app.Services.CreateScope()) // Configure application middleware pipeline app.ConfigureAppMiddleware(builder.Configuration); -app.Run(); +app.UseSwaggerManifest(); + +app.Run(); \ No newline at end of file diff --git a/DysonNetwork.Sphere/Startup/ApplicationConfiguration.cs b/DysonNetwork.Sphere/Startup/ApplicationConfiguration.cs index 63ba5f3..121606d 100644 --- a/DysonNetwork.Sphere/Startup/ApplicationConfiguration.cs +++ b/DysonNetwork.Sphere/Startup/ApplicationConfiguration.cs @@ -1,7 +1,6 @@ using DysonNetwork.Shared.Auth; using DysonNetwork.Shared.Http; using DysonNetwork.Sphere.Publisher; -using Prometheus; namespace DysonNetwork.Sphere.Startup; @@ -9,12 +8,6 @@ public static class ApplicationConfiguration { public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration) { - app.MapMetrics(); - app.MapOpenApi(); - - app.UseSwagger(); - app.UseSwaggerUI(); - app.UseRequestLocalization(); app.ConfigureForwardedHeaders(configuration); diff --git a/DysonNetwork.Sphere/Startup/ServiceCollectionExtensions.cs b/DysonNetwork.Sphere/Startup/ServiceCollectionExtensions.cs index 7077a81..96f4004 100644 --- a/DysonNetwork.Sphere/Startup/ServiceCollectionExtensions.cs +++ b/DysonNetwork.Sphere/Startup/ServiceCollectionExtensions.cs @@ -90,55 +90,7 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddAppAuthentication(this IServiceCollection services) { - services.AddCors(); services.AddAuthorization(); - - return services; - } - - public static IServiceCollection AddAppSwagger(this IServiceCollection services) - { - services.AddEndpointsApiExplorer(); - services.AddSwaggerGen(options => - { - options.SwaggerDoc("v1", new OpenApiInfo - { - Version = "v1", - Title = "Solar Network API", - Description = "An open-source social network", - TermsOfService = new Uri("https://solsynth.dev/terms"), - License = new OpenApiLicense - { - Name = "APGLv3", - Url = new Uri("https://www.gnu.org/licenses/agpl-3.0.html") - } - }); - options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme - { - In = ParameterLocation.Header, - Description = "Please enter a valid token", - Name = "Authorization", - Type = SecuritySchemeType.Http, - BearerFormat = "JWT", - Scheme = "Bearer" - }); - options.AddSecurityRequirement(new OpenApiSecurityRequirement - { - { - new OpenApiSecurityScheme - { - Reference = new OpenApiReference - { - Type = ReferenceType.SecurityScheme, - Id = "Bearer" - } - }, - [] - } - }); - }); - services.AddOpenApi(); - return services; } diff --git a/DysonNetwork.sln.DotSettings.user b/DysonNetwork.sln.DotSettings.user index 90d3763..7a6ea48 100644 --- a/DysonNetwork.sln.DotSettings.user +++ b/DysonNetwork.sln.DotSettings.user @@ -114,6 +114,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded