首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> .NET 網頁程式設計 >> 關於.NET

OpenExpressApp 平台:功能權限管理實作(Command 控制與模組存取)

     編輯:關於.NET

承接使用者管理,OEA 以「部門+崗位=角色」模型實作功能權限。權限對象 OrgPositionOperation 關聯 CommandBase,涵蓋工具列按鈕、右鍵選單等所有 UI 指令。

權限設定介面 (PBS 模板)

PBS 模板介面 功能權限設定

  • 左側列出所有模組,右側列出模組下可控制的 Command。
  • 根節點自動包含「開啟模組」內建權限。
  • 設定後,AutoUI 自動隱藏無權限的指令。

自動 UI 產生時的權限檢查

private static void CreateCommandsForToolBar(ToolBar toolbar, Type boType, ObjectView view, BoInfoOperationList commands) {
    foreach (var cmd in commands) {
        var command = cmd.Operation.Command;
        // 權限檢查
        if (!(Csla.ApplicationContext.User.Identity as OEAIdentity).HavePermissionOnOperation(boInfo.Id, new Guid(command.Id)))
            continue; // 無權限則跳過不產生 UI 元素
        // ... 建立按鈕/選單項目
    }
}

模組存取權限:「開啟模組」控制

登入時依使用者權限動態產生模組清單:

IList<BusinessObjectInfo> modules = new List<BusinessObjectInfo>();
if (Csla.ApplicationContext.User.Identity.IsAuthenticated) {
    foreach (var item in ApplicationModel.Modules) {
        if ((Csla.ApplicationContext.User.Identity as OEAIdentity).HavePermissionOnOperation(item.Id, new Guid(CommandNames.OpenModule)))
            modules.Add(item);
    }
}

完整模組列表 部門管理功能權限 移除開啟模組權限後的列表

移除「開啟模組」權限後,該模組從主選單消失,實現模組層級存取控制。下一篇將介紹資料權限(Row-Level Security)。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved