cogExtra Configuration APIs related to platform concepts (e.g. user references)
TypeJAR
Developed by

XWiki Development Team

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Description

See the Configuration API for general configuration concepts.

Configuration Permissions

It's possible to implement permission checking for ConfigurationSource properties, to decide who has the rights to view or modify them.

To implement this check for your ConfigurationSource component, you need to implement the following component role:

@Role
public interface ConfigurationSourceAuthorization
{
   /**
     * @param key the key for which to check the access right for
     * @param userReference the reference to the user to check for permissions
     * @param right the right to check (e.g. {@code AccessRight.READ})
     * @return true if the property can be accessed for the passed right (e.g. READ or WRITE)
     */

   boolean hasAccess(String key, UserReference userReference, ConfigurationRight right);
}

Where ConfigurationRight is defined as:

public enum ConfigurationRight
{
   /**
     * The configuration can be read from.
     */

    READ,

   /**
     * The configuration can be written to.
     */

    WRITE
}

At the moment, your implementation of ConfigurationSourceAuthorization is not called automatically by the ConfigurationSource, so you'll need to perform the call yourself to check for the rights.

Tags:
Created by Vincent Massol on 2020/05/13 11:49
    

Get Connected