it ipimiutduioi

This commit is contained in:
MarcEricMartel
2022-10-30 13:58:47 -07:00
parent 8a5b00624e
commit a8bf691e21
13 changed files with 892 additions and 75 deletions

View File

@@ -1,6 +1,12 @@
using GrossesMitainesAPI.Data;
using GrossesMitainesAPI.Services;
using Microsoft.AspNet.Identity;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System.Net;
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
var builder = WebApplication.CreateBuilder(args);
@@ -17,6 +23,13 @@ builder.Services.AddCors(options => {
});
builder.Services.AddControllers();
builder.Services.AddAuthentication("Cookies").AddIdentityCookies();
builder.Services.AddIdentityCore<InventoryUser>()
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<InventoryContext>()
.AddSignInManager();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
@@ -25,6 +38,9 @@ builder.Services.AddDbContextFactory<InventoryContext>(options => { options.UseS
builder.Services.AddSingleton<DatabaseCacheService>();
builder.Services.BuildServiceProvider().GetRequiredService<DatabaseCacheService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
@@ -38,6 +54,7 @@ app.UseHttpsRedirection();
app.UseCors(MyAllowSpecificOrigins);
app.UseAuthorization();
app.UseAuthentication();
app.MapControllers();