oat-sa/tao-core

TAO core extension

Installs: 72 557

Dependents: 61

Suggesters: 0

Security: 0

Stars: 44

Watchers: 49

Forks: 28

Open Issues: 59

Type:tao-extension

v48.83.0 2022-01-21 15:23 UTC

This package is auto-updated.

Last update: 2022-01-22 01:31:59 UTC


README

Task Queue Doc

Middlewares Doc

Feature flag

You can now define feature flag in environment global variables.

How to use it

You can use feature flag to easily switch off/on parts of TAO functionality.

Feature flag name

It is import tht we will use FEATURE_FLAG prefix for our feature flags to recognise them and they prupose in environment variable list.

AbstractFeatureFlagFormPropertyMapper

To hide/show form fields you can extend AbstractFeatureFlagFormPropertyMapper with your configurable service that has OPTION_FEATURE_FLAG_FORM_FIELDS mapped to list of fields that you want to hide/show.

<?php
use oat\taoLti\models\classes\LtiProvider\FeatureFlagFormPropertyMapper;    

return new FeatureFlagFormPropertyMapper(
    [
        FeatureFlagFormPropertyMapper::OPTION_FEATURE_FLAG_FORM_FIELDS => [
                'formField_01' => [
                    'FEATURE_FLAG_NAME'
                ]
            ]
    ]
);

This configuration will display formField_01 when FEATURE_FLAG_NAME is enabled

SectionVisibilityFilterInterface

tao/SectionVisibilityFilter is responsible for listing sections that can be disabled from user. In order to add more sections that have to be disabled/enabled based on feature flag.

<?php

return new oat\tao\model\menu\SectionVisibilityFilter(array(
    'featureFlagSections' => [
        'sectionName' => [
            'FETURE_FLAG_01'
        ]
    ]
));

This configuration will display sectionName when FETURE_FLAG_01 is enabled.

Webhooks

Description

Webhooks allow you to send a request to remote server based on triggered event

How to use it

Register event webhook.

use command \oat\tao\scripts\tools\RegisterEventWebhook to register events that are implementing \oat\tao\model\webhooks\configEntity\WebhookInterface interface.

i.e:

$ php index.php 'oat\tao\scripts\tools\RegisterEventWebhook' 
    \ -u "https://example.com"
    \ -m "POST"
    \ -e "<<Class FQN>>"

Check ACL Permissions

In order to check ACL permissions, you can use the PermissionChecker:

$permissionChecker = $this->getServiceLocator()->get(oat\tao\model\accessControl\PermissionChecker::class);

$permissionChecker->hasWriteAccess('resourceId');
$permissionChecker->hasReadAccess('resourceId');
$permissionChecker->hasGrantAccess('resourceId');

Important: It takes into consideration the current user in the session, if no user is provided.

Roles Access (rules and action permissions)

Description

Script allow you to apply (add)/revoke (remove) list of rules and/or permissions to a specific roles and actions.

How to use it

Execute the following command to apply (add) new rules/permissions:

$ php index.php 'oat\tao\scripts\tools\accessControl\SetRolesAccess' \
--config [config.json|json_string]

If you want to revoke (remove) them, add --revoke flag:

$ php index.php 'oat\tao\scripts\tools\accessControl\SetRolesAccess' \
--revoke \
--config [config.json|json_string]

Config example

{
    "rules": {
        "role": [
            {
                "ext": "extensionIdentifier",
                "mod": "actionControllerName",
                "act": "actionMethodName"
            }
        ]
    },
    "permissions": {
        "controller": {
            "action": {
                "rule1": "READ",
                "rule2": "WRITE"
            }
        }
    }
}

Environment variables

Here you can find the environment variables including feature flags

Variable Description Default value
FEATURE_FLAG_LISTS_DEPENDENCY_ENABLED Enable Remote Lists Dependency feature -
FEATURE_FLAG_ADVANCED_SEARCH_DISABLED Disable advanced search feature, if set to 1 -
FEATURE_FLAG_STATISTIC_METADATA_IMPORT Enable statistics metadata import -

Routing

Check more information about actions/controllers and routing here