Updated MoonCore dependencies. Switched to asp.net core native authentication scheme abstractions. Updated claim usage in frontend
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MoonCore.Blazor.FlyonUi.Auth;
|
||||
using MoonCore.Blazor.FlyonUi.Exceptions;
|
||||
using MoonCore.Permissions;
|
||||
using Moonlight.Client.Implementations;
|
||||
using Moonlight.Client.Services;
|
||||
|
||||
namespace Moonlight.Client.Startup;
|
||||
@@ -12,11 +14,12 @@ public partial class Startup
|
||||
WebAssemblyHostBuilder.Services.AddAuthorizationCore();
|
||||
WebAssemblyHostBuilder.Services.AddCascadingAuthenticationState();
|
||||
|
||||
WebAssemblyHostBuilder.Services.AddAuthenticationStateManager<RemoteAuthStateManager>();
|
||||
WebAssemblyHostBuilder.Services.AddScoped<AuthenticationStateProvider, RemoteAuthStateProvider>();
|
||||
WebAssemblyHostBuilder.Services.AddScoped<IGlobalErrorFilter, UnauthenticatedErrorFilter>();
|
||||
|
||||
WebAssemblyHostBuilder.Services.AddAuthorizationPermissions(options =>
|
||||
{
|
||||
options.ClaimName = "permissions";
|
||||
options.ClaimName = "Permissions";
|
||||
options.Prefix = "permissions:";
|
||||
});
|
||||
|
||||
|
||||
@@ -25,27 +25,11 @@ public partial class Startup
|
||||
WebAssemblyHostBuilder.Services.AddScoped(sp =>
|
||||
{
|
||||
var httpClient = sp.GetRequiredService<HttpClient>();
|
||||
var httpApiClient = new HttpApiClient(httpClient);
|
||||
|
||||
var localStorageService = sp.GetRequiredService<LocalStorageService>();
|
||||
|
||||
httpApiClient.OnConfigureRequest += async request =>
|
||||
{
|
||||
var accessToken = await localStorageService.GetString("AccessToken");
|
||||
|
||||
if (string.IsNullOrEmpty(accessToken))
|
||||
return;
|
||||
|
||||
request.Headers.Add("Authorization", $"Bearer {accessToken}");
|
||||
};
|
||||
|
||||
return httpApiClient;
|
||||
return new HttpApiClient(httpClient);
|
||||
});
|
||||
|
||||
WebAssemblyHostBuilder.Services.AddScoped<WindowService>();
|
||||
WebAssemblyHostBuilder.Services.AddFileManagerOperations();
|
||||
WebAssemblyHostBuilder.Services.AddFlyonUiServices();
|
||||
WebAssemblyHostBuilder.Services.AddScoped<LocalStorageService>();
|
||||
|
||||
WebAssemblyHostBuilder.Services.AddScoped<ThemeService>();
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MoonCore.Blazor.FlyonUi.Exceptions;
|
||||
using MoonCore.Logging;
|
||||
using Moonlight.Client.Implementations;
|
||||
|
||||
namespace Moonlight.Client.Startup;
|
||||
|
||||
@@ -7,6 +10,7 @@ public partial class Startup
|
||||
private Task SetupLogging()
|
||||
{
|
||||
var loggerFactory = new LoggerFactory();
|
||||
|
||||
loggerFactory.AddAnsiConsole();
|
||||
|
||||
Logger = loggerFactory.CreateLogger<Startup>();
|
||||
@@ -19,6 +23,8 @@ public partial class Startup
|
||||
WebAssemblyHostBuilder.Logging.ClearProviders();
|
||||
WebAssemblyHostBuilder.Logging.AddAnsiConsole();
|
||||
|
||||
WebAssemblyHostBuilder.Services.AddScoped<IGlobalErrorFilter, LogErrorFilter>();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,8 @@ public partial class Startup
|
||||
WebAssemblyHostBuilder = builder;
|
||||
|
||||
await PrintVersion();
|
||||
await SetupLogging();
|
||||
|
||||
await SetupLogging();
|
||||
await LoadConfiguration();
|
||||
await InitializePlugins();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user