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

[controller] Manual store deletion only can be done by specific user group. #1199

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

haoxu07
Copy link
Contributor

@haoxu07 haoxu07 commented Sep 26, 2024

Summary, imperative, start upper case, don't end with a period

This Code change adds a feature allowing manual store deletion from admin tool to a specific user group only. The newly added interface of isAllowlistUsersForStoreDeletion for AccessController will be used to check if user belong to that specific user group.

How was this PR tested?

Does this PR introduce any user-facing changes?

  • [*] No. You can skip the rest of this section.
  • Yes. Make sure to explain your proposed changes and call out the behavior change.

* @param method the operation (GET, POST, ...) to perform against the resource
* @return true if the client is admin
*/
boolean isAllowlistUsersForStoreDeletion(X509Certificate clientCert, String resource, String method);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we rename to hasAccessToDelete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, we could do that, but wondering why this naming is better?

Copy link
Contributor

Choose a reason for hiding this comment

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

It feels more concise to me, while conveying the same information

@haoxu07 haoxu07 marked this pull request as ready for review September 26, 2024 17:24
Comment on lines +158 to +162
/**
* Grant access if it's not required to check ACL.
* {@link accessController} will be empty if ACL is not enabled.
*/
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to do the opposite thing, right? If ACL is not enabled, do not allow the store deletion at all.

Besides, it's cleaner to check whether ACL is enabled in AdminSparkServer - do not register this API if ACL is not enabled:
if (sslEnabled) { httpService.post(DELETE_STORE.getPath(), new VeniceParentControllerRegionStateHandler(admin, storesRoutes.deleteStore(admin))); }
The spike will be fixing the test cases; let's see how difficult that is. WDYT?

// This is to limit the manual store deletion from admin tool without https to a specific allow list users.
if (!isSslEnabled()
&& !checkIsAllowListUser(request, veniceResponse, () -> isAllowListUserForStoreDeletion(request))) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should fail the request and send bad request error code to user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The checkedIsAllowListUser will mark the request as Bad Request:

  protected boolean checkIsAllowListUser(
      Request request,
      ControllerResponse veniceResponse,
      BooleanSupplier isAllowListUser) {
    if (!isAllowListUser.getAsBoolean()) {
      veniceResponse.setError(ACL_CHECK_FAILURE_WARN_MESSAGE_PREFIX + request.url());
      veniceResponse.setErrorType(ErrorType.BAD_REQUEST);
      return false;
    }
    return true;
  }

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.

3 participants