-
Notifications
You must be signed in to change notification settings - Fork 15k
KIP-290 Prefixed ACLs #5117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
KIP-290 Prefixed ACLs #5117
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
34c35aa
KAFKA-6841: Piyush changes
big-andy-coates 8d07119
Add testing and Admin client changes.
big-andy-coates 3f9b2ba
upgrade.html update.
big-andy-coates 7303e7e
- review comments
big-andy-coates d5cca47
- don't use deprecated functions internally
big-andy-coates dc8a5e2
Merge branch 'trunk' into prefixed-acls
big-andy-coates 8d37198
self review.
big-andy-coates 105bb82
review changes
big-andy-coates d600682
review changesreview changes
big-andy-coates 458e5aa
self review
big-andy-coates 8ae4e11
Add additional test.
big-andy-coates b78d226
Add additional test.
big-andy-coates 6f96d0d
Merge remote-tracking branch 'apache-github/trunk' into kip-290-acl-p…
ijuma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -18,12 +18,14 @@ | |
|
|
||
| import org.apache.kafka.common.acl.AccessControlEntryFilter; | ||
| import org.apache.kafka.common.acl.AclBindingFilter; | ||
| import org.apache.kafka.common.errors.UnsupportedVersionException; | ||
| import org.apache.kafka.common.protocol.ApiKeys; | ||
| import org.apache.kafka.common.protocol.types.ArrayOf; | ||
| import org.apache.kafka.common.protocol.types.Field; | ||
| import org.apache.kafka.common.protocol.types.Schema; | ||
| import org.apache.kafka.common.protocol.types.Struct; | ||
| import org.apache.kafka.common.resource.ResourceFilter; | ||
| import org.apache.kafka.common.resource.ResourceNameType; | ||
| import org.apache.kafka.common.utils.Utils; | ||
|
|
||
| import java.nio.ByteBuffer; | ||
|
|
@@ -37,6 +39,7 @@ | |
| import static org.apache.kafka.common.protocol.CommonFields.PERMISSION_TYPE; | ||
| import static org.apache.kafka.common.protocol.CommonFields.PRINCIPAL_FILTER; | ||
| import static org.apache.kafka.common.protocol.CommonFields.RESOURCE_NAME_FILTER; | ||
| import static org.apache.kafka.common.protocol.CommonFields.RESOURCE_NAME_TYPE_FILTER; | ||
| import static org.apache.kafka.common.protocol.CommonFields.RESOURCE_TYPE; | ||
|
|
||
| public class DeleteAclsRequest extends AbstractRequest { | ||
|
|
@@ -52,9 +55,20 @@ public class DeleteAclsRequest extends AbstractRequest { | |
| PERMISSION_TYPE)))); | ||
|
|
||
| /** | ||
| * The version number is bumped to indicate that on quota violation brokers send out responses before throttling. | ||
| * V1 sees a new `RESOURCE_NAME_TYPE_FILTER` that controls how the filter handles different resource name types. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to preserve the comment on quota violation.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. |
||
| * Also, when the quota is violated, brokers will respond to a version 1 or later request before throttling. | ||
| * | ||
| * For more info, see {@link org.apache.kafka.common.resource.ResourceNameType}. | ||
| */ | ||
| private static final Schema DELETE_ACLS_REQUEST_V1 = DELETE_ACLS_REQUEST_V0; | ||
| private static final Schema DELETE_ACLS_REQUEST_V1 = new Schema( | ||
| new Field(FILTERS, new ArrayOf(new Schema( | ||
| RESOURCE_TYPE, | ||
| RESOURCE_NAME_FILTER, | ||
| RESOURCE_NAME_TYPE_FILTER, | ||
| PRINCIPAL_FILTER, | ||
| HOST_FILTER, | ||
| OPERATION, | ||
| PERMISSION_TYPE)))); | ||
|
|
||
| public static Schema[] schemaVersions() { | ||
| return new Schema[]{DELETE_ACLS_REQUEST_V0, DELETE_ACLS_REQUEST_V1}; | ||
|
|
@@ -84,6 +98,8 @@ public String toString() { | |
| DeleteAclsRequest(short version, List<AclBindingFilter> filters) { | ||
| super(version); | ||
| this.filters = filters; | ||
|
|
||
| validate(version, filters); | ||
| } | ||
|
|
||
| public DeleteAclsRequest(Struct struct, short version) { | ||
|
|
@@ -136,4 +152,16 @@ public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable throwable | |
| public static DeleteAclsRequest parse(ByteBuffer buffer, short version) { | ||
| return new DeleteAclsRequest(DELETE_ACLS.parseRequest(version, buffer), version); | ||
| } | ||
|
|
||
| private void validate(short version, List<AclBindingFilter> filters) { | ||
| if (version == 0) { | ||
| final boolean unsupported = filters.stream() | ||
| .map(AclBindingFilter::resourceFilter) | ||
| .map(ResourceFilter::nameType) | ||
| .anyMatch(nameType -> nameType != ResourceNameType.LITERAL); | ||
| if (unsupported) { | ||
| throw new UnsupportedVersionException("Version 0 only supports literal resource name types"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't figure out how to add a comment to the correct line using github's terrible user interface. But on line 110 where you have the code:
You must add verification that the version you are using supports the ACLs you are trying to send. If someone tries to set a prefix ACL when using CREATE_ACLS_REQUEST_V0, the code must throw
UnsupportedVersionException. In fact, anything besidesResourceNameType.LITERALshould trigger a UVE there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider it done.