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

Add promotion persmission #2182

Merged
merged 15 commits into from
Jan 22, 2024
Merged

Add promotion persmission #2182

merged 15 commits into from
Jan 22, 2024

Conversation

muralibasani
Copy link
Contributor

Linked issue

Resolves: #2121

What kind of change does this PR introduce?

New permission when topics are promoted

  • a config is added if new permission is required to promote topics

  • a new permission is added and this should be manually assigned to role by users

  • on topic promotion, apart from APPROVE_TOPICS, a check is added to look for permission APPROVE_TOPICS_PROMOTION if server config for extra permission is set to true. by default it is false.

  • Bug fix

  • New feature

  • [ X] Refactor

  • Docs update

  • CI update

What is the current behavior?

Describe the state of the application before this PR. Illustrations appreciated (videos, gifs, screenshots).
there is no extra permission to promote topics

What is the new behavior?

Describe the state of the application after this PR. Illustrations appreciated (videos, gifs, screenshots).
a new permission is added to check if the user has promote topics permission

Other information

Additional changes, explanations of the approach taken, unresolved issues, necessary follow ups, etc.

Requirements (all must be checked before review)

  • The pull request title follows our guidelines
  • Tests for the changes have been added (if relevant)
  • The latest changes from the main branch have been pulled
  • pnpm lint has been run successfully

Signed-off-by: muralibasani <[email protected]>
Copy link
Contributor

@aindriu-aiven aindriu-aiven left a comment

Choose a reason for hiding this comment

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

A few comments

@@ -47,6 +49,8 @@ public class DefaultDataService {
@Value("${klaw.clusterapi.url:http://localhost:9343}")
private String clusterApiUrl;

private boolean extraPermissionForTopicsPromotion;
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesnt look like it is used.


KwProperties kwProperties38 =
new KwProperties(
KLAW_EXTRA_PERMISSION_TOPIC_PROMOTION_KEY,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would probably call this KLAW_OPTIONAL_PERMISSION_TOPIC_PROMOTION_KEY

KLAW_EXTRA_PERMISSION_TOPIC_PROMOTION_KEY,
tenantId,
"false",
"Need of an extra permission APPROVE_TOPICS_PROMOTION to promote topics");
Copy link
Contributor

Choose a reason for hiding this comment

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

"Optional permission APPROVE_TOPICS_PROMOTION to allow users to promote topics but not create topics"

@@ -708,6 +709,16 @@ public ApiResponse approveTopicRequests(String topicId) throws KlawException {
int tenantId = commonUtilsService.getTenantId(userName);
TopicRequest topicRequest = getTopicRequestFromTopicId(Integer.parseInt(topicId), tenantId);

String needOfExtraPermissionForPromote =
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe "isOptionalExtraPermissionForPromote" as it is a boolean?

@@ -708,6 +709,16 @@ public ApiResponse approveTopicRequests(String topicId) throws KlawException {
int tenantId = commonUtilsService.getTenantId(userName);
TopicRequest topicRequest = getTopicRequestFromTopicId(Integer.parseInt(topicId), tenantId);

String needOfExtraPermissionForPromote =
manageDatabase.getKwPropertyValue(KLAW_EXTRA_PERMISSION_TOPIC_PROMOTION_KEY, tenantId);
if (topicRequest.getRequestOperationType().equals(RequestOperationType.PROMOTE.value)
Copy link
Contributor

Choose a reason for hiding this comment

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

This means that if a user also has the CreateTopic Permission they will also require the optional promote permission.

Should it be in the check that they have either the Create or Promote version?

This is just a question though on the UX I don't mind which way its implemented as long as we are happy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Valid question. Approve_topics permission is always required. But if they set this server config property to true, then approve_topics_promotion check is validated

allUserInfo.stream().map(UserInfo::getTenantId).collect(Collectors.toSet());

for (int tenantId : tenantIds) {
List<KwProperties> kwPropertiesList = selectDataJdbc.selectAllKwPropertiesPerTenant(tenantId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry just realised it's probably worth putting a check in here to only update it if it does not already exist?

muralibasani added 6 commits January 10, 2024 16:22
public boolean migrate() {
log.info(
"Start to migrate 2.8.0 data. Add new server property klaw.extra.permission.topic.promote.");

Copy link
Contributor

Choose a reason for hiding this comment

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

minor correction klaw.extra.permission.topic.promote. ->klaw.extra.permission.topic.create

KLAW_OPTIONAL_PERMISSION_NEW_TOPIC_CREATION_KEY,
tenantId,
"false",
"Need of an extra permission " + APPROVE_TOPICS_CREATE + " to create new topics");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Need of an extra permission " + APPROVE_TOPICS_CREATE + " to create new topics");
"Enforce extra permission " + APPROVE_TOPICS_CREATE + " to create new topics");

Copy link
Contributor

@aindriu-aiven aindriu-aiven left a comment

Choose a reason for hiding this comment

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

Functionally looks good, just a couple of small comments

aindriu-aiven
aindriu-aiven previously approved these changes Jan 22, 2024
Copy link
Contributor

@aindriu-aiven aindriu-aiven left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: muralibasani <[email protected]>
Copy link
Contributor

@aindriu-aiven aindriu-aiven left a comment

Choose a reason for hiding this comment

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

LGTM

@muralibasani muralibasani merged commit 0ccca58 into main Jan 22, 2024
24 checks passed
@muralibasani muralibasani deleted the promote-permission branch January 22, 2024 15:52
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.

Create a separate permission for topic promotion
2 participants