diff --git a/HR.LeaveManagement.API/HR.LeaveManagement.API.csproj b/HR.LeaveManagement.API/HR.LeaveManagement.API.csproj index 3954bcb..fc3ad8e 100644 --- a/HR.LeaveManagement.API/HR.LeaveManagement.API.csproj +++ b/HR.LeaveManagement.API/HR.LeaveManagement.API.csproj @@ -7,11 +7,14 @@ + all runtime; build; native; contentfiles; analyzers; buildtransitive + + @@ -19,6 +22,7 @@ + diff --git a/HR.LeaveManagement.API/Program.cs b/HR.LeaveManagement.API/Program.cs index 138c2ee..2b93d3b 100644 --- a/HR.LeaveManagement.API/Program.cs +++ b/HR.LeaveManagement.API/Program.cs @@ -4,8 +4,12 @@ using HR.LeaveManagement.Infrastructure; using HR.LeaveManagement.Persistence; +using Microsoft.OpenApi.Models; + using Serilog; +using Swashbuckle.AspNetCore.Filters; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. @@ -31,8 +35,17 @@ // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); - +builder.Services.AddSwaggerGen(c => +{ + c.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme + { + Description = """Standard Authorization header using the Bearer scheme. Example: "bearer {token}" """, + In = ParameterLocation.Header, + Name = "Authorization", + Type = SecuritySchemeType.ApiKey + }); + c.OperationFilter(); +}); var app = builder.Build(); app.UseMiddleware(); diff --git a/HR.LeaveManagement.API/appsettings.json b/HR.LeaveManagement.API/appsettings.json index d2db756..d37a137 100644 --- a/HR.LeaveManagement.API/appsettings.json +++ b/HR.LeaveManagement.API/appsettings.json @@ -14,7 +14,7 @@ "FromName": "HR Management System" }, "JwtSettings": { - "Key": "SECRET_JWT_KEY_HERE", + "Key": "this is my custom Secret key for authentication", "Issuer": "HRLeavemanagement.Api", "Audience": "HRLeavemanagementUser", "DurationInMinutes": 15