forked from gongxuegit/tiku-backend.net
feat: harden SaaS authentication and authorization
This commit is contained in:
64
Tiku.Application/Security/BackendPermissions.cs
Normal file
64
Tiku.Application/Security/BackendPermissions.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
namespace Tiku.Application.Security;
|
||||
|
||||
public static class BackendPermissions
|
||||
{
|
||||
public const string TenantDashboardView = "tenant:dashboard:view";
|
||||
public const string TenantStaffManage = "tenant:staff:manage";
|
||||
public const string TenantRoleManage = "tenant:role:manage";
|
||||
public const string TenantStudentManage = "tenant:student:manage";
|
||||
public const string TenantContentManage = "tenant:content:manage";
|
||||
public const string TenantSettingsManage = "tenant:settings:manage";
|
||||
public const string TenantProviderManage = "tenant:provider:manage";
|
||||
public const string TenantCommerceOperate = "tenant:commerce:operate";
|
||||
public const string TenantCrmManage = "tenant:crm:manage";
|
||||
public const string TenantCommissionManage = "tenant:commission:manage";
|
||||
public const string TenantJobManage = "tenant:job:manage";
|
||||
|
||||
public const string PlatformDashboardView = "platform:dashboard:view";
|
||||
public const string PlatformTenantManage = "platform:tenant:manage";
|
||||
public const string PlatformStaffManage = "platform:staff:manage";
|
||||
public const string PlatformRoleManage = "platform:role:manage";
|
||||
public const string PlatformQuestionBankManage = "platform:question-bank:manage";
|
||||
public const string PlatformAuditView = "platform:audit:view";
|
||||
|
||||
public static readonly IReadOnlySet<string> Tenant = new HashSet<string>(StringComparer.Ordinal)
|
||||
{
|
||||
TenantDashboardView,
|
||||
TenantStaffManage,
|
||||
TenantRoleManage,
|
||||
TenantStudentManage,
|
||||
TenantContentManage,
|
||||
TenantSettingsManage,
|
||||
TenantProviderManage,
|
||||
TenantCommerceOperate,
|
||||
TenantCrmManage,
|
||||
TenantCommissionManage,
|
||||
TenantJobManage
|
||||
};
|
||||
|
||||
public static readonly IReadOnlySet<string> Platform = new HashSet<string>(StringComparer.Ordinal)
|
||||
{
|
||||
PlatformDashboardView,
|
||||
PlatformTenantManage,
|
||||
PlatformStaffManage,
|
||||
PlatformRoleManage,
|
||||
PlatformQuestionBankManage,
|
||||
PlatformAuditView
|
||||
};
|
||||
|
||||
public static void EnsureTenant(string permissionCode)
|
||||
{
|
||||
if (!Tenant.Contains(permissionCode))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(permissionCode), permissionCode, "Unknown tenant permission.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnsurePlatform(string permissionCode)
|
||||
{
|
||||
if (!Platform.Contains(permissionCode))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(permissionCode), permissionCode, "Unknown platform permission.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user