RuslanPr0g/Hiscaries

Authorization & Role Checks

开放

#31 创建于 2024年11月8日

 (0 条评论) (0 个反应) (1 位负责人)C# (0 个派生)auto 404
enhancementgood first issue

仓库指标

星标
 (2 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Implement a robust and maintainable authorization mechanism to ensure that users can only delete their own content, while administrators have extended permissions, such as the ability to delete any story or comment. The solution should be designed for reusability across different parts of the application, particularly for handling role-based access control involving administrators and other roles.

Avoid using the built-in Microsoft IdentityUser as it is unnecessarily large for our requirements. Instead, utilize the Role property in the existing UserAccount class. Introduce a middleware-based approach to enforce role-based access at a global level, combined with MediatR pipeline behaviors to handle role restrictions for specific commands and queries. This design provides flexibility, simplicity, and scalability.

贡献者指南