文章出處

Security Permissions Caching

 

Security permission caching is implemented in Security Adapters - classes used by the Security System to process and cache security permission requests. Each Security Adapter has the corresponding Security Adapter Provider class, which is used internally to register the adapter. XPO adapters and their providers are located in the DevExpress.ExpressApp.Security.Xpo.v17.1.dll assembly. The provider and adapter for the Entity Framework are available in the DevExpress.ExpressApp.Security.EF.v17.1.dll assembly. Both these assemblies (XPO and EF) contain the SecurityAdapterHelper class that exposes static methods that enable/disable Security Adapters. So, in your code, you do not need to access Security Adapters directly. This topic describes how to enable and customize caching using the SecurityAdapterHelper class.

Security Adapters中實現了權限系統緩存, 權限系統用于處理和緩存安全權限請求的類。每個安全適配器都有相應的安全適配器提供程序類, 它在內部用于注冊適配器。適用于xpo的adapters在DevExpress. ExpressApp 安全. xpo. v17.1 .dll 程序集中。EF的Adapters在 DevExpress. ExpressApp. v17.1 .dll 程序集的安全。這些程序集 (xpo 和 ef) 都包含 SecurityAdapterHelper 類, 它公開了啟用/禁用安全適配器的靜態方法。因此, 在代碼中, 不需要直接訪問安全適配器。本主題介紹如何使用 SecurityAdapterHelper 類啟用和自定義緩存。

Expanded Enable Caching in Code

 

 

When creating a new XAF project, caching is enabled by the Solution Wizard. The wizard adds the following code line to the WinApplication.cs (WinApplication.vb) and WebApplication.cs (WebApplication.vb) files.

新建項目時,可以在創向導中選擇這個選薦.也可以在代碼中修改.(winapplication.cs/webapplication.cs)中:

using DevExpress.ExpressApp.Security;
// ... 
SecurityAdapterHelper.Enable();

 


in the constructor of your platform-agnostic module located in the Module.cs (Module.vb) file;To enable or customize Security permissions caching in an existing application, use the same code, or use another overload of the Enable method that takes an ReloadPermissionStrategy enumeration value. You can call this static method from any place of your code, which is executed before a user is logged on, e.g.:

  • in the Main method of the WinForms application located in the Program.cs (Program.vb) file, before the WinApplication.Start call;
  • in the Application_Start method of the ASP.NET application located in the Global.asax.cs (Global.asax.vb) file, before the WebApplication.Start call.

The Solution Wizard uses the second and third locations.

 

若要在現有應用程序中啟用或自定義安全權限緩存, 請使用相同的代碼, 或使用采用 ReloadPermissionStrategy 枚舉值的啟用方法的另一個重載。您可以從代碼的任何位置調用此靜態方法 (在用戶登錄之前執行), 例如:

 

在您的平臺不可知模塊的構造器中, 位于 Module.cs (模塊. vb) 文件中;
在 winforms 應用程序的 main 方法中, 位于 Program.cs (程序. vb) 文件中, 在 WinApplication 之前. 開始呼叫;
 

Expanded Reload Permission Strategies

 

 

Security Adapters support various modes of reloading the security permissions. The available modes are listed in the ReloadPermissionStrategy enumeration. There is an overload of the SecurityAdapterHelper.Enable method that takes the reloadPermissionStrategy parameter - use it to change the mode. By default, the NoCache mode is used. Each Session (in XPO) or DBContext (in Entity Framework) operates with the most recent permissions loaded from the database in this mode. You can use the CacheOnFirstAccess mode instead. Permissions are loaded and cached when the corresponding secured data is accessed for the first time, cached permissions are used until the user is logged off in this mode. This mode allows you to significantly reduce the number of database requests when working with secured data.

 

安全適配器支持各種重新加載安全權限的模式。可用模式在 ReloadPermissionStrategy 枚舉中列出。SecurityAdapterHelper 的重載. 啟用采用 reloadPermissionStrategy 參數的方法-使用它來更改模式。默認情況下, 使用緩存模式。每個會話 (在 xpo 中) 或 DBContext (在實體框架中) 都使用此模式中從數據庫加載的最新權限。您可以改用 CacheOnFirstAccess 模式。當第一次訪問相應的安全數據時, 將加載和緩存權限, 直到用戶在此模式下注銷時才使用緩存的權限。此模式允許您在使用安全數據時顯著減少數據庫請求的數量。


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()