Class OpaInputHeadersExtension

  • All Implemented Interfaces:
    OpaInputExtension<javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String>>

    public class OpaInputHeadersExtension
    extends java.lang.Object
    implements OpaInputExtension<javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String>>
    An input extension that adds the request headers to the OpaInput.

    Header names are defined as case-insensitive by the HTTP RFC (RFC 7230 Sec. 3.2). This filter normalizes all headers to lowercase and included as:

       …,
       "headers": {
         "my-header": ["value0", "value1", "value2"],
         "another-header": ["value0,value1", "value2,value3"]
       }
     

    Headers are currently passed to OPA as read by the framework. There might be an issue with multivalued headers. The representation differs depending on how the client sends the headers. It might be a list with values, or one entry separated with a separator, for example ',' or a combination of both.

    • Method Detail

      • createAdditionalInputContent

        public javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> createAdditionalInputContent​(javax.ws.rs.container.ContainerRequestContext requestContext)
        Description copied from interface: OpaInputExtension
        When registered, it is called in OpaAuthFilter.filter(ContainerRequestContext). The return value is added as child of the property name defined during the registration.

        Example that adds the property "myExtension": true:

           public class OpaInputHeadersExtension implements OpaInputExtension<Boolean> {
             @Override
             public Boolean createAdditionalInputContent(ContainerRequestContext requestContext) {
               return true;
             }
           }
        
           // ... in your application
           OpaBundle.builder()
               // ...
               .withInputExtension("myExtension", new MyOpaExtension())
               .build();
           // ...
         
        Specified by:
        createAdditionalInputContent in interface OpaInputExtension<javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String>>
        Parameters:
        requestContext - the request context
        Returns:
        the JsonNode that should be added as child of the extension's namespace property.