Skip to content
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

KAFKA-7185: Allow empty resource name when matching ACLs #5400

Merged
merged 3 commits into from
Jul 20, 2018

Conversation

dhruvilshah3
Copy link
Contributor

@dhruvilshah3 dhruvilshah3 commented Jul 19, 2018

No description provided.

@dhruvilshah3 dhruvilshah3 changed the title KAFKA-7185: Allow empty group id when matching ACLs KAFKA-7185: Allow empty resource name when matching ACLs Jul 19, 2018
@rajinisivaram
Copy link
Contributor

retest this please

def testAuthorizeWithEmptyResourceName(): Unit = {
assertFalse(simpleAclAuthorizer.authorize(session, Read, Resource(Group, "", LITERAL)))
simpleAclAuthorizer.addAcls(Set[Acl](allowReadAcl), Resource(Group, WildCardResource, LITERAL))
assertTrue(simpleAclAuthorizer.authorize(session, Read, Resource(Group, "", LITERAL)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to authorize the empty resource only? It would be good to have a test for that case too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can create ACLs for empty string since ACLs are stored in a ZK node with the resource name (it is an odd default to use, but I suppose we can't get of it now).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I actually tried testing this but the create failed with an exception because of the reason you mention.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should just have a test for that case to assert the current behaviour (even if not ideal)

@@ -238,7 +238,7 @@ class SimpleAclAuthorizer extends Authorizer with Logging {

val prefixed = aclCache.range(
Resource(resourceType, resourceName, PatternType.PREFIXED),
Resource(resourceType, resourceName.substring(0, 1), PatternType.PREFIXED)
Resource(resourceType, resourceName.substring(0, Math.min(1, resourceName.length)), PatternType.PREFIXED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you simply use take instead of substring?

@dhruvilshah3
Copy link
Contributor Author

Retest this please

Copy link
Contributor

@ijuma ijuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rajinisivaram
Copy link
Contributor

@dhruvilshah3 Thanks for the PR, merging to trunk and 2.0.

@rajinisivaram rajinisivaram merged commit 9449f05 into apache:trunk Jul 20, 2018
rajinisivaram pushed a commit that referenced this pull request Jul 20, 2018
Reviewers: Ismael Juma <ismael@juma.me.uk>, Rajini Sivaram <rajinisivaram@googlemail.com>
@dhruvilshah3 dhruvilshah3 deleted the acls-fix branch July 20, 2018 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants