Cookie Auth working

This commit is contained in:
CodeLiturgy 2022-09-10 06:05:24 +01:00
parent 015a7396ad
commit 9dc878c517
5 changed files with 14 additions and 9 deletions

View File

@ -96,6 +96,9 @@ namespace BlueWest.WebApi.EF.Model
private static ModelBuilder CurrencyModel(this ModelBuilder modelBuilder) private static ModelBuilder CurrencyModel(this ModelBuilder modelBuilder)
{ {
modelBuilder.Entity<Currency>().ToTable("Currencies");
modelBuilder.Entity<Country>().ToTable("Countries");
modelBuilder modelBuilder
.Entity<Currency>() .Entity<Currency>()
.HasMany(ub => ub.Countries) .HasMany(ub => ub.Countries)

View File

@ -53,13 +53,13 @@ namespace BlueWest.WebApi
.UseContentRoot(Directory.GetCurrentDirectory()) .UseContentRoot(Directory.GetCurrentDirectory())
.Build(); .Build();
MainHost.RunAsync(); MainHost.Run();
var tryGetEventManager = MainHost.Services.GetService(typeof(EventManager)); //var tryGetEventManager = MainHost.Services.GetService(typeof(EventManager));
_ = MainHost.Services.GetService(typeof(ExchangeInterface)); // _ = MainHost.Services.GetService(typeof(ExchangeInterface));
if(tryGetEventManager == null) Console.WriteLine($"Failed to get {nameof(EventManager)} Service."); /*if(tryGetEventManager == null) Console.WriteLine($"Failed to get {nameof(EventManager)} Service.");
if (tryGetEventManager is EventManager eventManager) if (tryGetEventManager is EventManager eventManager)
{ {
@ -67,7 +67,7 @@ namespace BlueWest.WebApi
System.Threading.Thread.Sleep(2500); System.Threading.Thread.Sleep(2500);
_threadServer = new ThreadServer(eventManager); _threadServer = new ThreadServer(eventManager);
_threadServer.Init(); _threadServer.Init();
} }*/
} }

View File

@ -69,7 +69,9 @@ namespace BlueWest.WebApi
// Set the comments path for the Swagger JSON and UI. // Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
options.IncludeXmlComments(xmlPath); options.IncludeXmlComments(xmlPath);
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
@ -117,6 +119,8 @@ namespace BlueWest.WebApi
services services
.AddSingleton<EventManager>(); .AddSingleton<EventManager>();
services.AddAuthServerServices(MyAllowSpecificOrigins, _configuration, _environment);
services.AddScoped<ExchangeInterface>();
switch (allowedDatabase) switch (allowedDatabase)
{ {
@ -132,10 +136,8 @@ namespace BlueWest.WebApi
throw new InvalidOperationException("config.json doesn't specify a valid database. Use mysql or sqlite."); throw new InvalidOperationException("config.json doesn't specify a valid database. Use mysql or sqlite.");
} }
services = services.AddAuthServerServices(MyAllowSpecificOrigins, _configuration, _environment);
services.AddScoped<ExchangeInterface>();
// services.AddGrpc(); // services.AddGrpc();
@ -165,6 +167,7 @@ namespace BlueWest.WebApi
app.UseRouting(); app.UseRouting();
app.UseCors(MyAllowSpecificOrigins); app.UseCors(MyAllowSpecificOrigins);
app.UseAuthentication(); app.UseAuthentication();

View File

@ -52,7 +52,6 @@ public class ApplicationUserDbContext : IdentityDbContext<
{ {
base.OnModelCreating(builder); base.OnModelCreating(builder);
builder.Entity<ApplicationUserRole>().ToTable("UserRoles"); builder.Entity<ApplicationUserRole>().ToTable("UserRoles");
builder.Entity<ApplicationUser>(b => builder.Entity<ApplicationUser>(b =>
{ {

View File

@ -1,4 +1,4 @@
{ {
"database": "sqlite", // use sqlite or mysql "database": "sqlite",
"environment": "dev" "environment": "dev"
} }