OSGi configuration
To implement Metadata-Driven Permissions a developer must deploy an OSGi configuration to AEM as a Cloud Service, that enables specific asset content or metadata properties to power metadata-driven permissions.
-
Determine which asset content or metadata properties will be used for access control. The property names are the JCR property names on the asset’s
jcr:content
orjcr:content/metadata
resource. In our case it going to be a property calledstatus
. -
Create an OSGi configuration
com.adobe.cq.dam.assetmetadatarestrictionprovider.impl.DefaultRestrictionProviderConfiguration.cfg.json
in your AEM Maven project. -
Paste the following JSON into the created file:
{ "restrictionPropertyNames":[ "status", "brand" ], "restrictionContentPropertyNames":[], "enabled":true }
-
Replace the property names with the required values. The
restrictionContentPropertyNames
configuration property is used to enable permissions onjcr:content
resource properties, while therestrictionPropertyNames
configuration property enables permissions onjcr:content/metadata
resource properties for assets.
Reset base asset permissions
Before adding restriction-based Access Control Entries, a new top-level entry should be added to first deny read access to all groups that are subject to permission evaluation for Assets (e.g. “contributors” or similar):
- Navigate to the Tools → Security → Permissions screen
- Select the Contributors group (or other custom group that all users groups belong to)
- Click Add ACE in the upper right corner of the screen
- Select
/content/dam
for Path - Enter
jcr:read
for Privileges - Select
Deny
for Permission Type - Under Restrictions, select
rep:ntNames
and enterdam:Asset
as the Restriction Value - Click Save