Refactor to use named authorization policies in controllers

Replaced direct role-based [Authorize] attributes with named
authorization policies (e.g., AuthPolicy.Receiver,
AuthPolicy.SenderOrReceiver) in AnnotationController,
DocumentController, and ReadOnlyController. Added and registered
new policies in Program.cs and updated AuthPolicy constants.
This centralizes and simplifies authorization management.
This commit is contained in:
2026-02-03 16:20:26 +01:00
parent c6c8747d23
commit 0d2425c9cf
5 changed files with 15 additions and 7 deletions

View File

@@ -180,8 +180,12 @@ try
builder.Services.AddAuthorizationBuilder()
.AddPolicy(AuthPolicy.SenderOrReceiver, policy =>
policy.RequireRole(Role.Sender, Role.Receiver.FullyAuth))
.AddPolicy(AuthPolicy.Sender, policy =>
policy.RequireRole(Role.Sender))
.AddPolicy(AuthPolicy.Receiver, policy =>
policy.RequireRole(Role.Receiver.FullyAuth));
policy.RequireRole(Role.Receiver.FullyAuth))
.AddPolicy(AuthPolicy.ReceiverTFA, policy =>
policy.RequireRole(Role.Receiver.PreAuth));
// User manager
#pragma warning disable CS0618 // Type or member is obsolete