pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

Check create topic permission on topic creation using pulsar proto clients

Open KannarFr opened this issue 3 years ago • 19 comments

Fixes #17406

Motivation

Enable CREATE_TOPIC permission check on topic auto creation.

Modifications

Introduce AuthAction.create_topic for the PulsarAuthorizationProvider

Verifying this change

  • [ ] Make sure that the change passes the CI checks.

This change updated tests and can be verified as follows:

  • updated test and give create_topic permission on the namespace

Does this pull request potentially affect one of the following parts:

  • it affects permissions as currently, CREATE_TOPIC wasn't checked on the default authZ provider.

  • [x] doc-required

KannarFr avatar Sep 01 '22 17:09 KannarFr

@KannarFr Please provide a correct documentation label for your PR. Instructions see Pulsar Documentation Label Guide.

github-actions[bot] avatar Sep 01 '22 17:09 github-actions[bot]

@gaoran10 the failing tests are due to CI flakyness, nope?

KannarFr avatar Sep 19 '22 14:09 KannarFr

@michaeljmarshall are you ok with the way I've done it in handleProducer?

KannarFr avatar Oct 17 '22 14:10 KannarFr

@KannarFr Please add the following content to your PR description and select a checkbox:

- [ ] `doc` <!-- Your PR contains doc changes -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->

github-actions[bot] avatar Oct 18 '22 05:10 github-actions[bot]

@michaeljmarshall there is something I missed?

KannarFr avatar Oct 31 '22 14:10 KannarFr

The pr had no activity for 30 days, mark with Stale label.

github-actions[bot] avatar Dec 01 '22 02:12 github-actions[bot]

@poorbarcode, @michaeljmarshall looks not available, can you ping someone else? It would be cool to merge it upstream asap :D.

KannarFr avatar Apr 18 '23 20:04 KannarFr

After reviewing this, here are a collection of thoughts on Pulsar's Authorization.

At it's core, I think the problem described by #17406 is that allowAutoTopicCreation is a configuration about permission/authorization.

Yes?

In my view, the allowAutoTopicCreation=true says "a role with permission to produce/consume to a topic also has permission to create that topic".

The HTTP admin API does not comply with this sentence. The CREATE_TOPIC operation is defined and used by HTTP admin API authz checks. I agree that this is introducing breaking changes in the permissions system and this is a problem, but there is authZ plugin provider providing this operation check and does not verify it during producer/consumer. So, I have no idea what the best answer is, but we can't stay and need to find a solution or make a decision here.

This change proposes that allowAutoTopicCreation=true and produce/consumer permissions are insufficient, and that a role must also have explicit permission to create a topic.

Well, this is the default behavior of every configurations keys in pulsar. Like namespace policies or tiered storage configurations, there is a default value that can be overridden by custom namespace policies.

KannarFr avatar Apr 19 '23 10:04 KannarFr

The HTTP admin API does not comply with this sentence.

Fair point. I hadn't considered the pulsar and http endpoints together when writing that generalization.

I agree that this is introducing breaking changes in the permissions system and this is a problem, but there is authZ plugin provider providing this operation check and does not verify it during producer/consumer.

Is there another way to achieve this? Perhaps we can introduce an additional check that calls the authorization service and then we'll implement the default PulsarAuthorizationProvider in such a way that there are no breaking changes.

I think it might make sense to discuss the underlying inconsistency on the pulsar mailing list.

michaeljmarshall avatar Apr 19 '23 15:04 michaeljmarshall

Perhaps we can introduce an additional check that calls the authorization service and then we'll implement the default PulsarAuthorizationProvider in such a way that there are no breaking change

This LGTM. Can you drive this discussion on the ML if you think it's required? Shall I do it?

KannarFr avatar Apr 19 '23 17:04 KannarFr

Perhaps we can introduce an additional check that calls the authorization service and then we'll implement the default PulsarAuthorizationProvider in such a way that there are no breaking change

This LGTM. Can you drive this discussion on the ML if you think it's required? Shall I do it?

I won't be able to drive this discussion. Let me know if you have any questions though.

michaeljmarshall avatar Apr 19 '23 22:04 michaeljmarshall

The pr had no activity for 30 days, mark with Stale label.

github-actions[bot] avatar Jun 02 '23 02:06 github-actions[bot]

I sent

Hi,

CREATE_TOPIC authorization check is not performed when trying to PRODUCE/CONSUME a topic, it has been referenced: https://github.com/apache/pulsar/issues/17406.

I opened a PR to fix it https://github.com/apache/pulsar/pull/17411, but Michael reported issues about backward compatibility (which is totally correct). Adding support of CREATE_TOPIC authorization as-is will break current authorization system. I noticed that HTTP Admin API verifies the CREATE_TOPIC right when creating topic, so we have inconsistencies between pulsar binary protocol and the HTTP admin API on this.

Also, the AuthorizationProvider is an interface exposing the CREATE_TOPIC feature for authZ plugins. But it is inconsistent too.

Michael suggested to fix this interface to support the CREATE_TOPIC check and adapt the pulsar's DefaultAuthzProvider to continue as-is.

I'd like to know what do you think?

Thanks,

Kannar

On the ML the 20/04/2023 and still have no answers @michaeljmarshall @nodece.

KannarFr avatar Jun 02 '23 08:06 KannarFr

Is there any progression on this issue ?

Nowadays avatar Jul 31 '23 15:07 Nowadays

Unfortunately, no. I don't know why this is stuck @michaeljmarshall?

KannarFr avatar Jul 31 '23 16:07 KannarFr

@gaoran10 @MarvinCai

KannarFr avatar Jul 31 '23 16:07 KannarFr

@michaeljmarshall @gaoran10 @MarvinCai, it makes sense to rebase it..?

KannarFr avatar Oct 04 '23 23:10 KannarFr

Is there any way to move forward with this PR ?

publishing/consuming and creating/deleting a topic are clearly different actions, and thus should require different authorization.

Why would there be an api to create/delete topics if that was not the case ?

Nowadays avatar Oct 05 '23 07:10 Nowadays

Any bumps?

KannarFr avatar Mar 22 '24 12:03 KannarFr