added basic functionalities (login, create/del/rename pages)

This commit is contained in:
taywon18
2024-09-22 11:48:59 +02:00
parent d531454166
commit 5707f5a2d4
12 changed files with 374 additions and 31 deletions

View File

@@ -1,13 +1,36 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Server;
using Tagger.Service;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddJsonFile("config.json", true);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddHttpContextAccessor();
builder.Services.AddSingleton<PageProvider>();
builder.Services.AddScoped<UserManager>();
builder.Services.AddScoped<IHostEnvironmentAuthenticationStateProvider>(sp =>
(ServerAuthenticationStateProvider)sp.GetRequiredService<AuthenticationStateProvider>()
);
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.Cookie.Name = "auth_token";
options.LoginPath = "/login";
options.Cookie.MaxAge = TimeSpan.FromHours(1);
});
builder.Services.AddAuthorization();
builder.Services.AddCascadingAuthenticationState();
var app = builder.Build();