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

[improve][authentication] Pass the authorization when user lookup transactionCoordinator topic #22744

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TakaHiR07
Copy link
Contributor

@TakaHiR07 TakaHiR07 commented May 20, 2024

Motivation

As seen in the AuthenticatedTransactionProducerConsumerTest, if we enable authorization, and want to produce/consume to a normal topic by transaction, we not only need to grant permission on normal topic, but also need to grant permission on system namespace.

企业微信截图_5ed0c5c6-6101-4217-9c21-3aa3e5bba35b

It looks unreasonable and very dangerous.

Normal users just want to produce/consume to a normal topic by transaction, but super user need to grant the whole system namespace permission to them. I think the reasonable way is to make normal user unable to produce/consume system namespace directly, instead, make them able to lookup the transactionCoordinator topic.

Modifications

When do canLookupAsync(), if the topic is tc topic, pass the authorization

Verifying this change

  • Make sure that the change passes the CI checks.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: TakaHiR07#20

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label May 20, 2024
@TakaHiR07 TakaHiR07 changed the title [Improve][authentication] Pass the authorization when user lookup transactionCoordinator topic [improve][authentication] Pass the authorization when user lookup transactionCoordinator topic May 21, 2024
@TakaHiR07
Copy link
Contributor Author

@nodece @michaeljmarshall could you take a look of this problem. thx

@TakaHiR07 TakaHiR07 force-pushed the improve_tc_lookup_auth branch from 3b969e2 to c1f37d2 Compare May 22, 2024 10:06
@nodece
Copy link
Member

nodece commented May 23, 2024

The pulsar/system is the system namespace, we should skip the permission checks. When creating a system topic, the client should have the superuser or tenant admin role.

@@ -155,6 +156,9 @@ public CompletableFuture<Boolean> canConsumeAsync(TopicName topicName, String ro
@Override
public CompletableFuture<Boolean> canLookupAsync(TopicName topicName, String role,
AuthenticationDataSource authenticationData) {
if (SystemTopicNames.isTransactionCoordinatorAssign(topicName)) {
Copy link
Member

Choose a reason for hiding this comment

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

You should write this code in the org.apache.pulsar.broker.authentication.AuthenticationService.

That looks like an important change, could you discuss this in the mailing list?

Copy link
Member

Choose a reason for hiding this comment

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

Why should we implement it in AuthenticationService?

Copy link
Member

@thetumbled thetumbled left a comment

Choose a reason for hiding this comment

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

@@ -155,6 +156,9 @@ public CompletableFuture<Boolean> canConsumeAsync(TopicName topicName, String ro
@Override
public CompletableFuture<Boolean> canLookupAsync(TopicName topicName, String role,
AuthenticationDataSource authenticationData) {
if (SystemTopicNames.isTransactionCoordinatorAssign(topicName)) {
Copy link
Contributor

@congbobo184 congbobo184 Jul 17, 2024

Choose a reason for hiding this comment

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

how do we control user can use transaction?
It seem like a good way to control user to use transaction, if user have the produce role of TC system topic, then can send transaction message and can do lookup for tc topic. this only a idea. WDYT? @thetumbled @TakaHiR07

Copy link
Member

Choose a reason for hiding this comment

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

Do we need to restrict user to use transaction feature by authorizing the lookup permission of TC system topic?
It is weird as there is no official document pointing out this.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is just a thought, as we currently have no means to restrict users from using transactions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants