67 lines
2.3 KiB
C#
67 lines
2.3 KiB
C#
using Microsoft.AspNetCore.Authentication.Negotiate;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.SelfService.Portal.Core.API.Context;
|
|
using Microsoft.SelfService.Portal.Core.API.Events;
|
|
using Microsoft.SelfService.Portal.Core.API.Events.Interfaces;
|
|
using Microsoft.SelfService.Portal.Core.API.Interfaces;
|
|
using Microsoft.SelfService.Portal.Core.API.Repository;
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers().AddJsonOptions(options =>
|
|
{
|
|
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
|
|
});
|
|
|
|
builder.Services.AddScoped<IEventHandlerInterface, AbstractEventHandler>();
|
|
|
|
builder.Services.AddScoped<IDomainInterface,DomainRepository>();
|
|
builder.Services.AddScoped<IEnvironmentInterface, EnvironmentRepository>();
|
|
builder.Services.AddScoped<IVirtualMachineInterface, VirtualMachineRepository>();
|
|
builder.Services.AddScoped<IServiceInterface, ServiceRepository>();
|
|
builder.Services.AddScoped<IRunbookInterface, RunbookRepository>();
|
|
builder.Services.AddScoped<IDeploymentGroupInterface, DeploymentGroupRepository>();
|
|
builder.Services.AddScoped<IDeploymentInterface, DeploymentRepository>();
|
|
builder.Services.AddScoped<ITemplateInterface, TemplateRepository>();
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
|
|
|
builder.Services.AddDbContext<DataContext>(options =>
|
|
options.UseSqlServer(builder.Configuration.GetConnectionString("Context") ?? throw new InvalidOperationException("Connection string 'Context' not found.")));
|
|
|
|
builder.Services.AddAuthentication(NegotiateDefaults.AuthenticationScheme)
|
|
.AddNegotiate();
|
|
|
|
builder.Services.AddHttpContextAccessor();
|
|
|
|
builder.Services.AddAuthorization(options =>
|
|
{
|
|
// By default, all incoming requests will be authorized according to the default policy.
|
|
options.FallbackPolicy = options.DefaultPolicy;
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
//{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
//}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|