Class OpaInputHeadersExtension
- java.lang.Object
-
- org.sdase.commons.server.opa.extension.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 theOpaInput
.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OpaInputHeadersExtension.Builder
static interface
OpaInputHeadersExtension.ExtensionBuilder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OpaInputHeadersExtension.ExtensionBuilder
builder()
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String>
createAdditionalInputContent(javax.ws.rs.container.ContainerRequestContext requestContext)
When registered, it is called inOpaAuthFilter.filter(ContainerRequestContext)
.
-
-
-
Method Detail
-
builder
public static OpaInputHeadersExtension.ExtensionBuilder builder()
-
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 inOpaAuthFilter.filter(ContainerRequestContext)
. The return value is added as child of the property name defined during theregistration
.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 interfaceOpaInputExtension<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.
-
-