You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve testing for authorization to prevent regressions in topic operations related to subscriptions #19183
I searched in the issues and found nothing similar.
Motivation
In PR #19176, I fixed a minor regression in our authorization code base related to topic operations. We should have better tests or possibly a better design to make sure we catch these regressions before they are merged.
The tests should also cover cases seen in #17123 and in #19184
publicCompletableFuture<Boolean> allowTopicOperationAsync(TopicNametopicName,
TopicOperationoperation,
Stringrole,
AuthenticationDataSourceauthData) {
if (log.isDebugEnabled()) {
log.debug("Check if role {} is allowed to execute topic operation {} on topic {}",
role, operation, topicName);
}
if (!this.conf.isAuthorizationEnabled()) {
returnCompletableFuture.completedFuture(true);
}
// This check prevents regressions... but it'd run everywhere, how do we use this?if (TopicOperation.subscriptionNameRequiredForAuthorization(operation) && authData.hasSubscription()) {
}
The downside is that it would need to get evaluated on every call to authorize. This could help third party plugins. However, I think the ideal solution catches issues with tests and not with verification in production runtime.
Activity
[cleanup][broker] Pass subName to authz provider on unsubscribe (#19176)
[fix][broker] Pass subName for subscription operations in ServerCnx (#…
[fix][broker] Pass subName for subscription operations in ServerCnx (#…
[fix][broker] Pass subName for subscription operations in ServerCnx (#…
[fix][broker] Pass subName for subscription operations in ServerCnx (a…
michaeljmarshall commentedon Jan 25, 2023
One comment on a potential design is to add something like the following to the
TopicOperationenum:The downside is that it would need to get evaluated on every call to authorize. This could help third party plugins. However, I think the ideal solution catches issues with tests and not with verification in production runtime.
github-actions commentedon Feb 25, 2023
The issue had no activity for 30 days, mark with Stale label.
michaeljmarshall commentedon Mar 1, 2023
Another option is to use
assertin the case where we ought to have a subscription. That might not be the right solution though.github-actions commentedon Apr 2, 2023
The issue had no activity for 30 days, mark with Stale label.