Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ public enum DittoHeaderDefinition implements HeaderDefinition {
*/
ACCEPT("accept", String.class, true, false, HeaderValueValidators.getNoOpValidator()),

/**
* Header definition for the authorization header of a command.
* Making sure that it is not written to external headers to not unintentionally leak authorization information
* (bearer token or basic auth).
* <p>
* Key: {@code "authorization"}, Java type: {@link String}.
* </p>
* @since 3.8.7
*/
AUTHORIZATION("authorization", String.class, true, false, HeaderValueValidators.getNoOpValidator()),

/**
* Header definition for the reply to address. MUST be lower-case.
* "reply-to" is a standard internet message header (RFC-5322).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public final class ImmutableDittoHeadersTest {
AuthorizationModelFactory.newAuthSubject("knownRevokedSubject2"));
private static final String KNOWN_CONTENT_TYPE = "application/json";
private static final String KNOWN_ACCEPT = "application/json";
private static final String KNOWN_AUTHORIZATION = "Bearer 0815";
private static final String KNOWN_REPLY_TO = "replies";
private static final String KNOWN_ORIGIN = "knownOrigin";
private static final String KNOWN_REPLY_TARGET = "5";
Expand Down Expand Up @@ -220,6 +221,7 @@ public void settingAllKnownHeadersWorksAsExpected() {
.putHeader(DittoHeaderDefinition.LIVE_CHANNEL_CONDITION_MATCHED.getKey(),
String.valueOf(KNOWN_LIVE_CHANNEL_CONDITION_MATCHED))
.accept(KNOWN_ACCEPT)
.putHeader(DittoHeaderDefinition.AUTHORIZATION.getKey(), KNOWN_AUTHORIZATION)
.putHeader(DittoHeaderDefinition.GET_METADATA.getKey(), KNOWN_DITTO_GET_METADATA )
.putHeader(DittoHeaderDefinition.DELETE_METADATA.getKey(), KNOWN_DITTO_DELETE_METADATA )
.putHeader(DittoHeaderDefinition.DITTO_METADATA.getKey(), KNOWN_DITTO_METADATA.formatAsString())
Expand Down Expand Up @@ -533,6 +535,7 @@ public void toJsonReturnsExpected() {
.set(DittoHeaderDefinition.ORIGIN.getKey(), KNOWN_ORIGIN)
.set(DittoHeaderDefinition.CONTENT_TYPE.getKey(), KNOWN_CONTENT_TYPE)
.set(DittoHeaderDefinition.ACCEPT.getKey(), KNOWN_ACCEPT)
.set(DittoHeaderDefinition.AUTHORIZATION.getKey(), KNOWN_AUTHORIZATION)
.set(DittoHeaderDefinition.REPLY_TARGET.getKey(), Integer.parseInt(KNOWN_REPLY_TARGET))
.set(DittoHeaderDefinition.INBOUND_PAYLOAD_MAPPER.getKey(), KNOWN_MAPPER)
.set(DittoHeaderDefinition.ORIGINATOR.getKey(), KNOWN_ORIGINATOR)
Expand Down Expand Up @@ -780,6 +783,7 @@ private static Map<String, String> createMapContainingAllKnownHeaders() {
result.put(DittoHeaderDefinition.ETAG.getKey(), KNOWN_ETAG.toString());
result.put(DittoHeaderDefinition.CONTENT_TYPE.getKey(), KNOWN_CONTENT_TYPE);
result.put(DittoHeaderDefinition.ACCEPT.getKey(), KNOWN_ACCEPT);
result.put(DittoHeaderDefinition.AUTHORIZATION.getKey(), KNOWN_AUTHORIZATION);
result.put(DittoHeaderDefinition.ORIGIN.getKey(), KNOWN_ORIGIN);
result.put(DittoHeaderDefinition.REPLY_TARGET.getKey(), KNOWN_REPLY_TARGET);
result.put(DittoHeaderDefinition.INBOUND_PAYLOAD_MAPPER.getKey(), KNOWN_MAPPER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.eclipse.ditto.placeholders.Placeholder;
import org.eclipse.ditto.placeholders.PlaceholderFactory;
import org.eclipse.ditto.placeholders.PlaceholderResolver;
import org.eclipse.ditto.protocol.Adaptable;
import org.eclipse.ditto.protocol.TopicPath;
import org.eclipse.ditto.protocol.adapter.DittoProtocolAdapter;
import org.eclipse.ditto.things.model.signals.events.ThingEventToThingConverter;
Expand Down Expand Up @@ -103,10 +102,9 @@ public static ExpressionResolver forOutbound(final OutboundSignal.Mapped mappedO

final Signal<?> signal = mappedOutboundSignal.getSource();
final ExternalMessage externalMessage = mappedOutboundSignal.getExternalMessage();
final Adaptable adaptable = mappedOutboundSignal.getAdaptable();
return PlaceholderFactory.newExpressionResolver(
RESOLVER_CREATORS.stream()
.map(creator -> creator.create(adaptable.getDittoHeaders(),
.map(creator -> creator.create(signal.getDittoHeaders(),
signal,
externalMessage.getTopicPath().orElse(null),
signal.getDittoHeaders().getAuthorizationContext(),
Expand Down
Loading