Prior to version , data security was configured within the technical administration and required programming skills to define security rules.

Starting from version , application provides a mechanism for securing data access without requiring access to the technical admin interface, nore specific programming knowledge.

Requirements

Overview

Permissions pkgsecupermission

A permission represents an authorized action.

Permission are defined by giving a functional name (property name) and a permission key (property permission).

A permission grants a right for a context. The given right is resolved by analyzing the permission property. Permission follows the following pattern:

<version>/<domain>/<action>/[modifiers]+

For instance named “Update owned offline“ with permission v1/objectdata/update/$offline/$selfownermeans that a user having this permission on an object is allowed to update instances in an offline status (status is not online and not archived) that he owns object.owner == surfer.id

Patterns

Modifiers

Each modifier supports specific keywords to finely define the context.

boardVisibility

Allows to limit permission based on boards visibility:

boardType

Allows to limit permission based on the type of board:

creationMode

Creation mode represents how the instance is created. 3 keywords are available:

workflowAction

Workflow action represents the action that is performed on the object from a workflow perspective. 6 keywords are available:

instanceStatus

Instance status represents the current status of the object from a workflow perspective. 5 keywords are available:

ownership

Ownership allows to limit a permission to the owner property of an instance. 2 keywords are available

Groups pkgsecugroup

Groups allow to centralize multiple permissions on one or many obects, for one or many roles and one or many users.

When defining a group as a template, properties objectsselector, roles and users will not be editable anymore. Creating templates is quite handy as you can think about it as being a group of permissions. It is recommended to create templates such as “[VIEWER]“, [CONTRIBUTOR]” or “[MANAGER]” and to link the typical permissions granted to such a group.

To avoid security issues, not all structures are eligible to this mechanism. To be able to grant a permission on a structure, the table MUST have the appropriate tags.

It is not possible to add users through their group. Users can only be assigned through their role or directly

Identifying eligible structures

Structures eligibles to permission granting are marked with one or multiple table tags :

pkg/security/secugroup/<action> or pkg/security/secugroup/all

this means that to be able to manage view permissions on object foo, foo table configuration must have either pkg/security/secugroup/view or pkg/security/secugroup/all

Installing the feature

Initializing data

The default NAR file contains the required structures for managing the rights, but to ease migrations, and upgrades, the NAR file does not contains neither permissions definitions nor groups:

Providing default values would force some ids with functional meanings on permissions, groups, roles and eventually users, which is obviously not desired as each projects needs defines different roles, each project will make use of some permissions, but not all the possible ones…

Additionally, delivering configured permissions or groups directly in the NAR file would increase migration complexity as product added permissions and product added groups might come in conflict with projects definitions.

As the whole system only relies on permission strings, a service API is provided to “fill the gap” between actual values in DB and what the product team recommends to create:

/api/packaged/admin/security/update

This API requires Administrators or TestOperators HTTP role to be executed as well as the right to create instances of pkgsecupermission and pkgsecugroup

This API will check current data in pkgsecupermission and pkgsecugroup and create missing data in both structures. Additional information is provided in the swagger UI.

Product team will only provide templates for groups. Product team will always give template names with brackets.

It is recommended to identify project specific template with either a prefix or a suffix

Make usage of the permissions

Permissions handled by the plugin are just a tool allowing to give you more flexibility to your rules, but they can be combined with any project specific rules.

The plugin provides a security macro per domain with the camel-cased name pkg<version><domain>. These macro will be installed first time you activate the plugin.

You will need to make usage of these macros in your security rules:

For instance on objectdata/update, you can define a single rule “Packaged updates“ with following code:

@pkgV1Objectdata('update')

Of course you might have more specific rules regarding users' rights on specific objects, but you can always use the macros as a starting point:

For instance, this call is perfectly fine

STRUCTUREHASTAG(objectname, 'damobject')
AND
NBCOMMONELEMENTS(object.someproperty, surfer.someproperty) > 0
AND 
@pkgV1Objectdata('update')

You could even add additional rules like to be able to update an object, you should be allowed to view it. In such a case, the rule could be written as

In objectdata/update, rule “To update, must also be allowed to view”

@pkgV1Objectdata('view') AND @pkgV1Objectdata('update')

Extending capabilities

Meta statuses definitions

Quite often, you will need to identify workflow statuses as specific, but will not be able to rely on native keywords. For instance, you might want to identify what are the “validation steps” to be able to create permissions that will only apply to those statuses.

You can achieve this by configuring the plugin parameter meta_statuses:

This parameter is JSON. It accepts either null or a JsonObject.

If null, then no specific “metastatuses” are defined.

If a JsonObject, each key is a metaStatus name (exemple: “validationStep”). Associated value can be either

Custom permission resolver

It is possible to configure a specific groovy script to resolve permissions in the surfer:

In plugin, configure custom_permissions_builder to the SAN based groovy script path to your desired implementation. (When saving, the groovy script will be created if not exists, with sample code)

Troubleshooting

Datamodel compliance

You can check the compliance of your data model by accessing

/api/packaged/admin/security/validators/model/html

Testing a user

You can check what the plugin has resolved for a user by calling

/api/packaged/admin/security/surfer-keys/<userId>

Cheat sheet

Find for each managed domain / action, the permission pattern

domain

action

permission pattern

boards

makePublicBoard

v1/boards/makepublicboard

boards

shareBoard

v1/objectdata/shareboard/:boardVisibility/:boardType/:ownership

objectdata

changeStatus

v1/objectdata/changestatus/:workflowAction/:instanceStatus/:ownership

objectdata

delete

v1/objectdata/delete/:instanceStatus/:ownership

objectdata

i18nFieldsTranslate

v1/objectdata/i18nfieldstranslate/:instanceStatus/:ownership

objectdata

insert

v1/objectdata/insert/:creationMode

objectdata

order

v1/objectdata/order/:instanceStatus/:ownership

objectdata

retrieveCaption

v1/objectdata/retrieveCaption/:instanceStatus/:ownership

objectdata

update

v1/objectdata/update/:instanceStatus/:ownership

objectdata

view

v1/objectdata/view/:instanceStatus/:ownership

Find available values for modifiers

modifier

value

description

boardVisibility

$publicboard

A board that is not private

$privateboard

A private board

$anyvisibilityboard

A board private or not

boardType

$anyboardtype

Any type of board

<type>

A board of type <type>

creationMode

$newcreation

Only fresh new instances

$copycreation

Only copies

$anycreation

Any mode

instanceStatus

$online

An online marked state

$archived

An archived marked state

$offline

A state that is neither marked online not archived

$initialstatus

The initial state of the instance (usually = 2)

$anystatus

Any state

<customMetaStatus>

A custom meta state

ownership

$selfowner

User must be the owner of the instance to be able to perform an action

$anyowner

No restriction on ownership

$boardcollaborator

Specific to boards domain - Identify the surfer as a collaborator on a board

workflowAction

$publish

Publishing action: performing a workflow action that will move the instance in an online marked state

$archive

Archiving action: performing a workflow action that will move the instance in an archived marked state

$forward

Forward action: performing an action marked forward, and that will not lead to online or archived marked state.

$backward

Backward action: performing an action NOT marked forward, and that will not lead to online or archived marked state.

$process

Any process action: performing that will not lead to online or archived marked state.

$anyaction

Any workflow action (including publishing and archiving actions)

<actionName>

If none of the above keywords, the action name is taken as is and resolved base on the instance’s workflow