aspboilerplate中的权限管理
Permission management in aspboilerplate
我目前正在使用 aspboilerplate 开发 multitenant saas webapp 并希望实施 权限管理 但我有点困惑。
首先,MultitenancySides.Host
和我发现的MultitenancySides.Tenant
有什么区别here....
public override void SetPermissions(IPermissionDefinitionContext context)
{
context.CreatePermission(PermissionNames.Pages_Users, L("Users"));
context.CreatePermission(PermissionNames.Pages_Roles, L("Roles"));
context.CreatePermission(PermissionNames.Pages_Tenants, L("Tenants"), multiTenancySides: MultiTenancySides.Host);
context.CreatePermission(PermissionNames.Pages_Events, L("Events"), multiTenancySides: MultiTenancySides.Tenant);
}
其次,[AbpAuthorize]
与
有何不同
[AbpAuthorize(PermissionNames.Pages_Tenants)]
我在活动服务中找到了那些 (first link and second link),
[AbpAuthorize]
public class EventAppService : EventCloudAppServiceBase, IEventAppService
{
private readonly IEventManager _eventManager;
private readonly IRepository<Event, Guid> _eventRepository;
并在 TenantService 中
[AbpAuthorize(PermissionNames.Pages_Tenants)]
public class TenantAppService : AsyncCrudAppService<Tenant, TenantDto, int, PagedResultRequestDto, CreateTenantDto, TenantDto>, ITenantAppService
{
private readonly TenantManager _tenantManager;
这是我想要并期望在我的多租户 Saas 中实现权限的内容 (Core + Angualr SPA) ...
会有不同的功能(我说的是模块),包括事件(CRUD
)、图书馆(CRUD
)、考试(CRUD
)、结果(CRUD
)、出勤(CRUD
) 并且我希望拥有租户超级管理员的完全访问权限 (CRUD
)(默认情况下在创建租户时分配),然后超级管理员可以创建角色(分配的模块和权限(CRUD
) 到特定模块)。
为简单起见,如果系统有出勤 module/feature,则默认情况下,租户的 Superadmin
将拥有完整的 CRUD
访问权限,而如果 Staff
角色已创建并受到限制CR
但不允许 UD
。
我已经完成了 this 教程,但无法整理。
谢谢。
Firstly, what's the difference between MultiTenancySides.Host
and MultitenancySides.Tenant
?
MultiTenancySides.Host
→ 只能分配给主机用户(user.TenantId == null
)。
MultiTenancySides.Tenant
→ 只能分配给租户用户(user.TenantId != null
)。
Secondly, how [AbpAuthorize]
differs from [AbpAuthorize(PermissionNames.Pages_Tenants)]
?
[AbpAuthorize]
→ 用户已登录。
[AbpAuthorize(PermissionNames.Pages_Tenants)]
→ 用户已登录并拥有该权限。
我目前正在使用 aspboilerplate 开发 multitenant saas webapp 并希望实施 权限管理 但我有点困惑。
首先,MultitenancySides.Host
和我发现的MultitenancySides.Tenant
有什么区别here....
public override void SetPermissions(IPermissionDefinitionContext context)
{
context.CreatePermission(PermissionNames.Pages_Users, L("Users"));
context.CreatePermission(PermissionNames.Pages_Roles, L("Roles"));
context.CreatePermission(PermissionNames.Pages_Tenants, L("Tenants"), multiTenancySides: MultiTenancySides.Host);
context.CreatePermission(PermissionNames.Pages_Events, L("Events"), multiTenancySides: MultiTenancySides.Tenant);
}
其次,[AbpAuthorize]
与
[AbpAuthorize(PermissionNames.Pages_Tenants)]
我在活动服务中找到了那些 (first link and second link),
[AbpAuthorize]
public class EventAppService : EventCloudAppServiceBase, IEventAppService
{
private readonly IEventManager _eventManager;
private readonly IRepository<Event, Guid> _eventRepository;
并在 TenantService 中
[AbpAuthorize(PermissionNames.Pages_Tenants)]
public class TenantAppService : AsyncCrudAppService<Tenant, TenantDto, int, PagedResultRequestDto, CreateTenantDto, TenantDto>, ITenantAppService
{
private readonly TenantManager _tenantManager;
这是我想要并期望在我的多租户 Saas 中实现权限的内容 (Core + Angualr SPA) ...
会有不同的功能(我说的是模块),包括事件(CRUD
)、图书馆(CRUD
)、考试(CRUD
)、结果(CRUD
)、出勤(CRUD
) 并且我希望拥有租户超级管理员的完全访问权限 (CRUD
)(默认情况下在创建租户时分配),然后超级管理员可以创建角色(分配的模块和权限(CRUD
) 到特定模块)。
为简单起见,如果系统有出勤 module/feature,则默认情况下,租户的 Superadmin
将拥有完整的 CRUD
访问权限,而如果 Staff
角色已创建并受到限制CR
但不允许 UD
。
我已经完成了 this 教程,但无法整理。
谢谢。
Firstly, what's the difference between
MultiTenancySides.Host
andMultitenancySides.Tenant
?
MultiTenancySides.Host
→ 只能分配给主机用户(user.TenantId == null
)。
MultiTenancySides.Tenant
→ 只能分配给租户用户(user.TenantId != null
)。
Secondly, how
[AbpAuthorize]
differs from[AbpAuthorize(PermissionNames.Pages_Tenants)]
?
[AbpAuthorize]
→ 用户已登录。
[AbpAuthorize(PermissionNames.Pages_Tenants)]
→ 用户已登录并拥有该权限。