Skip to content

Proposal: optional PAP change listener for policies, PDP configuration and attribute providers #74

Description

@mikfaretta

Proposal: optional PAP change listener for policies, PDP configuration and attribute providers

Hello maintainers,

We would like to contribute a small, optional extension point to AuthzForce Server and would appreciate your feedback before implementing a PR.

Our use case is a central AuthzForce PAP with embedded AuthzForce PDPs in downstream services. We want to notify those services when relevant PAP operations succeed, while keeping messaging libraries and delivery infrastructure outside AuthzForce Server.

Proposed scope

Introduce a framework-independent Java listener and immutable event, for example:

public interface PapChangeListener {
    void papChanged(PapChangeEvent event);
}

Names and API details are open for discussion. The event would identify the domain, operation type, and policy ID/version where applicable, with an event identifier and timestamp. We would avoid including sensitive attribute-provider configuration in notification payloads.

The initial scope would cover:

  • Addition of a policy/version.
  • Removal of a policy version or all versions of a policy.
  • Changes to PDP configuration, including the root policy reference.
  • Changes to attribute-provider configuration.
  • Domain deletion, if you consider it appropriate for this contract.

Attribute-provider configuration changes are in scope; changes to external data queried by a provider are not.

Events would describe successful PAP operations, rather than claim that every added policy version becomes active. Rejected requests, conflicting policy versions and not-found deletions would not emit successful-change events.

Candidate integration points

In the local checkout reviewed (server 12.1.1-SNAPSHOT), the candidate methods are:

  • DomainResourceImpl.addPolicy()
  • DomainResourceImpl.updateOtherPdpProperties()
  • DomainResourceImpl.updateAttributeProviderList()
  • DomainResourceImpl.deleteDomain()
  • PolicyResourceImpl.deletePolicy()
  • PolicyVersionResourceImpl.deletePolicyVersion()

Notification would occur after the DAO call and its result checks. For example, addPolicy() must check for a conflicting policy before emitting an event.

We propose keeping these hooks in the server API layer to avoid changes to the PDP engine or the flat-file persistence component. This deliberately scopes notifications to operations performed through the PAP API, rather than all underlying filesystem changes or individual automatic version-rolling effects.

The implementation would also require bounded changes to resource factories/constructors to propagate the notifier and domain context. We would preserve existing construction paths where feasible.

Configuration and extension packaging

The listener would be optional, with no notifications or additional behavior when none is configured. We propose using the existing Spring wiring in the webapp to register external listener implementations, with a documented configuration extension point.

An integrator could compile a listener in a separate JAR and deploy it with its dependencies in the web application's classpath. Deployment/repackaging and restart may be necessary, but changing an implementation would not require modifying AuthzForce source code.

No new third-party runtime dependency would be needed for the upstream hook. Broker clients, persistent event queues, publishers, retries and consumers would remain in external integrations.

For the initial contract, we suggest a synchronous callback that should finish promptly. Listener runtime failures would be logged without changing an already-successful PAP operation into an HTTP failure. The latency, concurrency and exception semantics would be documented and tested; we welcome your preference here.

Reliability boundaries

This proposal is not a transactional outbox or a delivery guarantee. A process failure between policy persistence and listener execution can lose a notification. A persistent queue populated by a listener only protects events successfully recorded in that queue.

Our downstream integration would combine push notifications with startup and periodic reconciliation against the PAP to recover the current policy/configuration state. This provides eventual convergence after recovery, not preservation of every intermediate change or immediate revocation during a missed notification.

No changes to the policy storage format, DAO persistence protocol or PDP evaluation engine are proposed.

Validation

We would add tests for successful operations, conflicts and failed operations, no-listener behavior, listener exceptions, and correct domain context under concurrent requests, using the existing test infrastructure.

Feedback requested

  1. Would you consider a server-level PAP change listener within this scope suitable for an upstream PR, or is there an existing extension point you would recommend?
  2. Do the proposed operation coverage and API-layer hook locations make sense, especially for attribute-provider and root-policy configuration changes?
  3. What package/API placement and external-listener configuration mechanism would you prefer?
  4. Would the proposed callback and error-handling semantics be acceptable?

We are happy to adjust the design before implementing the contribution. If another tracker or discussion channel is preferred, please let us know.

Activity

  1. added theissue type on Oct 18, 2026
  2. cdanger commented on Oct 18, 2026

    @cdanger
    Member
    1. Would you consider a server-level PAP change listener within this scope suitable for an upstream PR, or is there an existing extension point you would recommend?
    

    Yes, that's a good case for a PR indeed. There's no extension point for this at the moment.


    2. Do the proposed operation coverage and API-layer hook locations make sense, especially for attribute-provider and root-policy configuration changes?
    

    Yes, it makes sense to me, adding the hooks into the DomainResourceImpl, PolicyResourceImpl and PolicyVersionResourceImpl classes for the new listener.


    3. What package/API placement and external-listener configuration mechanism would you prefer?
    

    For the configuration, the way I see it, you add a new constructor argument to the DomainsResourceImpl class for passing the PapChangeListener instance (which the modified DomainsResourceImpl can then pass down to DomainResourceImpl, PolicyResourceImpl, etc.) . Then you modify the domainsResourceBean declaration in the Spring XML config (/webapp/src/main/webapp/WEB-INF/beans.xml) to make this argument value configurable:

    <!-- ...content omitted... -->
    <!-- I recommend using JNDI environment variables. However, if you have to use system environment variables or JVM system properties instead for some reason, I don't mind, but then you don't need the line below. -->
    <jee:jndi-lookup id="jndi_papChangeListenerClass" jndi-name="org.ow2.authzforce.rest.service.PapChangeListener.class" expected-type="java.lang.String" default-value="" />
    
    <!-- ...content omitted... -->
    
     <bean id="domainsResourceBean" class="org.ow2.authzforce.rest.service.jaxrs.DomainsResourceImpl">
          <constructor-arg name="domainsDao" ref="domainsDaoBean" />
          <constructor-arg name="authorizedResourceAttribute" value="authorizedResource" />
          <constructor-arg name="anyResourceId">
             <null />
          </constructor-arg>
           <constructor-arg name="papChangeListener">
             <bean class="#{ jndi_papChangeListenerClass == ''? null: jndi_papChangeListenerClass }"/>
             <!-- If the PapChangeListener class is passed as JVM system property:  
             <bean class="#{ systemProperties['org.ow2.authzforce.rest.service.PapChangeListener.class'] }"/>
             -->
             <!-- If the PapChangeListener class is passed as system environment variable:  
             <bean class="#{ systemEnvironment['org.ow2.authzforce.rest.service.PapChangeListener.class'] }"/>
             -->
          </constructor-arg>
       </bean>
    
    <!-- ...content omitted... -->

    If you are using a JNDI variable, you can pre-declare it with a proper description in /dist/src/webapp-context.xml, for instance:

    <!-- ...content omitted... -->
    <Environment name="org.ow2.authzforce.rest.service.PapChangeListener.class"
      description="Fully qualified name of the PAP change listener's Java class (empty string means undefined)" 
      type="java.lang.String" 
      value="" 
      override="false" />

    Then, at deployment time, this goes into /etc/tomcat11/Catalina/localhost/authzforce-ce.xml, so that users only have to change the value there to whatever custom PapChangeListener implementation class they are using. Of course, this assumes that the listener's JAR has been put somewhere on Tomcat classpath, e.g. /opt/authzforce-ce-server/webapp/WEB-INF/lib or elsewhere according to Tomcat HowTo.


    4. Would the proposed callback and error-handling semantics be acceptable?
    

    Sounds good, but I would need to look at the PR to be sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions