Skip to content

KAFKA-3396 : Unauthorized topics are returned to the user#1908

Closed
edoardocomar wants to merge 14 commits intoapache:trunkfrom
edoardocomar:KAFKA-3396
Closed

KAFKA-3396 : Unauthorized topics are returned to the user#1908
edoardocomar wants to merge 14 commits intoapache:trunkfrom
edoardocomar:KAFKA-3396

Conversation

@edoardocomar
Copy link
Contributor

Reopening of #1428

Copy link
Member

Choose a reason for hiding this comment

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

This seems unintentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for spotting that shameful oops, @ijuma . full test passes

@edoardocomar
Copy link
Contributor Author

Hi @ijuma all tests seem to have passed (they do locally for me) but the Jenkins build failed

@ijuma
Copy link
Member

ijuma commented Sep 27, 2016

Thanks @edoardocomar, will take another look soon. Can you please add a note to upgrade.html?

Copy link
Member

Choose a reason for hiding this comment

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

There should be no space before the :. There are a few other cases like that.

Copy link
Member

Choose a reason for hiding this comment

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

I think the usage of INVALID_TOPIC_EXCEPTION is intentional here. One of the differences is that INVALID_TOPIC_EXCEPTION is not retriable. @granthenke, is that right?

Copy link
Member

Choose a reason for hiding this comment

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

I think changing to a UNKNOWN_TOPIC_OR_PARTITION exception might make sense in this case. Especially if that is the behavior we are using for the other requests where a topic is not authorized and we don't want to leak the information. Consistency is always easier to reason about.

The most important thing is that the exception doesn't give any indication of whether or not the topic exists. Its behavior should the same as if the topic isn't there at all. If this exception is changed, I think the InvalidTopicException in AdminUtils may need to be changed too:
https://github.com/apache/kafka/blob/trunk/core/src/main/scala/kafka/admin/AdminUtils.scala#L328

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@edoardocomar
Copy link
Contributor Author

added a note to upgrade.html in the upgrade_1010_notable section

Copy link
Member

Choose a reason for hiding this comment

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

Closing <\li> missing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@hachikuji hachikuji left a comment

Choose a reason for hiding this comment

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

Left a couple more comments. It's looking pretty good on the server side. However, I still do not see any checks on the client side in the offset fetch and offset commit response handlers for the UNKNOWN_TOPIC_OR_PARTITION error code. I feel it would also be helpful when we catch this error explicitly and retry internally to log a message which mentions that the user may not have Describe access. Is there any reason we shouldn't do this?

Copy link
Contributor

@hachikuji hachikuji Sep 28, 2016

Choose a reason for hiding this comment

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

Would it be easier to handle the logging for this case in the initial call to partition above? May as well save the redundant cache lookup and it seems possible that the cache may have changed in between the first check and this one. Another minor point: is it worthwhile checking if DEBUG is enabled prior to doing this loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done thanks

Copy link
Contributor

@hachikuji hachikuji Sep 28, 2016

Choose a reason for hiding this comment

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

For discussion: Since Write access subsumes Describe, I'm wondering if it would make sense to change the order of the checks to something like this:

  1. Check for Write access on all topics.
  2. For those topics without Write access:
    1. If no Describe access or not exists -> UNKNOWN_TOPIC_OR_PARTITION
    2. Otherwise -> TOPIC_AUTHORIZATION_FAILED

The intuition is that failing Write should be the exceptional case. The one annoying thing is that you also need to check existence for topics which are authorized for Write. The fetch request handler could be done similarly since Read access also subsumes Describe.

Copy link
Contributor

@hachikuji hachikuji Sep 28, 2016

Choose a reason for hiding this comment

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

@ijuma Is it correct that we return TOPIC_AUTHORIZATION_FAILED here? Whether or not it's ideal, the authorization check is on the Cluster resource currently.

Copy link
Member

@ijuma ijuma Sep 28, 2016

Choose a reason for hiding this comment

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

That's a bit weird, isn't it? In a KIP discussion, we had said that we wanted to change it so that one would require a Create Topic instead of Create Cluster ACL for topic creation (would probably need both for compatibility), so it seems reasonable to keep throwing a TOPIC_AUTHORIZATION_FAILED here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ack. I agree that this is probably better long term, even if it's a little misleading at the moment.

@edoardocomar edoardocomar changed the title Kafka 3396 KAFKA-3396 : Unauthorized topics are returned to the user Sep 28, 2016
@edoardocomar
Copy link
Contributor Author

Handling UTOP in consumerCoordinator handleResponse for fetchOffset and commitOffset, with more descriptive msg

@edoardocomar
Copy link
Contributor Author

rebased/merged and fixed spurious test failure

@edoardocomar
Copy link
Contributor Author

@ijuma the Jenkins build failed to complete again. However all tests pass locally for me

@hachikuji
Copy link
Contributor

I've been running system tests against this branch. There were a couple test failures, but I think they are known transient failures. I'm running again to be sure. In the meantime, I'll do another pass over the code and hopefully we can merge this today.

edoardocomar and others added 14 commits September 30, 2016 22:03
Modified KafkaApis to return Errors.UNKNOWN_TOPIC_OR_PARTITION if
principal has no Describe access to topic

Unit tests expanded

Some paths cause the client to block due to bug
https://issues.apache.org/jira/browse/KAFKA-3727?filter=-2
tests work around this by executing in separate thread
- Added tests from 44ad3ec
- Small refactorings
Rebased after kip-79 changes.
Fixing leak of topic for LIST_OFFSETS when unauthorized.
Added tests.
Revised handling of FETCH PRODUCE and DELETE requests
oops had commented out part os a test by mistake
addressing comments: code formatting, not in upgrade.html
addressing comments: 
handling UTOP in ConsumerCoordinator offset fetch/commit
improved logging efficiency on the server
test cleanup and fixing intermittent failure
throwing UTOP also form AdminUtils.delete
@edoardocomar
Copy link
Contributor Author

@hachikuji I rebased and rerun all the tests locally on my mac and they pass.

@hachikuji
Copy link
Contributor

LGTM. Merging to trunk and 0.10.1. Thanks @edoardocomar and @mimaison for the hard work (and patience) on this patch! I have some minor cleanups/improvements on the client and in testing, which I will submit in a follow-up PR.

@asfgit asfgit closed this in 8124f6e Oct 1, 2016
asfgit pushed a commit that referenced this pull request Oct 1, 2016
Reopening of #1428

Author: Edoardo Comar <ecomar@uk.ibm.com>
Author: Mickael Maison <mickael.maison@gmail.com>

Reviewers: Grant Henke <granthenke@gmail.com>, Ismael Juma <ismael@juma.me.uk>, Jason Gustafson <jason@confluent.io>

Closes #1908 from edoardocomar/KAFKA-3396

(cherry picked from commit 8124f6e)
Signed-off-by: Jason Gustafson <jason@confluent.io>
@hachikuji
Copy link
Contributor

By the way, I changed the title. Hopefully it's reasonable.

@edoardocomar edoardocomar deleted the KAFKA-3396 branch June 22, 2017 12:11
efeg pushed a commit to efeg/kafka that referenced this pull request May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments