summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Acl.cs1
-rw-r--r--AclEnum.cs14
-rw-r--r--Migrations/20230920052204_Security.Designer.cs (renamed from Migrations/20230920014958_Security.Designer.cs)8
-rw-r--r--Migrations/20230920052204_Security.cs (renamed from Migrations/20230920014958_Security.cs)12
-rw-r--r--Migrations/HBContextModelSnapshot.cs6
-rw-r--r--Pages/Component/AclDialog.razor19
-rw-r--r--Properties/launchSettings.json1
-rw-r--r--Server.csproj10
-rw-r--r--Services/SecurityService.cs5
9 files changed, 55 insertions, 21 deletions
diff --git a/Acl.cs b/Acl.cs
index 72d0bf2..297144e 100644
--- a/Acl.cs
+++ b/Acl.cs
@@ -25,6 +25,7 @@ public class Acl<T> : Acl where T : Enum {
public class AclRule : HBObject {
public HBPrincipal Principal { get; set; }
public AclRuleAction Action { get; set; }
+ [Column(TypeName = "bigint")]
public ulong Permissions { get; set; }
}
diff --git a/AclEnum.cs b/AclEnum.cs
new file mode 100644
index 0000000..e195444
--- /dev/null
+++ b/AclEnum.cs
@@ -0,0 +1,14 @@
+namespace HyperBooru;
+
+[Flags]
+public enum HBMediaPermissions {
+ [AclPermission] Read = 0x01,
+ [AclPermission] Write = 0x02,
+ [AclPermission] Delete = 0x04,
+ [AclPermission] GetTags = 0x08,
+ [AclPermission] SetTags = 0x10
+}
+
+public class AclPermissionAttribute : Attribute {
+ public string Name { get; set; }
+}
diff --git a/Migrations/20230920014958_Security.Designer.cs b/Migrations/20230920052204_Security.Designer.cs
index 7933a93..8640c30 100644
--- a/Migrations/20230920014958_Security.Designer.cs
+++ b/Migrations/20230920052204_Security.Designer.cs
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace HyperBooru.Migrations
{
[DbContext(typeof(HBContext))]
- [Migration("20230920014958_Security")]
+ [Migration("20230920052204_Security")]
partial class Security
{
/// <inheritdoc />
@@ -110,8 +110,8 @@ namespace HyperBooru.Migrations
b.Property<int>("Action")
.HasColumnType("integer");
- b.Property<decimal>("Permissions")
- .HasColumnType("numeric(20,0)");
+ b.Property<long>("Permissions")
+ .HasColumnType("bigint");
b.Property<int>("PrincipalObjectId")
.HasColumnType("integer");
@@ -284,7 +284,7 @@ namespace HyperBooru.Migrations
new
{
ObjectId = -3,
- Guid = new Guid("bf62bd4c-806e-4d1b-a62d-0efffce8628a"),
+ Guid = new Guid("8fbbc2e9-0609-460a-ab3a-c3bdd10ab793"),
Name = "admin",
PasswordHash = "P4geAuE2yX/PDRHuJSq74FF5vO782rWz5c0LAQPR8m45DEYAONhu1wYnAn60PSNyjocqEBdnCeKCJfK3sKyuWw=="
});
diff --git a/Migrations/20230920014958_Security.cs b/Migrations/20230920052204_Security.cs
index ed7def8..982cb97 100644
--- a/Migrations/20230920014958_Security.cs
+++ b/Migrations/20230920052204_Security.cs
@@ -19,6 +19,10 @@ namespace HyperBooru.Migrations
name: "IX_Users_Username",
table: "Users");
+ migrationBuilder.DropColumn(
+ name: "Username",
+ table: "Users");
+
migrationBuilder.CreateTable(
name: "Acls",
columns: table => new
@@ -56,7 +60,7 @@ namespace HyperBooru.Migrations
ObjectId = table.Column<int>(type: "integer", nullable: false),
PrincipalObjectId = table.Column<int>(type: "integer", nullable: false),
Action = table.Column<int>(type: "integer", nullable: false),
- Permissions = table.Column<decimal>(type: "numeric(20,0)", nullable: false),
+ Permissions = table.Column<long>(type: "bigint", nullable: false),
AclObjectId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
@@ -97,7 +101,7 @@ namespace HyperBooru.Migrations
keyColumn: "ObjectId",
keyValue: -3,
column: "Guid",
- value: new Guid("bf62bd4c-806e-4d1b-a62d-0efffce8628a"));
+ value: new Guid("8fbbc2e9-0609-460a-ab3a-c3bdd10ab793"));
migrationBuilder.InsertData(
table: "Principals",
@@ -131,10 +135,6 @@ namespace HyperBooru.Migrations
principalTable: "Principals",
principalColumn: "ObjectId",
onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.DropColumn(
- name: "Username",
- table: "Users");
}
/// <inheritdoc />
diff --git a/Migrations/HBContextModelSnapshot.cs b/Migrations/HBContextModelSnapshot.cs
index da4c444..5514b9b 100644
--- a/Migrations/HBContextModelSnapshot.cs
+++ b/Migrations/HBContextModelSnapshot.cs
@@ -107,8 +107,8 @@ namespace HyperBooru.Migrations
b.Property<int>("Action")
.HasColumnType("integer");
- b.Property<decimal>("Permissions")
- .HasColumnType("numeric(20,0)");
+ b.Property<long>("Permissions")
+ .HasColumnType("bigint");
b.Property<int>("PrincipalObjectId")
.HasColumnType("integer");
@@ -281,7 +281,7 @@ namespace HyperBooru.Migrations
new
{
ObjectId = -3,
- Guid = new Guid("bf62bd4c-806e-4d1b-a62d-0efffce8628a"),
+ Guid = new Guid("8fbbc2e9-0609-460a-ab3a-c3bdd10ab793"),
Name = "admin",
PasswordHash = "P4geAuE2yX/PDRHuJSq74FF5vO782rWz5c0LAQPR8m45DEYAONhu1wYnAn60PSNyjocqEBdnCeKCJfK3sKyuWw=="
});
diff --git a/Pages/Component/AclDialog.razor b/Pages/Component/AclDialog.razor
new file mode 100644
index 0000000..33d1f03
--- /dev/null
+++ b/Pages/Component/AclDialog.razor
@@ -0,0 +1,19 @@
+@implements IDialog
+
+<Dialog Title="Edit permissions" @ref=dialog>
+</Dialog>
+
+@code {
+ [Parameter]
+ public HBObject Object { get; set; }
+
+ public bool Visible {
+ get => dialog.Visible;
+ set => dialog.Visible = value;
+ }
+
+ private Dialog dialog;
+
+ public void Show() => Visible = true;
+ public void Hide() => Visible = false;
+} \ No newline at end of file
diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json
index b1659dc..9f4966c 100644
--- a/Properties/launchSettings.json
+++ b/Properties/launchSettings.json
@@ -13,7 +13,6 @@
"HyperBooru": {
"commandName": "Project",
"launchBrowser": true,
- "launchUrl": "Login",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
diff --git a/Server.csproj b/Server.csproj
index 3302b3e..ae08913 100644
--- a/Server.csproj
+++ b/Server.csproj
@@ -21,14 +21,14 @@
<ItemGroup>
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="13.2.0" />
- <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.10">
+ <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.11" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
- <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.10" />
- <PackageReference Include="Mime-Detective" Version="23.6.1" />
- <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.11" />
+ <PackageReference Include="Mime-Detective" Version="23.9.1" />
+ <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="Tesseract" Version="5.2.0" />
diff --git a/Services/SecurityService.cs b/Services/SecurityService.cs
index c8dafd5..6e5ecb8 100644
--- a/Services/SecurityService.cs
+++ b/Services/SecurityService.cs
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Caching.Memory;
using System.Data;
namespace HyperBooru.Services;
@@ -6,8 +7,8 @@ namespace HyperBooru.Services;
public class SecurityService {
private IDbContextFactory<HBContext> dbFactory;
- private Group[] groups;
- private Acl[] acls;
+ private Group[] groups;
+ private Acl[] acls;
public SecurityService(IDbContextFactory<HBContext> dbFactory) {
this.dbFactory = dbFactory;