Security Permissions Caching

  • 2 minutes to read

The Security System uses Security Adapters to process and cache security permission requests. Each Security Adapter has the corresponding Security Adapter Provider used internally to register the Adapter. The following assemblies contain platform-dependent Adapters and their Providers.

  • XPO - DevExpress.ExpressApp.Security.Xpo.v20.1.dll
  • Entity Framework - DevExpress.ExpressApp.Security.EF.v20.1.dll

These assemblies provides you with the RegisterXPOAdapterProviders and RegisterEFAdapterProviders methods that extend the SecurityStrategy class. Use these methods to enable/disable Security Adapters instead of accessing them directly.

This topic describes how to determine a way an application with SecurityStrategyComplex caches permissions.

Enable the Security Adapter

The Solution Wizard adds the following platform-dependent code to enable the Security Adapter in new XAF projects.

  • eXpress Persistent Objects

    using DevExpress.ExpressApp.Security;
    // ...
  • Entity Framework

    using DevExpress.ExpressApp.Security;
    // ...

This code is added to the following places depending on the application's platform.





Program.cs (Program.vb)

the application's Main method, before the WinApplication.Start call


Global.asax.cs (Global.asax.vb)

the application's Application_Start method, before the WebApplication.Start call


MobileApplication.cs (MobileApplication.vb)

the application's constructor

Set the Permissions Reload Mode

You can specify how Security Adapters reload security permissions. To do this, set the SecurityStrategyComplex's PermissionsReloadMode property to the PermissionsReloadMode enumeration value. The default mode is NoCache. In this mode, the cache is created for each Session (in XPO) and DBContext (in EF). Switch to the CacheOnFirstAccess mode to load and cache permissions when secured data is accessed for the first time and use these permissions until a user is logged off. This mode allows you to reduce the number of database requests when working with secured data.