Skip to content

Commit f505594

Browse files
committed
fix delete user
1 parent e4b731c commit f505594

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

auth/src/main/java/org/apache/rocketmq/auth/authentication/manager/AuthenticationMetadataManagerImpl.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)