Drops the replaced Client table

This commit is contained in:
Paul Schneider
2025-08-25 13:32:31 +01:00
parent c65de51f9c
commit 7ac48c3bbf
8 changed files with 3482 additions and 80 deletions

View File

@ -156,13 +156,13 @@ public static class HostingExtensions
policy.RequireAuthenticatedUser()
.RequireClaim("scope", "scope2");
});
options.AddPolicy("Performer", policy =>
{
policy
.RequireAuthenticatedUser()
.RequireClaim(Constants.RoleClaimType,
new string[] {Constants.PerformerGroupName, Constants.AdminGroupName})
new string[] { Constants.PerformerGroupName, Constants.AdminGroupName })
;
});
options.AddPolicy("AdministratorOnly", policy =>
@ -398,50 +398,44 @@ public static class HostingExtensions
app.InitializeDatabase();
return app;
}
private static void InitializeDatabase(this IApplicationBuilder app)
{
using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
private static void InitializeDatabase(this IApplicationBuilder app)
{
serviceScope.ServiceProvider.GetRequiredService<PersistedGrantDbContext>().Database.Migrate();
var context = serviceScope.ServiceProvider.GetRequiredService<ConfigurationDbContext>();
try
using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
{
serviceScope.ServiceProvider.GetRequiredService<PersistedGrantDbContext>().Database.Migrate();
var context = serviceScope.ServiceProvider.GetRequiredService<ConfigurationDbContext>();
context.Database.Migrate();
}
catch (Exception ex)
{
// TODO log
}
if (!context.Clients.Any())
{
foreach (var client in Config.Clients)
{
context.Clients.Add(client.ToEntity());
}
context.SaveChanges();
}
if (!context.IdentityResources.Any())
{
foreach (var resource in Config.IdentityResources)
if (!context.Clients.Any())
{
context.IdentityResources.Add(resource.ToEntity());
foreach (var client in Config.Clients)
{
context.Clients.Add(client.ToEntity());
}
context.SaveChanges();
}
context.SaveChanges();
}
if (!context.ApiScopes.Any())
{
foreach (var resource in Config.ApiScopes)
if (!context.IdentityResources.Any())
{
context.ApiScopes.Add(resource.ToEntity());
foreach (var resource in Config.IdentityResources)
{
context.IdentityResources.Add(resource.ToEntity());
}
context.SaveChanges();
}
if (!context.ApiScopes.Any())
{
foreach (var resource in Config.ApiScopes)
{
context.ApiScopes.Add(resource.ToEntity());
}
context.SaveChanges();
}
context.SaveChanges();
}
}
}
static void LoadGoogleConfig(IConfigurationRoot configuration)
{

View File

@ -4,7 +4,7 @@ USER_AND_GROUP=www-data:www-data
SERVICE_PROD=yavsc
DOTNET_FRAMEWORK=net9.0
all:
all: css js
dotnet build
showConfig:
@ -35,4 +35,6 @@ pushInProd: publish
%.min.css: %.css
jsmin < $^ > $@
css: wwwroot/css/site.css
css: wwwroot/css/site.min.css
js: wwwroot/js/site.min.js

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Yavsc.Migrations
{
/// <inheritdoc />
public partial class pending : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Client");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Client",
columns: table => new
{
Id = table.Column<string>(type: "text", nullable: false),
AccessTokenLifetime = table.Column<int>(type: "integer", nullable: false),
Active = table.Column<bool>(type: "boolean", nullable: false),
DisplayName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
LogoutRedirectUri = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
RedirectUri = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
RefreshTokenLifeTime = table.Column<int>(type: "integer", nullable: false),
Secret = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: false),
Type = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Client", x => x.Id);
});
}
}
}

View File

@ -429,47 +429,6 @@ namespace Yavsc.Migrations
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Yavsc.Models.Auth.Client", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("text");
b.Property<int>("AccessTokenLifetime")
.HasColumnType("integer");
b.Property<bool>("Active")
.HasColumnType("boolean");
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<string>("LogoutRedirectUri")
.HasMaxLength(512)
.HasColumnType("character varying(512)");
b.Property<string>("RedirectUri")
.HasMaxLength(512)
.HasColumnType("character varying(512)");
b.Property<int>("RefreshTokenLifeTime")
.HasColumnType("integer");
b.Property<string>("Secret")
.IsRequired()
.HasMaxLength(512)
.HasColumnType("character varying(512)");
b.Property<int>("Type")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Client");
});
modelBuilder.Entity("Yavsc.Models.Auth.Scope", b =>
{
b.Property<string>("Id")

View File

@ -1 +1,6 @@
.welcome-page .logo{width:64px;}.icon-banner{width:32px;}.body-container{margin-top:60px;padding-bottom:40px;}.welcome-page li{list-style:none;padding:4px;}.logged-out-page iframe{display:none;width:0;height:0;}.grants-page .card{margin-top:20px;border-bottom:1px solid #d3d3d3;}.grants-page .card .card-title{font-size:120%;font-weight:bold;}.grants-page .card .card-title img{width:100px;height:100px;}.grants-page .card label{font-weight:bold;}
.grants-page.card{margin-top:20px;border-bottom:1px solid lightgray;}.grants-page.card.card-title{font-size:120%;font-weight:bold;}.grants-page.card.card-title img{width:100px;height:100px;}.grants-page.card label{font-weight:bold;}.navbar-dark.navbar-toggler-icon{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");}
div.carousel-inner>div.item>div.carousel-caption-s{margin:.5em;background-color:rgba(0,0,0,0.6);color:#ffffc8;font-weight:bold;padding:.5em;}
img.blogphoto{max-width:100%;max-height:100%;}
input[type='checkbox']{appearance:auto;min-width:1em;min-height:1em;}.container{background-color:#000000d5;color:#fff;padding:.5em;margin:.5em;}.post{background-color:#000000dd;color:#d1d1d1;padding:2.3em;border-radius:2em;border:solid#441515a4 2pt;}.actiongroup{float:right;margin:.5em;}.float-left{float:left;margin:.5em;}
a{color:aquamarine;background-color:black;}
a.close{cursor:pointer;}

View File

@ -13,3 +13,4 @@ var setUiCult = function(lngspec) {
document.cookie = 'ASPNET_CULTURE=c=' + lngspec + '|uic=' + lngspec;
location.reload();
};

View File

@ -1 +1,2 @@
var notifClick=function(i){0<i&&$.get("/api/dimiss/click/"+i)},setUiCult=function(i){document.cookie="ASPNET_CULTURE=c="+i+"|uic="+i,location.reload()};
var notifClick=function(nid){if(nid>0){$.get({url:'/api/dimiss/click/'+nid,success:$('div[data-nid='+nid+']').remove()});}};var setUiCult=function(lngspec){document.cookie='ASPNET_CULTURE=c='+lngspec+'|uic='+lngspec;location.reload();};