Search Results for

    Show / Hide Table of Contents

    Access rule

    Introduction

    Access rules are designed to control user access to worker sites, pages, and widgets.

    Rule syntax

    Keywords

    You can use the following keywords to work with access rules:

    Name Type Description
    @user DslUser The user in context.
    @apiFactory IManagedApiFactory To construct Casewhere API objects. Read here for the full list of available Apis

    A DslUser object has the following properties:

    Name Type Description
    UserId string Id of the user.
    Username string Username used for login.
    Has bool (string claimType) A method used to determine if the user has a claim or not.
    Contains bool (string claimType, string value) A method used to determine if the user has a claim value or not.
    WorkerSite DslWorkerSite The worker site in context.

    A DslWorkerSite object has the following properties:

    Name Type Description
    Name string Name of the worker site. Worker site name must be unique.
    DomainName string Domain of the worker site.
    TimezoneId string Standard name of the timezone object retrieved from TimeZoneInfo.GetSystemTimeZones. For example, Romance Standard Time,
    TimezoneOffset double A number indicates the time difference in minutes between the current time zone's standard time and Coordinated Universal Time (UTC).
    ShortDate string Short date format. For example: dd.MM.yyyy
    LongDate string Long date format. For example: dd.MM.yyyy HH:mm
    DecimalSeparator string It could be "," or "." depending on the configuration.
    ThousandSeparator string It could be "," or "." depending on the configuration.

    Examples

    Example 1

    Role-based access control – Only users having a specific role can access the resource.

    @user.Contains("Role", "Manager")
    

    Example 2

    Only whitelisted users can access the resource.

    #predicate
     
    var dataApi = @apiFactory.Get<IDataApi>();
    var filter = FilterBuilder.Create().Eq("Username", @user.Username).Eq("Active", true).Build();
    var found = dataApi.Any("WhitelistedUsers", filter);
     
    return found;
    

    Example 3

    #predicate
     
    var dataApi = @apiFactory.Get<IDataApi>();
    var filter = FilterBuilder.Create().Eq("Username", @user.Username).Eq("Active", true).Build();
    var found = dataApi.Any("WhitelistedUsers", filter);
     
    return found;
    
    In This Article
    Back to top Generated by DocFX