Skip to content

EsmAccessControlOptions class

namespace: Serenity.Web   assembly: Serenity.Net.Web

Options for the ESM access control (see UseEsmAccessControl), which serves the ES modules and chunks under an esm folder (e.g. /esm/ or /Serenity.Extensions/esm/) only to users who may load an entry point (e.g. a page module) that needs them, using the build.esm-manifest that tsbuild writes next to them.

public class EsmAccessControlOptions

Public Members

name description
EsmAccessControlOptions() The default constructor.
AnonymousPaths { get; set; } Semicolon separated patterns of the entry points (or other files) that anonymous users can load, e.g. the login page. The files that these entry points reach are public too.
DefaultPermission { get; set; } The permission of entry points that do not match any other rule. Default is "?", e.g. logged-in users. Like other permissions, an empty value is invalid and denies access.
Enabled { get; set; } Whether the ESM access control is enabled. Default is false.
Permissions { get; set; } Optional patterns of entry points mapped to the permission (or permission expression) required to load them, e.g. { "Modules/Administration/**": "Administration:General" }. When a path matches more than one pattern, the longest pattern wins. Empty by default, in which case entry points that are not anonymous use DefaultPermission. Note that a page may load modules of another page, e.g. to open a dialog of another module, which fails for users without the permission of that module.
const SectionKey The default section key in appsettings.json

Remarks

Each file is served if the user has the permission of at least one entry point that reaches it via its imports. The permission of an entry point is, in order:

  1. the Permission if it is a layout module,
  2. "*" (public) if it matches AnonymousPaths,
  3. the permission of the longest matching pattern in Permissions, if any,
  4. DefaultPermission.

So unless Permissions is set, anonymous users only get the anonymous and layout module files, while logged-in users get all of them. A file that is not in the manifest is treated as an entry point of its own. Files of an esm folder without a manifest are served as before.

Patterns are semicolon separated globs (*, **, ?), case-insensitive, relative to the esm folder (e.g. Modules/Membership/**), or the full request path if they start with a slash (e.g. /Serenity.Extensions/esm/Modules/Membership/**).

See Also