Skip to content

Commit

Permalink
#8615 fix DeleteUserSubCommand command failed when acl2.0 authenticat…
Browse files Browse the repository at this point in the history
…ion enabled and authorization disabled
  • Loading branch information
kingkh1995 committed Sep 13, 2024
1 parent 7748040 commit 6d6a7c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ public CompletableFuture<Void> deleteUser(String username) {
throw new AuthenticationException("username can not be blank");
}
CompletableFuture<Void> deleteUser = this.getAuthenticationMetadataProvider().deleteUser(username);
CompletableFuture<Void> deleteAcl = this.getAuthorizationMetadataProvider().deleteAcl(User.of(username));
CompletableFuture<Void> deleteAcl = this.getAuthorizationMetadataProvider() == null ? CompletableFuture.completedFuture(null)
: this.getAuthorizationMetadataProvider().deleteAcl(User.of(username));
return CompletableFuture.allOf(deleteUser, deleteAcl);
} catch (Exception e) {
this.handleException(e, result);
Expand Down Expand Up @@ -214,9 +215,6 @@ private AuthenticationMetadataProvider getAuthenticationMetadataProvider() {
}

private AuthorizationMetadataProvider getAuthorizationMetadataProvider() {
if (authorizationMetadataProvider == null) {
throw new IllegalStateException("The authorizationMetadataProvider is not configured");
}
return authorizationMetadataProvider;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ public void deleteUser() {
Assert.assertNull(user);

this.authenticationMetadataManager.deleteUser("no_user").join();

this.authConfig.setAuthorizationEnabled(false);
this.authenticationMetadataManager = AuthenticationFactory.getMetadataManager(this.authConfig);
this.authenticationMetadataManager.deleteUser("no_user").join();
}

@Test
Expand Down

0 comments on commit 6d6a7c1

Please sign in to comment.