Initial endpoint configuration with authentication
This commit is contained in:
31
src/WebApi/Authentication/JwtOptions.cs
Normal file
31
src/WebApi/Authentication/JwtOptions.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace Vegasco.WebApi.Authentication;
|
||||
|
||||
public class JwtOptions
|
||||
{
|
||||
public const string SectionName = "JWT";
|
||||
|
||||
public string Audience { get; set; } = "";
|
||||
|
||||
public string Authority { get; set; } = "";
|
||||
|
||||
public string Issuer { get; set; } = "";
|
||||
|
||||
public string? NameClaimType { get; set; }
|
||||
}
|
||||
|
||||
public class JwtOptionsValidator : AbstractValidator<JwtOptions>
|
||||
{
|
||||
public JwtOptionsValidator()
|
||||
{
|
||||
RuleFor(x => x.Audience)
|
||||
.NotEmpty();
|
||||
|
||||
RuleFor(x => x.Authority)
|
||||
.NotEmpty();
|
||||
|
||||
RuleFor(x => x.Issuer)
|
||||
.NotEmpty();
|
||||
}
|
||||
}
|
||||
10
src/WebApi/Cars/Car.cs
Normal file
10
src/WebApi/Cars/Car.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Vegasco.WebApi.Cars;
|
||||
|
||||
public class Car
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
public Guid UserId { get; set; }
|
||||
}
|
||||
38
src/WebApi/Cars/CreateCar.cs
Normal file
38
src/WebApi/Cars/CreateCar.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using FluentValidation;
|
||||
using FluentValidation.Results;
|
||||
using Vegasco.WebApi.Common;
|
||||
|
||||
namespace Vegasco.WebApi.Cars;
|
||||
|
||||
public static class CreateCar
|
||||
{
|
||||
public record Request(string Name);
|
||||
public record Response(Guid Id, string Name);
|
||||
|
||||
public static RouteHandlerBuilder MapEndpoint(IEndpointRouteBuilder builder)
|
||||
{
|
||||
return builder
|
||||
.MapPost("cars", Handler)
|
||||
.WithTags("Cars");
|
||||
}
|
||||
|
||||
public class Validator : AbstractValidator<Request>
|
||||
{
|
||||
public Validator()
|
||||
{
|
||||
RuleFor(x => x.Name)
|
||||
.NotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<IResult> Handler(Request request, IEnumerable<IValidator<Request>> validators)
|
||||
{
|
||||
List<ValidationResult> failedValidations = await validators.ValidateAllAsync(request);
|
||||
if (failedValidations.Count > 0)
|
||||
{
|
||||
return Results.BadRequest(new HttpValidationProblemDetails(failedValidations.ToCombinedDictionary()));
|
||||
}
|
||||
|
||||
return Results.Ok();
|
||||
}
|
||||
}
|
||||
11
src/WebApi/Common/Constants.cs
Normal file
11
src/WebApi/Common/Constants.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Vegasco.WebApi.Common;
|
||||
|
||||
public static class Constants
|
||||
{
|
||||
public const string AppOtelName = "Vegasco.Api";
|
||||
|
||||
public static class Authorization
|
||||
{
|
||||
public const string RequireAuthenticatedUserPolicy = "RequireAuthenticatedUser";
|
||||
}
|
||||
}
|
||||
124
src/WebApi/Common/DependencyInjectionExtensions.cs
Normal file
124
src/WebApi/Common/DependencyInjectionExtensions.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using Asp.Versioning;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.Extensions.Options;
|
||||
using OpenTelemetry.Trace;
|
||||
using System.Diagnostics;
|
||||
using Vegasco.WebApi.Authentication;
|
||||
using Vegasco.WebApi.Endpoints;
|
||||
using Vegasco.WebApi.Endpoints.OpenApi;
|
||||
|
||||
namespace Vegasco.WebApi.Common;
|
||||
|
||||
public static class DependencyInjectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds all the WebApi related services to the Dependency Injection container.
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
public static void AddWebApiServices(this IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddMiscellaneousServices()
|
||||
.AddOpenApi()
|
||||
.AddApiVersioning()
|
||||
.AddOtel()
|
||||
.AddAuthenticationAndAuthorization();
|
||||
}
|
||||
|
||||
private static IServiceCollection AddMiscellaneousServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddResponseCompression();
|
||||
|
||||
services.AddValidatorsFromAssemblies(
|
||||
[
|
||||
typeof(IWebApiMarker).Assembly
|
||||
], ServiceLifetime.Singleton);
|
||||
|
||||
services.AddHealthChecks();
|
||||
services.AddEndpointsFromAssemblyContaining<IWebApiMarker>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddOpenApi(this IServiceCollection services)
|
||||
{
|
||||
services.ConfigureOptions<ConfigureSwaggerGenOptions>();
|
||||
|
||||
services.AddEndpointsApiExplorer();
|
||||
services.AddSwaggerGen();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddApiVersioning(this IServiceCollection services)
|
||||
{
|
||||
services.AddApiVersioning(o =>
|
||||
{
|
||||
o.DefaultApiVersion = new ApiVersion(1);
|
||||
o.ApiVersionReader = new UrlSegmentApiVersionReader();
|
||||
o.ReportApiVersions = true;
|
||||
})
|
||||
.AddApiExplorer(o =>
|
||||
{
|
||||
o.GroupNameFormat = "'v'V";
|
||||
o.SubstituteApiVersionInUrl = true;
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddOtel(this IServiceCollection services)
|
||||
{
|
||||
Activity.DefaultIdFormat = ActivityIdFormat.W3C;
|
||||
|
||||
ActivitySource activitySource = new(Constants.AppOtelName);
|
||||
services.AddSingleton(activitySource);
|
||||
|
||||
services.AddOpenTelemetry()
|
||||
.WithTracing(t =>
|
||||
{
|
||||
t.AddAspNetCoreInstrumentation()
|
||||
.AddHttpClientInstrumentation()
|
||||
.AddOtlpExporter()
|
||||
.AddSource(activitySource.Name);
|
||||
})
|
||||
.WithMetrics();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddAuthenticationAndAuthorization(this IServiceCollection services)
|
||||
{
|
||||
services.AddOptions<JwtOptions>()
|
||||
.BindConfiguration(JwtOptions.SectionName)
|
||||
.ValidateFluently()
|
||||
.ValidateOnStart();
|
||||
|
||||
var jwtOptions = services.BuildServiceProvider().GetRequiredService<IOptions<JwtOptions>>();
|
||||
|
||||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, o =>
|
||||
{
|
||||
o.Authority = jwtOptions.Value.Authority;
|
||||
|
||||
o.TokenValidationParameters.ValidAudience = jwtOptions.Value.Audience;
|
||||
o.TokenValidationParameters.ValidateAudience = true;
|
||||
|
||||
o.TokenValidationParameters.ValidIssuer = jwtOptions.Value.Issuer;
|
||||
o.TokenValidationParameters.ValidateIssuer = true;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(jwtOptions.Value.NameClaimType))
|
||||
{
|
||||
o.TokenValidationParameters.NameClaimType = jwtOptions.Value.NameClaimType;
|
||||
}
|
||||
});
|
||||
|
||||
services.AddAuthorizationBuilder()
|
||||
.AddPolicy(Constants.Authorization.RequireAuthenticatedUserPolicy, p => p
|
||||
.RequireAuthenticatedUser()
|
||||
.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme));
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
3
src/WebApi/Common/IWebApiMarker.cs
Normal file
3
src/WebApi/Common/IWebApiMarker.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace Vegasco.WebApi.Common;
|
||||
|
||||
public interface IWebApiMarker;
|
||||
62
src/WebApi/Common/StartupExtensions.cs
Normal file
62
src/WebApi/Common/StartupExtensions.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Asp.Versioning.ApiExplorer;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using System.Globalization;
|
||||
using Vegasco.WebApi.Endpoints;
|
||||
|
||||
namespace Vegasco.WebApi.Common;
|
||||
|
||||
internal static class StartupExtensions
|
||||
{
|
||||
internal static WebApplication ConfigureServices(this WebApplicationBuilder builder)
|
||||
{
|
||||
builder.Configuration.AddEnvironmentVariables("Vegasco_");
|
||||
|
||||
builder.Services.AddWebApiServices();
|
||||
|
||||
WebApplication app = builder.Build();
|
||||
return app;
|
||||
}
|
||||
|
||||
internal static WebApplication ConfigureRequestPipeline(this WebApplication app)
|
||||
{
|
||||
app.UseRequestLocalization(o =>
|
||||
{
|
||||
o.SupportedCultures =
|
||||
[
|
||||
new CultureInfo("en")
|
||||
];
|
||||
|
||||
o.SupportedUICultures = o.SupportedCultures;
|
||||
|
||||
CultureInfo defaultCulture = o.SupportedCultures[0];
|
||||
o.DefaultRequestCulture = new RequestCulture(defaultCulture);
|
||||
});
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.MapHealthChecks("/health");
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapEndpoints();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(o =>
|
||||
{
|
||||
// Create a Swagger endpoint for each API version
|
||||
IReadOnlyList<ApiVersionDescription> apiVersions = app.DescribeApiVersions();
|
||||
foreach (ApiVersionDescription apiVersionDescription in apiVersions)
|
||||
{
|
||||
string url = $"/swagger/{apiVersionDescription.GroupName}/swagger.json";
|
||||
string name = apiVersionDescription.GroupName.ToUpperInvariant();
|
||||
o.SwaggerEndpoint(url, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
||||
94
src/WebApi/Common/ValidatorExtensions.cs
Normal file
94
src/WebApi/Common/ValidatorExtensions.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using FluentValidation;
|
||||
using FluentValidation.Results;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Vegasco.WebApi.Common;
|
||||
|
||||
public static class ValidatorExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Asynchronously validates an instance of <typeparamref name="T"/> against all <see cref="IValidator{T}"/> instances in <paramref name="validators"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="validators"></param>
|
||||
/// <param name="instance"></param>
|
||||
/// <returns>The failed validation results.</returns>
|
||||
public static async Task<List<ValidationResult>> ValidateAllAsync<T>(this IEnumerable<IValidator<T>> validators, T instance)
|
||||
{
|
||||
var validationTasks = validators
|
||||
.Select(validator => validator.ValidateAsync(instance))
|
||||
.ToList();
|
||||
|
||||
await Task.WhenAll(validationTasks);
|
||||
|
||||
List<ValidationResult> failedValidations = validationTasks
|
||||
.Select(x => x.Result)
|
||||
.Where(x => !x.IsValid)
|
||||
.ToList();
|
||||
|
||||
return failedValidations;
|
||||
}
|
||||
|
||||
public static Dictionary<string, string[]> ToCombinedDictionary(this IEnumerable<ValidationResult> validationResults)
|
||||
{
|
||||
// Use a hash set to avoid duplicate error messages.
|
||||
Dictionary<string, HashSet<string>> combinedErrors = [];
|
||||
|
||||
foreach (var error in validationResults.SelectMany(x => x.Errors))
|
||||
{
|
||||
if (!combinedErrors.TryGetValue(error.PropertyName, out HashSet<string>? value))
|
||||
{
|
||||
value = ([error.ErrorMessage]);
|
||||
combinedErrors[error.PropertyName] = value;
|
||||
continue;
|
||||
}
|
||||
|
||||
value.Add(error.ErrorMessage);
|
||||
}
|
||||
|
||||
return combinedErrors.ToDictionary(x => x.Key, x => x.Value.ToArray());
|
||||
}
|
||||
|
||||
public static OptionsBuilder<T> ValidateFluently<T>(this OptionsBuilder<T> builder)
|
||||
where T : class
|
||||
{
|
||||
builder.Services.AddTransient<IValidateOptions<T>>(serviceProvider =>
|
||||
{
|
||||
var validators = serviceProvider.GetServices<IValidator<T>>() ?? [];
|
||||
return new FluentValidationOptions<T>(builder.Name, validators);
|
||||
});
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
internal class FluentValidationOptions<TOptions> : IValidateOptions<TOptions>
|
||||
where TOptions : class
|
||||
{
|
||||
private readonly IEnumerable<IValidator<TOptions>> _validators;
|
||||
|
||||
public string? Name { get; set; }
|
||||
|
||||
public FluentValidationOptions(string? name, IEnumerable<IValidator<TOptions>> validators)
|
||||
{
|
||||
Name = name;
|
||||
_validators = validators;
|
||||
}
|
||||
|
||||
public ValidateOptionsResult Validate(string? name, TOptions options)
|
||||
{
|
||||
if (name is not null && name != Name)
|
||||
{
|
||||
return ValidateOptionsResult.Skip;
|
||||
}
|
||||
|
||||
ArgumentNullException.ThrowIfNull(options);
|
||||
|
||||
var failedValidations = _validators.ValidateAllAsync(options).Result;
|
||||
if (failedValidations.Count == 0)
|
||||
{
|
||||
return ValidateOptionsResult.Success;
|
||||
}
|
||||
|
||||
return ValidateOptionsResult.Fail(failedValidations.SelectMany(x => x.Errors.Select(x => x.ErrorMessage)));
|
||||
}
|
||||
}
|
||||
25
src/WebApi/Dockerfile
Normal file
25
src/WebApi/Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
USER app
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 8081
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["src/Api/Api.csproj", "src/Api/"]
|
||||
RUN dotnet restore "./src/Api/Api.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/src/Api"
|
||||
RUN dotnet build "./Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "Api.dll"]
|
||||
39
src/WebApi/Endpoints/EndpointExtensions.cs
Normal file
39
src/WebApi/Endpoints/EndpointExtensions.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Asp.Versioning.Builder;
|
||||
using Asp.Versioning.Conventions;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Vegasco.WebApi.Cars;
|
||||
using Vegasco.WebApi.Common;
|
||||
|
||||
namespace Vegasco.WebApi.Endpoints;
|
||||
|
||||
public static class EndpointExtensions
|
||||
{
|
||||
public static IServiceCollection AddEndpointsFromAssemblyContaining<T>(this IServiceCollection services)
|
||||
{
|
||||
var assembly = typeof(T).Assembly;
|
||||
|
||||
ServiceDescriptor[] serviceDescriptors = assembly
|
||||
.DefinedTypes
|
||||
.Where(type => type is { IsAbstract: false, IsInterface: false } &&
|
||||
type.IsAssignableTo(typeof(IEndpoint)))
|
||||
.Select(type => ServiceDescriptor.Transient(typeof(IEndpoint), type))
|
||||
.ToArray();
|
||||
|
||||
services.TryAddEnumerable(serviceDescriptors);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static void MapEndpoints(this IEndpointRouteBuilder builder)
|
||||
{
|
||||
ApiVersionSet apiVersionSet = builder.NewApiVersionSet()
|
||||
.HasApiVersion(1.0)
|
||||
.Build();
|
||||
|
||||
RouteGroupBuilder versionedApis = builder.MapGroup("/v{apiVersion:apiVersion}")
|
||||
.WithApiVersionSet(apiVersionSet)
|
||||
.RequireAuthorization(Constants.Authorization.RequireAuthenticatedUserPolicy);
|
||||
|
||||
CreateCar.MapEndpoint(versionedApis);
|
||||
}
|
||||
}
|
||||
6
src/WebApi/Endpoints/IEndpoint.cs
Normal file
6
src/WebApi/Endpoints/IEndpoint.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Vegasco.WebApi.Endpoints;
|
||||
|
||||
public interface IEndpoint
|
||||
{
|
||||
void MapEndpoint(IEndpointRouteBuilder builder);
|
||||
}
|
||||
56
src/WebApi/Endpoints/OpenApi/ConfigureSwaggerGenOptions.cs
Normal file
56
src/WebApi/Endpoints/OpenApi/ConfigureSwaggerGenOptions.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Asp.Versioning.ApiExplorer;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace Vegasco.WebApi.Endpoints.OpenApi;
|
||||
|
||||
/// <summary>
|
||||
/// Registers each api version as its own swagger document.
|
||||
/// </summary>
|
||||
/// <param name="versionDescriptionProvider"></param>
|
||||
public class ConfigureSwaggerGenOptions(
|
||||
IApiVersionDescriptionProvider versionDescriptionProvider)
|
||||
: IConfigureNamedOptions<SwaggerGenOptions>
|
||||
{
|
||||
private readonly IApiVersionDescriptionProvider _versionDescriptionProvider = versionDescriptionProvider;
|
||||
|
||||
public void Configure(SwaggerGenOptions options)
|
||||
{
|
||||
foreach (ApiVersionDescription description in _versionDescriptionProvider.ApiVersionDescriptions)
|
||||
{
|
||||
OpenApiSecurityScheme securityScheme = new()
|
||||
{
|
||||
Name = "Bearer",
|
||||
In = ParameterLocation.Header,
|
||||
Type = SecuritySchemeType.Http,
|
||||
Scheme = "bearer",
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Id = IdentityConstants.BearerScheme,
|
||||
Type = ReferenceType.SecurityScheme
|
||||
}
|
||||
};
|
||||
options.AddSecurityDefinition(securityScheme.Reference.Id, securityScheme);
|
||||
|
||||
options.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{ securityScheme, Array.Empty<string>() }
|
||||
});
|
||||
|
||||
OpenApiInfo openApiInfo = new()
|
||||
{
|
||||
Title = "Vegasco API",
|
||||
Version = description.ApiVersion.ToString()
|
||||
};
|
||||
|
||||
options.SwaggerDoc(description.GroupName, openApiInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public void Configure(string? name, SwaggerGenOptions options)
|
||||
{
|
||||
Configure(options);
|
||||
}
|
||||
}
|
||||
6
src/WebApi/Endpoints/OpenApi/SwaggerDocConstants.cs
Normal file
6
src/WebApi/Endpoints/OpenApi/SwaggerDocConstants.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Vegasco.WebApi.Endpoints.OpenApi;
|
||||
|
||||
public static class SwaggerDocConstants
|
||||
{
|
||||
|
||||
}
|
||||
6
src/WebApi/Program.cs
Normal file
6
src/WebApi/Program.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using Vegasco.WebApi.Common;
|
||||
|
||||
WebApplication.CreateBuilder(args)
|
||||
.ConfigureServices()
|
||||
.ConfigureRequestPipeline()
|
||||
.Run();
|
||||
52
src/WebApi/Properties/launchSettings.json
Normal file
52
src/WebApi/Properties/launchSettings.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:5076"
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://localhost:7098;http://localhost:5076"
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Container (Dockerfile)": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_HTTPS_PORTS": "8081",
|
||||
"ASPNETCORE_HTTP_PORTS": "8080"
|
||||
},
|
||||
"publishAllPorts": true,
|
||||
"useSSL": true
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:22111",
|
||||
"sslPort": 44373
|
||||
}
|
||||
}
|
||||
}
|
||||
28
src/WebApi/WebApi.csproj
Normal file
28
src/WebApi/WebApi.csproj
Normal file
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>4bf893d3-0c16-41ec-8b46-2768d841215d</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>..\..</DockerfileContext>
|
||||
<RootNamespace>Vegasco.WebApi</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Asp.Versioning.Http" Version="8.1.0" />
|
||||
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.7" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||
<PackageReference Include="OpenTelemetry" Version="1.9.0" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
8
src/WebApi/appsettings.Development.json
Normal file
8
src/WebApi/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
src/WebApi/appsettings.json
Normal file
9
src/WebApi/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user