File tree Expand file tree Collapse file tree
auth/src/main/java/org/apache/rocketmq/auth/authentication/manager Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,9 +38,14 @@ public class AuthenticationMetadataManagerImpl implements AuthenticationMetadata
3838
3939 private final AuthorizationMetadataProvider authorizationMetadataProvider ;
4040
41+ private boolean authorizationEnabled ;
42+
4143 public AuthenticationMetadataManagerImpl (AuthConfig authConfig ) {
4244 this .authenticationMetadataProvider = AuthenticationFactory .getMetadataProvider (authConfig );
4345 this .authorizationMetadataProvider = AuthorizationFactory .getMetadataProvider (authConfig );
46+ if (authConfig != null ) {
47+ this .authorizationEnabled = authConfig .isAuthorizationEnabled ();
48+ }
4449 this .initUser (authConfig );
4550 }
4651
@@ -146,7 +151,12 @@ public CompletableFuture<Void> deleteUser(String username) {
146151 throw new AuthenticationException ("username can not be blank" );
147152 }
148153 CompletableFuture <Void > deleteUser = this .getAuthenticationMetadataProvider ().deleteUser (username );
149- CompletableFuture <Void > deleteAcl = this .getAuthorizationMetadataProvider ().deleteAcl (User .of (username ));
154+ CompletableFuture <Void > deleteAcl = null ;
155+ if (!authorizationEnabled && authorizationMetadataProvider == null ) {
156+ deleteAcl = CompletableFuture .completedFuture (null );
157+ } else {
158+ deleteAcl = this .getAuthorizationMetadataProvider ().deleteAcl (User .of (username ));
159+ }
150160 return CompletableFuture .allOf (deleteUser , deleteAcl );
151161 } catch (Exception e ) {
152162 this .handleException (e , result );
You can’t perform that action at this time.
0 commit comments