View on GitHub
Clean Architecture Toolkit for .NET
Clean Architecture Toolkit is a clean, modular architecture foundation for .NET applications.
It embraces SOLID principles and focuses on maintainability, testability, and scalability through clear boundaries and pluggable design.

|   HOME   |   MODULE OVERVIEW   |   DEMO   |

Plans for Cat.Authorization

A decorator that checks permissions before a service request runs.
Status: not started. This plan collects what we know. The open questions need an answer before the build.

Contents

The idea

Who may do what is a business rule, and it should live in the core service, where it can be tested without HTTP. A decorator on service requests can check the rule before the handler runs. A caller without permission gets a clear response, and the handler never starts.

What we already know

From the demo plan:

From the module conventions:

Decisions and open questions

Decided

Topic Decision
Place A decorator on service requests.
Identity The business logic only knows the user abstraction, never HttpContext.
User abstraction ICatUser lives in Cat.Authorization.Abstractions, renamed from the demo’s ICurrentUser. This module owns it. Cat.Auditing and other modules reference that project. The core service may reference it, because it only references abstractions. Contracts does not.
Two layers The gateway and the service both validate the token.
Until the module exists The demo keeps its own ICurrentUser and an owner filter in the queries. When Cat.Authorization.Abstractions exists, the demo switches to ICatUser.

Open

Questions before building

  1. Which members does ICatUser get? Roles or claims instead of IsAdmin, an authenticated flag, a string id?
  2. Do we build Cat.Authorization.Abstractions first, ahead of the decorator, so the demo and Cat.Auditing can use ICatUser early?
  3. What does ICatUser return when there is no user, such as in a scheduled job or a message handler?
  4. Does the module ship an ASP.NET Core implementation of ICatUser, or only the abstraction?
  5. Do you want roles, permissions or both?
  6. How should a request declare what it needs: attribute, registration or policy class?
  7. Do we cover only the check before the handler, or also the owner filter in queries?
  8. Do the existing Unauthorized and Forbidden responses cover 401 and 403, or is something missing?
  9. Do we depend on ASP.NET Core authorization, or stay free of it?
  10. What are the rules for background work that has no user?
  11. Is Keycloak the only identity provider we design for?
  12. Do we build this before the demo gets Keycloak, or after, with the real claims?
  13. Does the Catalog admin save become the first use case?