server: Remove the rule(s) validation with api names while importing role, to be in sync with the create role permission behavior (#4840)

This PR removes the rule(s) validation with api names while importing a role. This will be in sync with the current create role permission behavior.
This commit is contained in:
sureshanaparti 2021-03-29 16:23:43 +05:30 committed by GitHub
parent b8884efa7f
commit 89111110cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 16 deletions

View File

@ -42,6 +42,4 @@ public interface ApiServerService {
public String handleRequest(Map<String, Object[]> params, String responseType, StringBuilder auditTrailSb) throws ServerApiException;
public Class<?> getCmdClass(String cmdName);
public boolean isValidApiName(String apiName);
}

View File

@ -94,9 +94,6 @@ public class ImportRoleCmd extends RoleCmd {
if (Strings.isNullOrEmpty(rule)) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Empty rule provided in rules param");
}
if (!rule.contains("*") && !_apiServer.isValidApiName(rule)) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid api name: " + rule + " provided in rules param");
}
ruleDetails.put(ApiConstants.RULE, new Rule(rule));
String permission = detail.get(ApiConstants.PERMISSION);

View File

@ -1208,17 +1208,6 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
}
}
@Override
public boolean isValidApiName(String apiName) {
if (apiName == null || apiName.isEmpty())
return false;
if (!s_apiNameCmdClassMap.containsKey(apiName))
return false;
return true;
}
// FIXME: rather than isError, we might was to pass in the status code to give more flexibility
private void writeResponse(final HttpResponse resp, final String responseText, final int statusCode, final String responseType, final String reasonPhrase) {
try {