feat: auth, compression, jwt, paste wip, roles, ratelimiting

This commit is contained in:
2025-11-24 21:50:26 -05:00
parent 050f0bc935
commit 6ec1a7fa7b
26 changed files with 611 additions and 473 deletions
@@ -1,122 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SharpbinV3.Data;
#nullable disable
namespace SharpbinV3.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20251124021817_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.0");
modelBuilder.Entity("SharpbinV3.Data.Entities.Paste", b =>
{
b.Property<int>("PID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AuthorUUID")
.IsRequired()
.HasColumnType("TEXT");
b.Property<long?>("EditedAt")
.HasColumnType("INTEGER");
b.Property<long>("ExpiresAt")
.HasColumnType("INTEGER");
b.Property<string>("FilePath")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ID")
.HasColumnType("TEXT");
b.Property<int>("Size")
.HasColumnType("INTEGER");
b.Property<string>("Syntax")
.HasColumnType("TEXT");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.Property<int>("TrueSize")
.HasColumnType("INTEGER");
b.Property<string>("UUID")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("UserUID")
.HasColumnType("INTEGER");
b.Property<int>("Views")
.HasColumnType("INTEGER");
b.HasKey("PID");
b.HasIndex("UserUID");
b.ToTable("Pastes");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.User", b =>
{
b.Property<int>("UID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("DisplayName")
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasColumnType("TEXT");
b.Property<long?>("LastLogin")
.HasColumnType("INTEGER");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("TEXT");
b.Property<Guid>("UUID")
.HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("UID");
b.ToTable("Users");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.Paste", b =>
{
b.HasOne("SharpbinV3.Data.Entities.User", "User")
.WithMany("Pastes")
.HasForeignKey("UserUID");
b.Navigation("User");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.User", b =>
{
b.Navigation("Pastes");
});
#pragma warning restore 612, 618
}
}
}
@@ -1,143 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SharpbinV3.Data;
#nullable disable
namespace SharpbinV3.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20251124181150_AddPasteIndexes")]
partial class AddPasteIndexes
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "10.0.0");
modelBuilder.Entity("SharpbinV3.Data.Entities.Paste", b =>
{
b.Property<int>("PID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AuthorUUID")
.IsRequired()
.HasColumnType("TEXT");
b.Property<long?>("EditedAt")
.HasColumnType("INTEGER");
b.Property<long>("ExpiresAt")
.HasColumnType("INTEGER");
b.Property<string>("FilePath")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ID")
.HasColumnType("TEXT");
b.Property<int>("Size")
.HasColumnType("INTEGER");
b.Property<string>("Syntax")
.HasColumnType("TEXT");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.Property<int>("TrueSize")
.HasColumnType("INTEGER");
b.Property<string>("UUID")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("UserUID")
.HasColumnType("INTEGER");
b.Property<int>("Views")
.HasColumnType("INTEGER");
b.HasKey("PID");
b.HasIndex("AuthorUUID");
b.HasIndex("ExpiresAt");
b.HasIndex("ID")
.IsUnique();
b.HasIndex("PID")
.IsUnique();
b.HasIndex("UUID")
.IsUnique();
b.HasIndex("UserUID");
b.HasIndex("Views");
b.ToTable("Pastes");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.User", b =>
{
b.Property<int>("UID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("DisplayName")
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasColumnType("TEXT");
b.Property<long?>("LastLogin")
.HasColumnType("INTEGER");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("TEXT");
b.Property<Guid>("UUID")
.HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("UID");
b.HasIndex("UID")
.IsUnique();
b.HasIndex("UUID")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.Paste", b =>
{
b.HasOne("SharpbinV3.Data.Entities.User", "User")
.WithMany("Pastes")
.HasForeignKey("UserUID");
b.Navigation("User");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.User", b =>
{
b.Navigation("Pastes");
});
#pragma warning restore 612, 618
}
}
}
@@ -1,95 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SharpbinV3.Migrations
{
/// <inheritdoc />
public partial class AddPasteIndexes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_Users_UID",
table: "Users",
column: "UID",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Users_UUID",
table: "Users",
column: "UUID",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Pastes_AuthorUUID",
table: "Pastes",
column: "AuthorUUID");
migrationBuilder.CreateIndex(
name: "IX_Pastes_ExpiresAt",
table: "Pastes",
column: "ExpiresAt");
migrationBuilder.CreateIndex(
name: "IX_Pastes_ID",
table: "Pastes",
column: "ID",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Pastes_PID",
table: "Pastes",
column: "PID",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Pastes_UUID",
table: "Pastes",
column: "UUID",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Pastes_Views",
table: "Pastes",
column: "Views");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Users_UID",
table: "Users");
migrationBuilder.DropIndex(
name: "IX_Users_UUID",
table: "Users");
migrationBuilder.DropIndex(
name: "IX_Pastes_AuthorUUID",
table: "Pastes");
migrationBuilder.DropIndex(
name: "IX_Pastes_ExpiresAt",
table: "Pastes");
migrationBuilder.DropIndex(
name: "IX_Pastes_ID",
table: "Pastes");
migrationBuilder.DropIndex(
name: "IX_Pastes_PID",
table: "Pastes");
migrationBuilder.DropIndex(
name: "IX_Pastes_UUID",
table: "Pastes");
migrationBuilder.DropIndex(
name: "IX_Pastes_Views",
table: "Pastes");
}
}
}
@@ -1,60 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SharpbinV3.Migrations
{
/// <inheritdoc />
public partial class AddVisibility : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "Type",
table: "Users",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "Visiblity",
table: "Users",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "Visiblity",
table: "Pastes",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_Pastes_Visiblity",
table: "Pastes",
column: "Visiblity");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Pastes_Visiblity",
table: "Pastes");
migrationBuilder.DropColumn(
name: "Type",
table: "Users");
migrationBuilder.DropColumn(
name: "Visiblity",
table: "Users");
migrationBuilder.DropColumn(
name: "Visiblity",
table: "Pastes");
}
}
}
@@ -11,8 +11,8 @@ using SharpbinV3.Data;
namespace SharpbinV3.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20251124184531_AddVisibility")]
partial class AddVisibility
[Migration("20251125015039_Init")]
partial class Init
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -92,6 +92,39 @@ namespace SharpbinV3.Migrations
b.ToTable("Pastes");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.RefreshToken", b =>
{
b.Property<Guid>("UserUUID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<long>("CreatedAt")
.HasColumnType("INTEGER");
b.Property<long>("ExpiresAt")
.HasColumnType("INTEGER");
b.Property<string>("JwtId")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("Used")
.HasColumnType("INTEGER");
b.Property<int?>("UserUID")
.HasColumnType("INTEGER");
b.HasKey("UserUUID");
b.HasIndex("UserUID");
b.ToTable("RefreshTokens");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.User", b =>
{
b.Property<int>("UID")
@@ -111,8 +144,9 @@ namespace SharpbinV3.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.PrimitiveCollection<string>("Roles")
.IsRequired()
.HasColumnType("TEXT");
b.Property<Guid>("UUID")
.HasColumnType("TEXT");
@@ -144,6 +178,15 @@ namespace SharpbinV3.Migrations
b.Navigation("User");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.RefreshToken", b =>
{
b.HasOne("SharpbinV3.Data.Entities.User", "User")
.WithMany()
.HasForeignKey("UserUID");
b.Navigation("User");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.User", b =>
{
b.Navigation("Pastes");
@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace SharpbinV3.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@@ -22,7 +22,9 @@ namespace SharpbinV3.Migrations
PasswordHash = table.Column<string>(type: "TEXT", nullable: false),
Email = table.Column<string>(type: "TEXT", nullable: true),
DisplayName = table.Column<string>(type: "TEXT", nullable: true),
LastLogin = table.Column<long>(type: "INTEGER", nullable: true)
LastLogin = table.Column<long>(type: "INTEGER", nullable: true),
Roles = table.Column<string>(type: "TEXT", nullable: false),
Visiblity = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
@@ -46,6 +48,7 @@ namespace SharpbinV3.Migrations
TrueSize = table.Column<int>(type: "INTEGER", nullable: false),
Views = table.Column<int>(type: "INTEGER", nullable: false),
Syntax = table.Column<string>(type: "TEXT", nullable: true),
Visiblity = table.Column<int>(type: "INTEGER", nullable: false),
ExpiresAt = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
@@ -58,10 +61,87 @@ namespace SharpbinV3.Migrations
principalColumn: "UID");
});
migrationBuilder.CreateTable(
name: "RefreshTokens",
columns: table => new
{
UserUUID = table.Column<Guid>(type: "TEXT", nullable: false),
Token = table.Column<string>(type: "TEXT", nullable: false),
JwtId = table.Column<string>(type: "TEXT", nullable: false),
CreatedAt = table.Column<long>(type: "INTEGER", nullable: false),
ExpiresAt = table.Column<long>(type: "INTEGER", nullable: false),
Used = table.Column<bool>(type: "INTEGER", nullable: false),
UserUID = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RefreshTokens", x => x.UserUUID);
table.ForeignKey(
name: "FK_RefreshTokens_Users_UserUID",
column: x => x.UserUID,
principalTable: "Users",
principalColumn: "UID");
});
migrationBuilder.CreateIndex(
name: "IX_Pastes_AuthorUUID",
table: "Pastes",
column: "AuthorUUID");
migrationBuilder.CreateIndex(
name: "IX_Pastes_ExpiresAt",
table: "Pastes",
column: "ExpiresAt");
migrationBuilder.CreateIndex(
name: "IX_Pastes_ID",
table: "Pastes",
column: "ID",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Pastes_PID",
table: "Pastes",
column: "PID",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Pastes_UserUID",
table: "Pastes",
column: "UserUID");
migrationBuilder.CreateIndex(
name: "IX_Pastes_UUID",
table: "Pastes",
column: "UUID",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Pastes_Views",
table: "Pastes",
column: "Views");
migrationBuilder.CreateIndex(
name: "IX_Pastes_Visiblity",
table: "Pastes",
column: "Visiblity");
migrationBuilder.CreateIndex(
name: "IX_RefreshTokens_UserUID",
table: "RefreshTokens",
column: "UserUID");
migrationBuilder.CreateIndex(
name: "IX_Users_UID",
table: "Users",
column: "UID",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Users_UUID",
table: "Users",
column: "UUID",
unique: true);
}
/// <inheritdoc />
@@ -70,6 +150,9 @@ namespace SharpbinV3.Migrations
migrationBuilder.DropTable(
name: "Pastes");
migrationBuilder.DropTable(
name: "RefreshTokens");
migrationBuilder.DropTable(
name: "Users");
}
@@ -89,6 +89,39 @@ namespace SharpbinV3.Migrations
b.ToTable("Pastes");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.RefreshToken", b =>
{
b.Property<Guid>("UserUUID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<long>("CreatedAt")
.HasColumnType("INTEGER");
b.Property<long>("ExpiresAt")
.HasColumnType("INTEGER");
b.Property<string>("JwtId")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("TEXT");
b.Property<bool>("Used")
.HasColumnType("INTEGER");
b.Property<int?>("UserUID")
.HasColumnType("INTEGER");
b.HasKey("UserUUID");
b.HasIndex("UserUID");
b.ToTable("RefreshTokens");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.User", b =>
{
b.Property<int>("UID")
@@ -108,8 +141,9 @@ namespace SharpbinV3.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.PrimitiveCollection<string>("Roles")
.IsRequired()
.HasColumnType("TEXT");
b.Property<Guid>("UUID")
.HasColumnType("TEXT");
@@ -141,6 +175,15 @@ namespace SharpbinV3.Migrations
b.Navigation("User");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.RefreshToken", b =>
{
b.HasOne("SharpbinV3.Data.Entities.User", "User")
.WithMany()
.HasForeignKey("UserUID");
b.Navigation("User");
});
modelBuilder.Entity("SharpbinV3.Data.Entities.User", b =>
{
b.Navigation("Pastes");