Apache Sling Capabilities

Clone this repo:
  1. 4541d86 SLING-12094 - Use GitHub for the Maven scm.url value by Robert Munteanu · 9 months ago master
  2. ec39408 SLING-11709 - Set up Jira autolinks to all Sling Github projects by Robert Munteanu · 1 year, 4 months ago
  3. 5ec172b SLING-11051 - Fixing JavaDoc badge by Dan Klco · 2 years, 6 months ago
  4. f5190cb SLING-10676 - remove SECURITY.md which is not needed by Bertrand Delacretaz · 3 years ago
  5. d37eff5 SLING-10676 - add or update SECURITY.md by Bertrand Delacretaz · 3 years ago

Apache Sling

Build Status Test Status Coverage Sonarcloud Status JavaDoc Maven Central License

Sling Capabilities Module

This module is part of the Apache Sling project.

The servlet provided by this module allows for creating Capabilities HTTP endpoints on a Sling instance: Resources that provide information on which services are available, version levels etc.

The example configuration below shows the JSON vocabulary used to expose capabilities.

For now, we have one module which provides a CapabilitiesSource, that's the sling-org-apache-sling-capabilities-jcr module which provides information on the JCR repository.

CapabilitiesSource services

Services that implement the CapabilitiesSource interface provide capabilities.

Each service must have its own unique namespace, used to split the capabilities in categories that can be provided separately (see below):

@ProviderType
public interface CapabilitiesSource {
    /** @return the namespace to use to group our capabilities.
     *  That name must be unique in a given Sling instance.
     */
    String getNamespace();

    /** Return zero to N capabilities, each being represented by
     *  a key/value pair.
     *
     *  Services implementing this interface must be careful to
     *  avoid crossing trust boundaries. They should only expose data that
     * is accessible to the ResourceResolver that's passed
     *  as a parameter.
     *
     * @return a Map of capabilities
     * @param resolver used to establish the user's identity
     * @throws Exception if the capabilities could not be computed.
     */
      Map<String, Object> getCapabilities(ResourceResolver resolver) throws Exception;
}

This module does not provide any CapabilitiesSource service, but an example SlingServletsSource is provided in the test code.

The sling/capabilities resource type

To act as an endpoint for capabilities a resource must have the sling/capabilities resource type.

A required property named namespace_patterns must be present, containing 1..N Java regexp patterns to select which capabilities namespaces are exposed by this resource.

As an example, a resource that causes capabilities with the org\.apache\.sling\.servlets\.test[A|B] namespace regexp to be output (assuming a CapabilitiesSource that provides them is available) can be created as follows:

curl -u admin:admin \
  -Fsling:resourceType=sling/capabilities \
  -Fnamespace_patterns='org\.apache\.sling\.servlets\.test[A|B]' \
  http://localhost:8080/var/capabilities/caps