Преглед изворни кода

AMBARI-25175: Start, Stop, Service Check and other request actions using PUT/POST from Ambari UI do not respond when tried via Knox TP (#3467)

Zhiguo Wu пре 3 година
родитељ
комит
4830adb9bc

+ 2 - 0
ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestFactory.java

@@ -26,6 +26,7 @@ import java.util.Map;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.UriInfo;
 
+import org.apache.ambari.server.api.predicate.QueryLexer;
 import org.apache.ambari.server.api.resources.ResourceDefinition;
 import org.apache.ambari.server.api.resources.ResourceInstance;
 
@@ -154,6 +155,7 @@ public class RequestFactory {
    */
   private boolean applyDirectives(Request.Type requestType, RequestBody body, UriInfo uriInfo, ResourceInstance resource) {
     Map<String, String> queryParameters = getQueryParameters(uriInfo, body);
+    queryParameters.remove(QueryLexer.QUERY_DOAS); // KNOX appends a doAs parameter to every request. Ignore this as it's neither a query predicate nor a directive.
     Map<String, String> requestInfoProperties;
     boolean allDirectivesApplicable = true;
     if (!queryParameters.isEmpty()) {

+ 1 - 1
ambari-server/src/test/python/ldap-password.dat

@@ -1 +1 @@
-password
+${alias=ambari.ldap.manager.password}

+ 4 - 0
ambari-web/app/utils/ajax/ajax.js

@@ -3321,6 +3321,10 @@ var formatRequest = function (data) {
   if (this.format) {
     jQuery.extend(opt, this.format(data, opt));
   }
+  if (!('headers' in opt && 'Content-Type' in opt.headers)) {
+    // With the default www-url-form-encoded Content-Type KNOX would corrupt the json content.
+    opt.headers['Content-Type'] = 'text/plain';
+  }
   var statusCode = jQuery.extend({}, require('data/statusCodes'));
   statusCode['404'] = function () {
     console.log("Error code 404: URI not found. -> " + opt.url);