Add users, roles, and per-novel permissions

Introduces accounts (ASP.NET Identity + cookie auth), four global
roles (Admin/Writer/Editor/Reviewer), per-novel ownership and grants
via ProjectMember, and a service-API-key principal for the MCP server
and background import jobs. Enforcement lives in the application
services (not endpoint filters) so the embedded agent and MCP tools,
which call the same services directly, can't bypass it. Web client
gets a login page, session-aware routing, and a People section for
managing per-novel access.

Also includes prior in-flight changes from this branch (CLAUDE.md
compliance pass, dev-deploy docker-compose setup) that were
uncommitted when this feature work started.
This commit is contained in:
James Wampler
2026-08-15 22:29:33 -07:00
parent 7d8dd0c4fd
commit e598c18d67
111 changed files with 6562 additions and 797 deletions
+19 -1
View File
@@ -3,11 +3,13 @@ using Novelly.Api.Common;
using Novelly.Api.Common.Validation;
using Novelly.Api.Data;
using Novelly.Api.Tags;
using Novelly.Api.Users;
namespace Novelly.Api.Chapters;
public class ChapterService(
INovelDbContext db,
ProjectAccessService access,
TagService tags,
ILogger<ChapterService> logger,
IModelValidator<CreateChapterRequest> createValidator,
@@ -19,6 +21,8 @@ public class ChapterService(
logger.LogInformation("Listing chapters for project {ProjectId}", projectId);
await access.RequireAsync(projectId, ProjectPermission.Read, ct);
return await db.Chapters
.Include(c => c.Beats)
.Include(c => c.Tags)
@@ -32,7 +36,15 @@ public class ChapterService(
Guard.Default(id, nameof(id));
logger.LogInformation("Getting chapter {ChapterId}", id);
return await FindAsync(id, ct);
var chapter = await FindAsync(id, ct);
if (chapter is null)
{
return null;
}
await access.RequireAsync(chapter.ProjectId, ProjectPermission.Read, ct);
return chapter;
}
public async Task<Chapter?> CreateAsync(Guid projectId, CreateChapterRequest request, CancellationToken ct = default)
@@ -49,6 +61,8 @@ public class ChapterService(
return null;
}
await access.RequireAsync(projectId, ProjectPermission.CreateContent, ct);
var chapter = new Chapter
{
ProjectId = projectId,
@@ -88,6 +102,8 @@ public class ChapterService(
return null;
}
await access.RequireAsync(chapter.ProjectId, ProjectPermission.Write, ct);
chapter.Title = Patch.Apply(chapter.Title, request.Title) ?? chapter.Title;
chapter.Number = request.Number ?? chapter.Number;
chapter.Summary = Patch.Apply(chapter.Summary, request.Summary);
@@ -125,6 +141,8 @@ public class ChapterService(
return false;
}
await access.RequireAsync(chapter.ProjectId, ProjectPermission.DeleteContent, ct);
db.Chapters.Remove(chapter);
await db.SaveChangesAsync(ct);
return true;