-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for EventPolicy filters (#4086)
* Move filters from dispatcher to core module * Move contract filter converter from ConsumerVerticleBuilder to filter package * Update benchmark module to reflect filter package movements * Run update-codegen * AuthenticationHandler -> AuthHandler * Move OIDC discovery from Receiver to TokenVerifierImpl * Rework tokenVerifier AuthZ to read the cloudevent only once from the request when policies claims matched * Rename TokenVerifier to AuthVerifier * Provision EventPolicy filters in contract * Add e2e test * Run hack/update-codegen.sh * Fix: Always pass cloudevent (can be null) to ingresshandler
- Loading branch information
Showing
55 changed files
with
977 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
data-plane/core/src/main/java/dev/knative/eventing/kafka/broker/core/filter/Filter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright © 2018 Knative Authors ([email protected]) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package dev.knative.eventing.kafka.broker.core.filter; | ||
|
||
import dev.knative.eventing.kafka.broker.contract.DataPlaneContract; | ||
import dev.knative.eventing.kafka.broker.core.filter.subscriptionsapi.*; | ||
import io.cloudevents.CloudEvent; | ||
import java.util.List; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* This interface provides an abstraction for filtering {@link CloudEvent} instances. | ||
*/ | ||
@FunctionalInterface | ||
public interface Filter extends Predicate<CloudEvent> { | ||
|
||
/** | ||
* @return noop implementation that always returns true | ||
*/ | ||
static Filter noop() { | ||
return ce -> true; | ||
} | ||
|
||
static Filter fromContract(DataPlaneContract.DialectedFilter filter) { | ||
return switch (filter.getFilterCase()) { | ||
case EXACT -> new ExactFilter(filter.getExact().getAttributesMap()); | ||
case PREFIX -> new PrefixFilter(filter.getPrefix().getAttributesMap()); | ||
case SUFFIX -> new SuffixFilter(filter.getSuffix().getAttributesMap()); | ||
case NOT -> new NotFilter(fromContract(filter.getNot().getFilter())); | ||
case ANY -> new AnyFilter(filter.getAny().getFiltersList().stream() | ||
.map(Filter::fromContract) | ||
.collect(Collectors.toList())); | ||
case ALL -> new AllFilter(filter.getAll().getFiltersList().stream() | ||
.map(Filter::fromContract) | ||
.collect(Collectors.toList())); | ||
case CESQL -> new CeSqlFilter(filter.getCesql().getExpression()); | ||
default -> Filter.noop(); | ||
}; | ||
} | ||
|
||
static Filter fromContract(List<DataPlaneContract.DialectedFilter> filters) { | ||
return new AllFilter(filters.stream().map(Filter::fromContract).collect(Collectors.toList())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.